Skip to content

sivaunknown/Simple_Linear_Regression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 

Repository files navigation

Simple_Linear_Regression

A Mathematical implementation of Simple_Linear_Regression using Python

Here's a simple and clean explanation you can use in your README.md file for your code:


๐Ÿ“Š Simple Linear Regression (Salary Prediction)

This Python script implements Simple Linear Regression from scratch using NumPy, Pandas, and Matplotlib.

It predicts the salary of an employee based on their years of experience.


โœ… Features

  • ๐Ÿ“ฅ Reads salary data from a CSV file

  • ๐Ÿ“ˆ Calculates regression line using the least squares method

  • ๐Ÿ“ Predicts salary for a custom input value

  • ๐Ÿ“Š Plots:

    • Data points (scatter plot)
    • Best-fit regression line
    • Predicted point with dashed lines to x/y axes
  • ๐Ÿ“ Displays model accuracy using Rยฒ Score


๐Ÿ“ Data Format

The dataset (Salary_dataset.csv) should contain two columns:

YearsExperience Salary
1.2 39344.0
2.3 39892.0
... ...

๐Ÿงฎ How It Works

  1. Load Data Loads the dataset and splits it into independent variable x (Years of Experience) and dependent variable y (Salary).

  2. Calculate Parameters

    • slope is calculated using the least squares formula
    • y_intercept is computed using mean values
  3. Predict Values Uses the formula: y = mx + c

    where:

    • m = slope
    • c = y-intercept
  4. Plot Results

    • Plots original data and regression line
    • Highlights a predicted salary for a given experience value with a green X and dashed guide lines
  5. Evaluate Accuracy

    • Calculates Rยฒ Score (model accuracy)

๐Ÿ“ท Example Output

  • Red line โ†’ Regression line
  • Blue dots โ†’ Actual data points
  • Green X โ†’ Predicted point (with dashed lines to x and y axes) Let me know if you want me to generate a complete README.md file or also include setup instructions like required libraries.

About

A Mathematical implementation of Simple_Linear_Regression using Python

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages