0% found this document useful (0 votes)
2 views

AI LAB PROGRAMS MTECH

Linear Regression is a statistical method for predicting a continuous target variable using one or more independent variables, modeled by the equation y=mx+c. The document outlines the steps to implement linear regression, including understanding the dataset, calculating coefficients, and predicting values, using a sample dataset of hours studied versus scores. It also provides a brief overview of Python code implementation for the regression analysis.

Uploaded by

aadhya L R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

AI LAB PROGRAMS MTECH

Linear Regression is a statistical method for predicting a continuous target variable using one or more independent variables, modeled by the equation y=mx+c. The document outlines the steps to implement linear regression, including understanding the dataset, calculating coefficients, and predicting values, using a sample dataset of hours studied versus scores. It also provides a brief overview of Python code implementation for the regression analysis.

Uploaded by

aadhya L R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Linear Regression

Linear Regression is a statistical method used to predict the value of a continuous target
variable based on one or more independent variables. A simple linear regression predicts the
target variable using one independent variable.
The relationship is modeled as:

y=mx+c
Where:
• y is the target variable (output)
• x is the input variable (feature)
• m is the slope (coefficient)
• c is the y-intercept
The objective is to find the values of mmm and ccc that minimize the error (difference)
between the predicted values (y^) and actual values.

Sample Dataset:
We will use a simple dataset for predicting a student's score based on the number of hours
studied:
Hours Studied Score
1 50
2 55
3 65
4 70
5 75
6 85
7 95

Steps to Implement Linear Regression:


1. Understand the Dataset: We use "Hours Studied" as the input variable (x) and
"Score" as the target variable (y).
2. Calculate the Coefficients: Using mathematical formulas for m and c:
Where:
• xˉ is the mean of x.
• yˉis the mean of y.
Predict Values: Use y=mx+c to predict scores.

Python Code Implementation:


Explanation of the Code:
1. Input Data: The hours_studied and scores arrays represent the dataset.
2. Calculate Mean: Compute the average of the input (x) and target (y).
3. Calculate Slope and Intercept: Using the formulas for mmm and ccc.
4. Predict: Use the equation y=mx+c to generate predictions.
5. Visualize: The scatter plot shows actual data points, and the red line represents the
regression line.

Output:

You might also like