-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
multiclass_ecoc_random.sg
40 lines (32 loc) · 1.24 KB
/
multiclass_ecoc_random.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
35
36
37
38
39
40
set_global_seed(1)
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_classifier]
LibLinear classifier()
#![create_classifier]
#![choose_strategy]
ECOCRandomDenseEncoder encoder()
ECOCHDDecoder decoder()
ECOCStrategy rnd_dense_strategy(encoder, decoder)
#![choose_strategy]
#![create_instance]
LinearMulticlassMachine mc_classifier(rnd_dense_strategy, features_train, classifier, labels_train)
#![create_instance]
#![train_and_apply]
mc_classifier.train()
MulticlassLabels labels_predict = mc_classifier.apply_multiclass(features_test)
#![train_and_apply]
#![evaluate_accuracy]
MulticlassAccuracy eval()
real accuracy = eval.evaluate(labels_predict, labels_test)
#![evaluate_accuracy]
# integration testing variables
RealVector output = labels_predict.get_labels()