Linear Regression Exercise

Programming for Data Science is a subject we’ve designed to explore the various programming components of data science.
Author

Juma Shafara

Published

August 29, 2024

Keywords

data science, data analysis, programming, dataidea

Photo by DATAIDEA

Week 2: Linear Regression (3 Questions)

1. Linear Regression 1 Dimension

  • Exercise: Implement a simple linear regression model to fit a line to 1D data points generated as (x, y) = (x, 3x + 7 + noise). Visualize the data and the fitted line.

2. Linear Regression with 1 Parameter

  • Exercise: Create a linear regression model with a single parameter. Train the model on a dataset with a known linear relationship, and evaluate the model’s performance by plotting the predicted vs. actual values.

3. Training Slope and Bias

  • Exercise: Implement a linear regression model from scratch to learn the slope and bias for the dataset (x, y) = (x, 4x + 10 + noise). Compare the learned parameters with the true values.

What’s on your mind? Put it in the comments!

Back to top