DATE:
EXPRIMENT-5
Linear regression
AIM: To implement python program by using Linear Regression .
SOURCE CODE:
import pandas as pd
from sklearn.linear_model import LinearRegression
# Load the dataset
data = pd.read_csv('student_scores.csv')
# Prepare the data
X = data[['projects']] # Feature
y = data['score'] # Target
# Train the Linear Regression Model
model = LinearRegression().fit(X, y)
# Print the linear regression equation
print(f"Score = {model.coef_[0]:.2f} * Projects + {model.intercept_:.2f}")
# Make Predictions and display them
data['Predicted Score'] = model.predict(X)
print("\nPredicted Scores:")
print(data[['student', 'projects', 'score', 'Predicted Score']])
DATASET DESCRIPTION:
This dataset contains information about the performance of five students in relation to the number of
projects they have completed. It includes the following columns:
student: The name of the student.
projects: The total number of projects each student has completed.
score: The performance score achieved by each student, which reflects their academic success.
The dataset can be utilized to analyze how the number of projects completed influences student
performance, providing insights into the correlation between active participation in projects and
academic outcomes.
Data give below:
student project score
Lokeswar 3 75
Ratnam 2 60
Vignesh 5 88
Rajeev 4 82
Ganesh 3 70
. Save data set by ‘student_scores.csv’.
OUTPUT:
Score = 6.50 * Projects + 54.00
Predicted Score:
student project score Predicted score
Lokeswar 3 75 73.00
Ratnam 2 60 60.50
Vignesh 5 88 87.00
Rajeev 4 82 83.50
Ganesh 3 70 73.00
RESULT:
Linear Regression model is developed by using Student and Score data set is successfully executed.