This script implements multiple linear regression using a closed-form solution to find optimal fit. User can analyze a dataset of their choice by providing:
- relative path to their CSV file
- name of the target column
If these are not provided, a demo dataset included with the script is used. For datasets with two or less independent variables, there is an option to visualize the fit of the regression model.
Python version: 3.10.8
External packages:
- pandas
- numpy
- matplotlib
References
- Closed form solution for linear regression
- Simple Linear Regression: A Practical Implementation in Python
- Argparse documentation
- Create a virtual environment and install the dependencies specified in requirements.txt
- Navigate to the Linear_Regression folder in the terminal.
- Understand the usage of the script:
python linear_regression.py -h- For the demo version, run the script without any arguments: (Demo dataset is self-generated using the random module from numpy package)
python linear_regression.py- To provide your own dataset (as a CSV file):
python linear_regression.py <PATH_TO_CSV_FILE> <TARGET_NAME>




