-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCapstone.py
More file actions
121 lines (76 loc) · 1.99 KB
/
Capstone.py
File metadata and controls
121 lines (76 loc) · 1.99 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/env python´
# coding: utf-8
# In[17]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# import dask.dataframe as dd
import time
start_time = time.time()
df = pd.read_csv('/Users/vineethdasary/Documents/flask-app/SampleInstPerf.csv')
print(df)
# In[18]:
df.drop(columns = ['SUBJECT', 'CATALOG_NBR'], inplace = True, axis = 1)
print(df)
# In[19]:
# Importing module and initializing setup
from pycaret.regression import *
reg1 = setup(data = df, target = 'Average_Point', train_size = 0.6)
# In[20]:
# comparing all models
allmodels = compare_models(n_select=5)
# In[ ]:
cbr = create_model('llar')
# In[ ]:
print(cbr)
# In[ ]:
# tune model
tcbr = tune_model(cbr)
# In[ ]:
print(tcbr)
# In[ ]:
# ensembling decision tree model (boosting)
btcbr = ensemble_model(tcbr, method = 'Bagging')
# In[ ]:
blender = blend_models(estimator_list=[btcbr])
print(blender)
# In[ ]:
print('belnder plot\n')
plot_model(estimator=blender, plot='residuals')
plt.show()
# In[ ]:
plot_model(estimator=blender, plot='error')
plt.show()
# In[ ]:
plot_model(estimator=blender, plot='cooks')
plt.show()
# In[ ]:
plot_model(estimator=blender, plot='learning')
plt.show()
# In[ ]:
plot_model(estimator=blender, plot='manifold')
plt.show()
# In[ ]:
final_llar_model = finalize_model(blender)
# print('intrpret model\n')
# interpret = interpret_model(blender)
# In[ ]:
save_model(final_llar_model, 'llar_model')
# In[ ]:
print('predict model on test data\n')
# In[ ]:
predtest = predict_model(blender)
print('prediction results\n')
print(predtest)
# In[ ]:
data_unseen = pd.read_csv('/Users/vineethdasary/Documents//Capstone/SampleInstPerf.csv')
# generate predictions on unseen data
predictions = predict_model(final_llar_model, data = data_unseen)
print('predictions on unseen data\n')
print(predictions)
df = pd.DataFrame(predictions)
df.to_csv('/Users/vineethdasary/Documents/Capstone/SampleInstPerf1.csv')
# %%
print("--- %s seconds ---" % (time.time() - start_time))
# %%
# %%