Professional Documents
Culture Documents
Multivariate Regression
Multivariate Regression
Multivariate Regression
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_)