-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
quadratic_discriminant_analysis.sg
32 lines (26 loc) · 1.11 KB
/
quadratic_discriminant_analysis.sg
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
CSVFile f_feats_train("../../data/classifier_4class_2d_linear_features_train.dat")
CSVFile f_feats_test("../../data/classifier_4class_2d_linear_features_test.dat")
CSVFile f_labels_train("../../data/classifier_4class_2d_linear_labels_train.dat")
CSVFile f_labels_test("../../data/classifier_4class_2d_linear_labels_test.dat")
#![create_features]
Features features_train = features(f_feats_train)
Features features_test = features(f_feats_test)
Labels labels_train = labels(f_labels_train)
Labels labels_test = labels(f_labels_test)
#![create_features]
#![create_instance]
Machine qda = machine("QDA", labels=labels_train, m_tolerance=0.0001, m_store_covs=True)
#![create_instance]
#![train_and_apply]
qda.train(features_train)
MulticlassLabels labels_predict = qda.apply_multiclass(features_test)
#![train_and_apply]
#![extract_mean_and_cov]
RealMatrix m = qda.get_real_matrix("m_means")
#![extract_mean_and_cov]
#![evaluate_accuracy]
MulticlassAccuracy eval()
real accuracy = eval.evaluate(labels_predict, labels_test)
#![evaluate_accuracy]
# additional integration testing variables
RealVector output = labels_predict.get_labels()