-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlasso_predictor.py
46 lines (31 loc) · 977 Bytes
/
lasso_predictor.py
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
36
37
38
39
40
41
42
43
44
45
# coding: utf-8
# In[7]:
import numpy as np
import pandas as pd
import pickle
import sys
import sklearn as sl
from sklearn.externals import joblib
# In[8]:
def main():
lasso = joblib.load('model.pkl')
test = pd.read_csv(sys.argv[1],index_col=False)
test["jump"] = np.log(test["jump"])
numerical_data = ['age', 'height', 'weight', 'sleep']
test[numerical_data] = np.log1p(test[numerical_data])
test = pd.get_dummies(test, columns=['exercise', 'competitive', 'gender', 'injured', 'color', 'race'])
X_test = test.drop('jump', axis=1)
y = test.jump
lasso.predict(X_test)
print('Prediction Accuracy:')
print(lasso.score(X_test,y))
res = lasso.predict(X_test)
print('Predicted Results:')
print(np.exp(res))
# In[ ]:
if __name__ == '__main__':
if len(sys.argv) <= 1:
print('Please enter a file name for the test case')
print('Usage: python lasso_predictor test.csv')
else:
main()