OpenEDG PCAD study materials
OpenEDG PCAD study resources

OpenEDG PCAD: Foundational Machine Learning: Regression Analysis and Model Evaluation

OpenEDG PCAD · Work through your exam, one topic at a time.

All guide sections

Foundational Machine Learning: Regression Analysis and Model Evaluation

What this domain tests

Foundational regression and model evaluation: fitting a linear model, separating features and target, evaluating on held-out data, and interpreting error metrics. The exam emphasizes correct workflow over exotic algorithms.

Core rules

  • Split before you fit: train_test_split(X, y, test_size=0.2, random_state=42). Fit preprocessing on the training set only, then apply it to test data.
  • LinearRegression().fit(X_train, y_train) learns coefficients and an intercept; predictions come from .predict(X_test).
  • Metrics: MAE and RMSE are in target units; RMSE penalizes large errors more. R-squared is the proportion of variance explained and can be negative on test data.
  • Evaluate on the test set, and use cross-validation for a more stable estimate.
  • Check assumptions and residuals; a high R-squared does not prove causation.

Worked example

You predict house price from size and age. After an 80/20 split, you fit on train, predict on test, and compute rmse = mean_squared_error(y_test, pred, squared=False). If RMSE is 40,000 and the mean price is 300,000, the typical error is about 13% of the mean. You compare against a baseline that always predicts the training mean; if the model does not beat it, the features add little. Reasoning: RMSE is interpretable in dollars, and the baseline prevents overstating a model that merely learns the average.

Traps that cost marks

  • Scaling or imputing before the split, which leaks test information.
  • Reporting training R-squared as model performance.
  • Using accuracy for a regression target.
  • Forgetting that mean_squared_error(..., squared=False) returns RMSE in newer scikit-learn.
  • Extrapolating far beyond the feature range seen in training.