-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_preprocessing.py
More file actions
35 lines (26 loc) · 1020 Bytes
/
Copy pathdata_preprocessing.py
File metadata and controls
35 lines (26 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# prediction_model.py
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_absolute_error
import data_preprocessing
# Load preprocessed data
df = data_preprocessing.generate_data()
# Define features and labels
X = df[['age', 'previous_score', 'attendance_rate', 'homework_completion']]
y = df['quiz_score']
# Split data into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Train a linear regression model
model = LinearRegression()
model.fit(X_train, y_train)
# Predict quiz scores
y_pred = model.predict(X_test)
# Evaluate model performance
mae = mean_absolute_error(y_test, y_pred)
print(f"Mean Absolute Error: {mae}")
# Display predictions and actual values
predicted_vs_actual = pd.DataFrame({'Predicted': y_pred, 'Actual': y_test})
print(predicted_vs_actual.head())
def generate_data():
return None