Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shareboost cookbook with integration test data
- Loading branch information
Showing
6 changed files
with
71 additions
and
40 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
doc/cookbook/source/examples/multiclass_classifier/shareboost.rst
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,33 @@ | ||
========== | ||
ShareBoost | ||
========== | ||
|
||
ShareBoost algorithm learns a multiclass predictor from a subset of shared features of the samples with forward greedy selection approach. | ||
|
||
See :cite:`shalev2011shareboost` for a detailed introduction. | ||
|
||
------- | ||
Example | ||
------- | ||
Imagine we have files with training and test data. We create CDenseFeatures (here 64 bit floats aka RealFeatures) and :sgclass:`CMulticlassLabels` as | ||
|
||
.. sgexample:: shareboost.sg:create_features | ||
|
||
We create an instance of the :sgclass:`CShareBoost` classifier by setting the number of features expected to be used for learning. | ||
|
||
.. sgexample:: shareboost.sg:create_instance | ||
|
||
Then we train and apply it to test data, which gives :sgclass:`CMulticlassLabels`. | ||
|
||
.. sgexample:: shareboost.sg:train_and_apply | ||
|
||
We can evaluate test performance via e.g. :sgclass:`CMulticlassAccuracy`. | ||
|
||
.. sgexample:: shareboost.sg:evaluate_accuracy | ||
|
||
---------- | ||
References | ||
---------- | ||
|
||
.. bibliography:: ../../references.bib | ||
:filter: docname in docnames |
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
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
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,29 @@ | ||
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] | ||
ShareBoost shareboost(features_train, labels_train, 2) | ||
#![create_instance] | ||
|
||
#![train_and_apply] | ||
shareboost.train() | ||
RealSubsetFeatures features_test_sub(features_test, shareboost.get_activeset()) | ||
MulticlassLabels labels_predict = shareboost.apply_multiclass(features_test_sub) | ||
#![train_and_apply] | ||
|
||
#![evaluate_accuracy] | ||
MulticlassAccuracy eval() | ||
real accuracy = eval.evaluate(labels_predict, labels_test) | ||
#![evaluate_accuracy] | ||
|
||
# additional integration testing variables | ||
RealVector output = labels_predict.get_labels() |
39 changes: 0 additions & 39 deletions
39
examples/undocumented/python_modular/classifier_multiclass_shareboost.py
This file was deleted.
Oops, something went wrong.