Multivariate Regression

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

import numpy as np

import pandas as pd
from sklearn.linear_model import LinearRegression

data = {
'Hours_of_Study': [2, 3, 5, 1, 4, 2, 6, 5, 7, 8],
'Hours_of_Sleep': [7, 6, 5, 8, 6, 7, 4, 5, 3, 2],
'Exam_Score': [85, 90, 78, 92, 88, 85, 75, 80, 70, 65]
}

df = pd.DataFrame(data)

X = df[['Hours_of_Study', 'Hours_of_Sleep']]
Y = df['Exam_Score']

model = LinearRegression()
model.fit(X, Y)

print("Coefficients:", model.coef_)
print("Intercept:", model.intercept_)

new_data = np.array([[6, 6]])


predicted_score = model.predict(new_data)

print("Predicted Exam Score:", predicted_score[0])

You might also like