Docsity

WGU D600 Task 3 Principal Component Analysis (PCA) Complete Regression Report, Python Mode, Exams of Statistical Physics

Toggle sidebar
bg1
WGU D600 Task 3: Principal Component
Analysis (PCA) | Complete Regression Report,
Python Modeling & Results | 2026/2027
Updated
WGU D600 Task 3: Principal Component Analysis (PCA) & Regression
Complete Report, Python Modeling & Evaluation
Course: D600 – Statistical Data Mining
Task: Task 3 – Principal Component Analysis (PCA) & Regression
Tool: Python (pandas, scikit-learn, statsmodels, matplotlib)
Dataset: Home Price Dataset (illustrative; replace with your assigned dataset)
A. GitHub Repository
A subgroup and project were created in GitHub for Task 3. The project was cloned
into the IDE, and commits were made after the completion of each rubric-aligned
section. Each commit included a descriptive message and timestamp to ensure
proper version tracking. The GitHub repository URL was submitted in the
“Comments to Evaluator” section as instructed, and the full branch history was
exported and included in the final submission.
B. Research Question and Goal
B1. Proposal of Question
Research Question: How do structural characteristics (square footage, number of
bedrooms, backyard space, age of home, renovation quality, previous sale price)
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download WGU D600 Task 3 Principal Component Analysis (PCA) Complete Regression Report, Python Mode and more Exams Statistical Physics in PDF only on Docsity!

WGU D600 Task 3: Principal Component

Analysis (PCA) | Complete Regression Report,

Python Modeling & Results | 2026/

Updated

WGU D600 Task 3: Principal Component Analysis (PCA) & Regression Complete Report, Python Modeling & Evaluation Course: D600 – Statistical Data Mining Task: Task 3 – Principal Component Analysis (PCA) & Regression Tool: Python (pandas, scikit-learn, statsmodels, matplotlib) Dataset: Home Price Dataset (illustrative; replace with your assigned dataset) A. GitHub Repository A subgroup and project were created in GitHub for Task 3. The project was cloned into the IDE, and commits were made after the completion of each rubric-aligned section. Each commit included a descriptive message and timestamp to ensure proper version tracking. The GitHub repository URL was submitted in the “Comments to Evaluator” section as instructed, and the full branch history was exported and included in the final submission. B. Research Question and Goal B1. Proposal of Question Research Question: How do structural characteristics (square footage, number of bedrooms, backyard space, age of home, renovation quality, previous sale price)

and neighborhood factors (crime rate, school rating, distance to city center, employment rate, property tax rate, local amenities, transportation access) influence housing prices in the dataset? This question reflects a real-world organizational concern relevant to property valuation and real estate analytics. The problem is suited for linear regression modeling because it examines the relationship between a continuous dependent variable (home price) and multiple quantitative explanatory variables. B2. Defined Goal The goal of the analysis was to build a predictive model of home prices using principal component analysis (PCA) to reduce multicollinearity, followed by a linear regression model using the retained principal components as predictors. This approach resolves redundancy among correlated housing variables while preserving the majority of the dataset’s variance. C. PCA Justification and Assumptions C1. Why PCA Was Used Principal component analysis was used to transform a set of correlated continuous variables into a smaller number of uncorrelated components. The PCA reduced redundancy, resolved multicollinearity, and improved the reliability of the subsequent linear regression model. The expected outcome was a reduced dataset where the retained components captured the majority of total variance, enabling effective and interpretable model training. C2. Fundamental Assumption of PCA One fundamental assumption of PCA is that the principal components are uncorrelated linear combinations of the original variables. This ensures that each component captures a unique dimension of the dataset’s variance and contributes independently to the regression model. In this analysis, the assumption held: the PCA transformed the original correlated variables into orthogonal (uncorrelated) components. D. Variable Identification and Standardization

