-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
linear_discriminant_analysis.sg
34 lines (28 loc) · 1.11 KB
/
linear_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
33
34
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]
RealFeatures features_train(f_feats_train)
RealFeatures features_test(f_feats_test)
MulticlassLabels labels_train(f_labels_train)
MulticlassLabels labels_test(f_labels_test)
#![create_features]
#![create_instance]
MCLDA mc_lda(features_train, labels_train, 0.0001, True)
#![create_instance]
#![train_and_apply]
mc_lda.train()
MulticlassLabels labels_predict = mc_lda.apply_multiclass(features_test)
#![train_and_apply]
#![extract_mean_and_cov]
int classlabel = 1
RealVector m = mc_lda.get_mean(classlabel)
RealMatrix c = mc_lda.get_cov()
#![extract_mean_and_cov]
#![evaluate_accuracy]
MulticlassAccuracy evals()
real accuracy = evals.evaluate(labels_predict, labels_test)
#![evaluate_accuracy]
# additional integration testing variables
RealVector output = labels_predict.get_labels()