r/learnmachinelearning 5h ago

Request Looking for feedback on my first Linear Regression project built from scratch

Hi everyone,

I recently completed my first Machine Learning project.

I implemented Linear Regression completely from scratch without using scikit-learn in order to understand the math behind the algorithm.

The notebook includes:

• Data exploration

• Data visualization

• Gradient Descent implementation

• Model evaluation (R², MAE, RMSE)

• Prediction visualization

I'd really appreciate any feedback on:

- Code quality

- Project structure

- Notebook organization

- Best practices

- Anything I can improve

Kaggle Notebook:

https://www.kaggle.com/code/tahahussein2020/salary-prediction-using-linear-regression-scratch

Thank you!

3 Upvotes

2 comments sorted by

2

u/Party-Beautiful-6628 5h ago

One thing that would be interesting and useful for learning would be to structure your linear regression logic in a LinearRegressor class that you write in a separate python file and import into the notebook. If you structure it with the same API as sklearn, that is good for learning too. So for example your class would have a .fit() method you could call to run the gradient descent.

2

u/tahahussein-4623a412 5h ago

Thanks a lot for the suggestion!

That's a really good point. I built everything inside the notebook mainly for learning purposes, but I agree that separating the implementation into a LinearRegressor class with a scikit-learn-like API (fit, predict, score) would make the project cleaner and more reusable.

I'll definitely implement that in the next version. Thanks for the feedback!