To determine how many principal components to retain, a Kaiser test was applied: retain components with eigenvalues > 1. A scree plot was also generated to visually inspect the elbow. In the illustrative dataset, the first 6 components had eigenvalues greater than 1. These 6 components collectively explained a substantial proportion of the total variance (typically >70% in housing datasets). Therefore, PC1 through PC6 were retained for the regression model. Note: The exact number of components retained depends on your specific dataset. The principle is: retain components with eigenvalue > 1 and/or those before the elbow in the scree plot, while ensuring a meaningful cumulative variance explained (e.g., ≥70%). F. Regression Modeling Using Principal Components F1. Critical Rule: Use Principal Components, Not Original Features A major point of confusion has been resolved by recent student guidance and instructor confirmation: you must use the principal components (PCs) in your regression model, not the original features. The PCA transforms the original predictors into new orthogonal variables (PC1, PC2, …), and these PCs become the predictors in the regression. F2. Model Specification The regression model was specified as: HomePrice = 𝛽 0 + 𝛽 1 (PC1) + 𝛽 2 (PC2) + 𝛽 3 (PC3) + 𝛽 4 (PC4) + 𝛽 5 (PC5)

  • 𝛽 6 (PC6) + 𝜀 The dependent variable remains in its original scale. The model was estimated using ordinary least squares (OLS) via statsmodels. F3. Model Evaluation The model was evaluated using:
  • R-squared (R²) and Adjusted R² : Proportion of variance in home price explained by the retained components.
  • F-statistic and p-value : Overall model significance.
  • Coefficient significance (t-tests, p-values) : Which components are statistically significant predictors.
  • Residual diagnostics : Normality (Q-Q plot), homoscedasticity (residuals vs. fitted), and influence (Cook’s distance). Interpretation: Because the predictors are principal components (not original variables), the coefficients represent the effect of a one-unit increase in the component score on home price. The loadings (from the PCA step) are used to interpret what each component represents in terms of the original variables (e.g., PC1 might represent “property size,” PC2 might represent “neighborhood quality”). G. Python Implementation (Complete Code) The following Python code implements the full workflow: data loading, standardization, PCA, component selection, regression on PCs, and model evaluation. python import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from sklearn.preprocessing import StandardScaler from sklearn.decomposition import PCA import statsmodels.api as sm from statsmodels.stats.outliers_influence import variance_inflation_factor

# Note: target is NOT standardized y = df[target] _# ------------------------------------------------------------

4. PCA

------------------------------------------------------------_

pca = PCA() pca.fit(X_scaled_df) # Explained variance and eigenvalues explained_var = pca.explained_variance_ratio_ eigenvalues = pca.explained_variance_ # Scree plot plt.figure(figsize=(8, 5)) plt.plot(range(1, len(eigenvalues) + 1), eigenvalues, 'o-', linewidth=2) plt.axhline(y=1, color='r', linestyle='--', label='Kaiser criterion (eigenvalue = 1)') plt.xlabel('Principal Component') plt.ylabel('Eigenvalue') plt.title('Scree Plot') plt.legend() plt.grid(True)

plt.show() # Kaiser criterion: retain components with eigenvalue > 1 n_components = np.sum(eigenvalues > 1) print(f"Components retained (eigenvalue > 1): {n_components}") print(f"Cumulative variance explained: {explained_var[:n_components].sum():.2%}") _# ------------------------------------------------------------

5. Transform data to principal components

------------------------------------------------------------_

pca_retained = PCA(n_components=n_components) X_pca = pca_retained.fit_transform(X_scaled_df) X_pca_df = pd.DataFrame( X_pca, columns=[f'PC{i+1}' for i in range(n_components)] ) _# ------------------------------------------------------------

6. Regression on Principal Components (OLS)

------------------------------------------------------------_

X_reg = sm.add_constant(X_pca_df) model = sm.OLS(y, X_reg).fit()

pca_retained.components_.T, columns=[f'PC{i+1}' for i in range(n_components)], index=continuous_vars ) print("\nPCA Loadings:") print(loadings.round(3)) _# ------------------------------------------------------------

9. VIF check on PCs (should be ~1, confirming no multicollinearity)

------------------------------------------------------------_

vif_data = pd.DataFrame() vif_data["feature"] = X_pca_df.columns vif_data["VIF"] = [variance_inflation_factor(X_pca_df.values, i) for i in range(X_pca_df.shape[1])] print("\nVIF for Principal Components:") print(vif_data) H. Summary of Findings

  1. PCA resolved multicollinearity among the 13 highly correlated housing variables by transforming them into 6 uncorrelated principal components (eigenvalues > 1).
  2. The retained components explained a substantial portion of variance (typically >70% in housing data), ensuring that the reduced feature set still captures the key drivers of home price.
  1. The regression model using PCs produced a statistically significant overall fit (F-test p < 0.05). The Adjusted R² indicates the proportion of variance in home price explained by the components.
  2. Loadings were used to interpret components : For example, PC1 may be dominated by SquareFootage and NumBedrooms (a “size” component), while PC2 may be dominated by CrimeRate and SchoolRating (a “neighborhood quality” component). This interpretation allows the analyst to explain which underlying dimensions drive home prices.
  3. VIF values for the PCs were approximately 1 , confirming that the multicollinearity problem was fully resolved. I. Conclusion This analysis successfully applied PCA to reduce a set of 13 correlated housing variables into 6 uncorrelated principal components, which were then used as predictors in a linear regression model to predict home prices. The workflow followed the rubric requirements: only continuous independent variables were standardized , the dependent variable remained in its original scale , and principal components—not original features—were used in the regression. The model provides a defensible, multicollinearity-free approach to understanding the drivers of housing prices, and the use of loadings allows for meaningful interpretation of what each component represents in real-world terms.