forked from UTSAVS26/PyVerse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregression.py
More file actions
28 lines (20 loc) · 711 Bytes
/
Copy pathregression.py
File metadata and controls
28 lines (20 loc) · 711 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
'''
Multi-linear regression.
'''
# -------------------- Imports -------------------- #
from sklearn import linear_model as lm
import math
from poker_hand_prediction import *
# -------------------- Model -------------------- #
model = lm.LinearRegression()
# FIT (i.e train)
trainedModel = model.fit(train_x, train_y)
# TEST (i.e predict)
predictions = model.predict(test_x)
# Errors
avgError = sum([math.fabs(x-y) for x, y in zip(predictions, test_y)]) / len(predictions)
print("Average error :", avgError)
rmsError = sum([(x-y)**2 for x, y in zip(predictions, test_y)]) / len(predictions)
rmsError = math.sqrt(rmsError)
print("RMSE :", rmsError)
print("Model R2 score :", model.score(train_x, train_y))