-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
117 lines (75 loc) · 2.89 KB
/
main.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import auxiliary_functions as utils
import numpy as np
G = utils.G
##
## Naïve Bayes Model
##
## Sequential Holdout 80/20 split
data,labels,individuals = utils.load_dataset()
data_train = data[:,:,0:int(2045*0.8)] #1636 of instances (80%) to train model
data_test = data[:,:,int(2045*0.8):2045] #409 of instances (20%) to evaluate model
labels_train = labels[0:int(2045*0.8)]
labels_test = labels[int(2045*0.8):2045]
M = utils.learn_model(data_train,labels_train)
probs = utils.classify_instances(data_test, M)
A = utils.Accuracy(probs, labels_test)
print(A)
##
## Linear Gaussian Model
##
## Sequential Holdout 80/20 split
data,labels,individuals = utils.load_dataset()
data_train = data[:,:,0:int(2045*0.8)] #1636 of instances (80%) to train model
data_test = data[:,:,int(2045*0.8):2045] #409 of instances (20%) to evaluate model
labels_train = labels[0:int(2045*0.8)]
labels_test = labels[int(2045*0.8):2045]
M = utils.learn_model(data_train,labels_train,G)
probs = utils.classify_instances(data_test, M)
A = utils.Accuracy(probs, labels_test)
print(A)
##
## Naïve Bayes Model
##
## Random Holdout 80/20 split
data,labels,individuals = utils.load_dataset()
shuffledIndex = utils.RandomVect(2045,0,2044)
data_train = data[:,:,shuffledIndex[0:int(2045*0.8)]] #1636 of instances (80%) to train model
data_test = data[:,:,shuffledIndex[int(2045*0.8):2045]] #409 of instances (20%) to evaluate model
labels_train = labels[shuffledIndex[0:int(2045*0.8)]]
labels_test = labels[shuffledIndex[int(2045*0.8):2045]]
M = utils.learn_model(data_train,labels_train)
probs = utils.classify_instances(data_test, M)
A = utils.Accuracy(probs, labels_test)
print(A)
##
## Linear Gaussian Model
##
## Random Holdout 80/20 split
data,labels,individuals = utils.load_dataset()
shuffledIndex = utils.RandomVect(2045,0,2044)
data_train = data[:,:,shuffledIndex[0:int(2045*0.8)]] #1636 of instances (80%) to train model
data_test = data[:,:,shuffledIndex[int(2045*0.8):2045]] #409 of instances (20%) to evaluate model
labels_train = labels[shuffledIndex[0:int(2045*0.8)]]
labels_test = labels[shuffledIndex[int(2045*0.8):2045]]
M = utils.learn_model(data_train,labels_train, G)
probs = utils.classify_instances(data_test, M)
A = utils.Accuracy(probs, labels_test)
print(A)
##
## Naïve Bayes Model
##
## Stratified Crossvalidation 4Fold
data,labels,individuals = utils.load_dataset()
[M, A, measures] = utils.GetPerformance(data, np.concatenate(labels), 4)
print("Accuracies = " + str(measures))
print("Best Accuracy = " + str(A))
print("Average Accuracy = " + str(np.average(measures)))
##
## Linear Gaussian Model
##
## Stratified Crossvalidation 4Fold
data,labels,individuals = utils.load_dataset()
[M, A, measures] = utils.GetPerformance(data, np.concatenate(labels), 4, G)
print("Accuracies = " + str(measures))
print("Best Accuracy = " + str(A))
print("Average Accuracy = " + str(np.average(measures)))