Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

Linear Regression

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:

  1. relative path to their CSV file
  2. 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:

  1. pandas
  2. numpy
  3. matplotlib

References

  1. Closed form solution for linear regression
  2. Simple Linear Regression: A Practical Implementation in Python
  3. Argparse documentation

Usage

  • 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

help_output

  • 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

demo2 output_2d

  • To provide your own dataset (as a CSV file):
    python linear_regression.py <PATH_TO_CSV_FILE> <TARGET_NAME>

demo3 output_3d

  • Visualization can also be skipped: demo4