-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.py
96 lines (75 loc) · 4 KB
/
demo.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
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
import sys
sys.path.insert(1, 'Utils/')
sys.path.insert(1, 'Processes/')
from dataProcessor import normalize
from regressorsUtils import *
from predictionUtils import *
from dataProcessingUtils import split_data
def etestRFR(itterations=100):
data, scalers = normalize('Datasets/house_data_2022-01-26.csv', scaled_list = ['price','year','loc', 'type'],encoding_type='label')
X_train, X_test, y_train, y_test = split_data(data, 0.2)
testRFR(X_train, X_test, y_train, y_test, its=itterations)
def ctestSVR(itterations=100):
data, scalers = normalize('Datasets/house_data_2022-01-26.csv', scaled_list = ['price','year','loc', 'type'],encoding_type='label')
X_train, X_test, y_train, y_test = split_data(data, 0.2)
testSVR(X_train, X_test, y_train, y_test, its=itterations)
def ntestBRR(itterations=100):
data, scalers = normalize('Datasets/house_data_2022-01-26.csv', scaled_list = ['price','year','loc', 'type'],encoding_type='label')
X_train, X_test, y_train, y_test = split_data(data, 0.2)
testBRR(X_train, X_test, y_train, y_test, its=itterations)
def ktestKNN(itterations=20):
data, scalers = normalize('Datasets/house_data_2022-01-26.csv', scaled_list = ['price','year','loc', 'type'],encoding_type='label')
X_train, X_test, y_train, y_test = split_data(data, 0.2)
testKNN(X_train, X_test, y_train, y_test, its=itterations)
def main(encoding_type='one_hot', show_plots=False, scaling='min_max'):
if encoding_type == 'label':
print('Encoding Type is set to Label')
data, scalers = normalize('Datasets/house_data_2022-01-26.csv', scaled_list = ['price','year','loc', 'type'],encoding_type='label')
elif scaling == 'standard':
print('Results with Standard Scaling')
data, scalers = normalize('Datasets/house_data_2022-01-26.csv', scaling_method = 'standard')
elif scaling == 'log':
print('Results with Log Transformation')
data, scalers = normalize('Datasets/house_data_2022-01-26.csv', scaling_method = 'log')
else:
print('Encoding Type is set to one_hot and Scaling to min_max')
data, scalers = normalize('Datasets/house_data_2022-01-26.csv')
X_train, X_test, y_train, y_test = split_data(data, 0.2)
bayesian_clf, bayesian_mse, bayesian_rs, bayesian_rmse, bayesian_plt = runBayesianRidge(X_train, X_test, y_train, y_test)
print_model_results('Bayesian Ridge Regressor', bayesian_mse, bayesian_rs, bayesian_rmse)
svm_rgs, svm_mse, svm_rs,svm_rmse, svm_plt = runSupportVector(X_train, X_test, y_train, y_test)
print_model_results('Support Vector Regressor', svm_mse, svm_rs, svm_rmse)
rf_rgs, rf_mse, rf_rs, rf_rmse, rf_plt = runRandomForest(X_train, X_test, y_train, y_test)
print_model_results('Random Forest Regressor', rf_mse, rf_rs, rf_rmse)
kn_rgs, kn_mse, kn_rs, kn_rmse, kn_plt = runKNeighbors(X_train, X_test, y_train, y_test)
print_model_results('K-Neighbors Regressor', kn_mse, kn_rs, kn_rmse)
lr_rgs, lr_mse, lr_rs, lr_rmse, lr_plt = runLinearRegression(X_train, X_test, y_train, y_test)
print_model_results('Linear Regressor', lr_mse, lr_rs, lr_rmse)
if show_plots:
bayesian_plt.show()
svm_plt.show()
rf_plt.show()
kn_plt.show()
lr_plt.show()
if __name__ == "__main__":
try:
if sys.argv[1] == 'default':
main()
elif sys.argv[1] == 'scaling' and sys.argv[2] == 'log':
main(scaling='log')
elif sys.argv[1] == 'encoding' and sys.argv[2] == 'lablel':
main(encoding_type='label')
elif sys.argv[1] == 'scaling' and sys.argv[2] == 'standard':
main(scaling='standard')
elif sys.argv[1] == 'test' and sys.argv[2] == 'knn':
ktestKNN()
elif sys.argv[1] == 'test' and sys.argv[2] == 'brr':
ntestBRR()
elif sys.argv[1] == 'test' and sys.argv[2] == 'svr':
ctestSVR()
elif sys.argv[1] == 'test' and sys.argv[2] == 'rfr':
etestRFR()
else:
main()
except:
main()