forked from shogun-toolbox/shogun
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add svmlin & svmsgd meta example (shogun-toolbox#4404)
* Add svmlin & svmsgd meta example * Update integration data
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
Submodule data
updated
3 files
+2 −2 | testsuite/meta/binary/svmlin.dat | |
+2 −2 | testsuite/meta/binary/svmsgd.dat | |
+2 −2 | testsuite/meta/evaluation/cross_validation_pipeline.dat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
File f_feats_train = csv_file("../../data/classifier_binary_2d_linear_features_train.dat") | ||
File f_feats_test = csv_file("../../data/classifier_binary_2d_linear_features_test.dat") | ||
File f_labels_train = csv_file("../../data/classifier_binary_2d_linear_labels_train.dat") | ||
File f_labels_test = csv_file("../../data/classifier_binary_2d_linear_labels_test.dat") | ||
|
||
Features feats_train = features(f_feats_train) | ||
Features feats_test = features(f_feats_test) | ||
Labels labels_train = labels(f_labels_train) | ||
Labels labels_test = labels(f_labels_test) | ||
|
||
Machine svm = machine("SVMLin", C1=0.9, C2=0.9, epsilon=0.00001, labels=labels_train) | ||
svm.train(feats_train) | ||
|
||
RealVector weights = svm.get_real_vector("w") | ||
real bias = svm.get_real("bias") | ||
|
||
Labels labels_predict = svm.apply(feats_test) | ||
Evaluation eval = evaluation("AccuracyMeasure") | ||
real accuracy = eval.evaluate(labels_predict, labels_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
File f_feats_train = csv_file("../../data/classifier_binary_2d_linear_features_train.dat") | ||
File f_feats_test = csv_file("../../data/classifier_binary_2d_linear_features_test.dat") | ||
File f_labels_train = csv_file("../../data/classifier_binary_2d_linear_labels_train.dat") | ||
File f_labels_test = csv_file("../../data/classifier_binary_2d_linear_labels_test.dat") | ||
|
||
Features feats_train = features(f_feats_train) | ||
Features feats_test = features(f_feats_test) | ||
Labels labels_train = labels(f_labels_train) | ||
Labels labels_test = labels(f_labels_test) | ||
|
||
Machine svm = machine("SVMSGD", C1=0.9, C2=0.9, epochs=5, labels=labels_train) | ||
svm.train(feats_train) | ||
|
||
RealVector weights = svm.get_real_vector("w") | ||
real bias = svm.get_real("bias") | ||
|
||
Labels labels_predict = svm.apply(feats_test) | ||
Evaluation eval = evaluation("AccuracyMeasure") | ||
real accuracy = eval.evaluate(labels_predict, labels_test) |