Supervised Learning
Supervised Learning
#Find the slope of the graph where the lower point on the line is represented as (−3, −2) and the
higher point on the line is represented as (2, 2).
Types of slopes
1. positive slope
Linear positive slope
The corresponding value of ‘a’ calculated using the above value of ‘b’ is
slope = 1.89 implies that the average value of the external examination marks increases by 1.89 for
each additional 1 mark in the internal examination.
Intercept=19.04 implies that indicates that 19.05 is the portion of the external examination marks
not explained by the internal examination marks. (Even if internal marks were zero (hypothetically),
the model predicts ~19 marks in external.)
Note:
Measures the total error between actual values (yi) and predicted values
R-squared (R²):
where,
where:
o Value ranges: 1 : perfect fit, 0 : model explains nothing, < 0: worse than mean
prediction
import pandas as pd
import numpy as np
%matplotlib inline
dataset = pd.read_csv('student_scores.csv')
[Link]
[Link]()
[Link](‘Internal vs External’)
[Link](’Internal’)
[Link](‘External’)
[Link]()
X = [Link][:, :-1].values
y = [Link][:, 1].values
print(X)
regressor = LinearRegression()
[Link](X_train, y_train)
y_pred = [Link](X_test)
print(comparison)
import pandas as pd
import numpy as np
%matplotlib inline
# Load dataset
dataset = pd.read_csv('student_scores.csv')
[Link]
[Link]()
# Visualize data
[Link](‘Internal vs External’)
[Link](’Internal’)
[Link](‘External’)
[Link]()
X = [Link][:, :-1].values
y = [Link][:, 1].values
print(X)
# Train-test split
[Link](X_train, y_train)
y_pred = [Link](X_test)
print(comparison)
custom_pred = [Link](6.5)
# Model accuracy
r2 = r2_score(y_test, y_pred)
print(f"SSE : {sse:.2f}")
print(f"R² : {r2:.2f}")
[Link](‘Internal Marks’)
[Link](‘External Marks’)
[Link]()
[Link]()