This project provides a simple implementation of linear regression using the gradient descent algorithm in Python.
train_model.pytakes a CSV file as input and trains the model using the gradient descent algorithm. After that the model is saved.predict.pyretrieves the trained model and makes predictions based on the given features.
After running train_model.py, performance metrics such as R-squared, Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), and Mean Squared Error (MSE) will be calculated.
git clone git@github.com:tsannie/linear_regression.git && cd linear_regression
pip install -r requirements.txtpython train_model.py [-h] [-f 'file_name'.csv] [-t 'column_name']
[-n N_ITERS] [-r LEARNING_RATE] [-g]
optional arguments:
-h, --help show this help message and exit
-f 'file_name'.csv, --file 'file_name'.csv
File name csv (default: data.csv)
-t 'column_name', --target 'column_name'
Target column (default: price)
-n N_ITERS, --n_iters N_ITERS
Number of iterations (default: 100)
-r LEARNING_RATE, --learning_rate LEARNING_RATE
Learning rate (alpha) (default: 1)
-g, --graph Show graph
python predict.py
