Machine Learning for Regression

Prepare car-price data, train linear regression models, and evaluate them with RMSE.

17 lessons · homework closed Oct 5, 2026

Lessons

  1. Car price prediction project

    Introduce the car price project, its Kaggle dataset, the MSRP target, and the steps of the project plan.

    6 min
  2. Data preparation

    Load the Kaggle car dataset with pandas and normalize column names and string values to lowercase with underscores.

    9 min
  3. Exploratory data analysis

    Explore each column, log-transform the long-tailed price distribution, and count missing values.

    19 min
  4. Setting up the validation framework

    Split the car data into shuffled 60/20/20 train, validation, and test sets using plain pandas and NumPy.

    18 min
  5. Linear regression

    Implement a linear regression prediction for one car as a weighted sum of its features plus a bias.

    19 min
  6. Linear regression: vector form

    Rewrite linear regression as a dot product and then a matrix-vector multiplication that predicts all cars at once.

    14 min
  7. Training linear regression: Normal equation

    Derive the normal equation for linear regression weights and implement it as a train_linear_regression function.

    16 min
  8. Baseline model for car price prediction project

    Train a baseline model on five numerical features, filling missing values with zeros, and compare its predictions with actual prices.

    10 min
  9. Root Mean Squared Error (RMSE)

    Explain RMSE with a worked example, implement it in NumPy, and apply it to the baseline model.

    8 min
  10. Computing RMSE on validation data

    Build a prepare_X helper and compute RMSE on the validation set instead of the training set.

    4 min
  11. Feature engineering

    Create an age feature from the year column, copy the dataframe in prepare_X, and check how it lowers validation RMSE.

    5 min
  12. Categorical variables

    Encode doors, make, and other categories as binary columns, and observe that adding them all worsens validation RMSE.

    16 min
  13. Regularization

    Explain why the normal equation breaks on duplicate features and add a diagonal term to keep weights stable.

    12 min
  14. Tuning the model

    Tune the regularization parameter on the validation set, then train the model with the chosen value.

    3 min
  15. Using the model

    Train the final model on train and validation data, check its test RMSE, and predict the price of one car.

    10 min
  16. Car price prediction project summary

    Recap the car price project, covering data preparation, linear regression, RMSE, feature engineering, and regularization.

    8 min
  17. Explore more

    Suggest optional practice ideas, including testing 10 features and trying other regression datasets.

Homework

Recordings, code and notes

Optional analytics

Optional analytics are off unless you allow them. Your choice does not affect access to DataTalks.Club, Slack, events, or courses.

Current choice: not chosen.

Privacy Policy

If you allow analytics, self-hosted Umami counts anonymous public pageviews without analytics cookies. Private account and learning pages are excluded. Read the Privacy Policy for the complete data boundary.