#include <experiment.h>
Inheritance diagram for Experiment:

All that you need to implement are Train() and Test(). When implementing Test(), the way you report a new prediction is via SetPrediction(). Make sure to call SetPrediction() on each testing example.
Public Member Functions | |
| Experiment (vector< LabeledIndex > training, vector< LabeledIndex > testing, const KernelMatrix &kernel) | |
| Experiment (vector< LabeledIndex > training, const KernelMatrix &training_matrix, vector< LabeledIndex > testing, const Matrix &testing_matrix) | |
| virtual | ~Experiment () |
| virtual void | Train ()=0 |
| Train a model (if applicable). | |
| virtual int | Test ()=0 |
| Make predictions for each testing example. | |
| int | GetPrediction (int test_index) const |
| Returns the predicted value of the <test_index>th test example. | |
| int | GetNumCorrect () const |
| Get the total number of testing examples that were correctly classified. | |
| int | GetNumCorrect (int label) const |
| Get the number of testing examples that had label <label> that were also correctly classified. | |
| int | GetNumTestExamples () const |
| Get the total number of test examples. | |
| int | GetNumTestExamples (int label) const |
| Get the number of text examples with label <label>. | |
| double | GetAccuracy () const |
| Same as GetNumCorrect() / GetNumTestExamples(). | |
| double | GetAccuracy (int label) const |
| Same as GetNumCorrect(label) / GetNumTestExamples(label). | |
Protected Member Functions | |
| double | GetKernelValue (int row, int col) const |
| Get a kernel value (wrapper for KernelMatrix). | |
| double | GetKernelValue (const LabeledIndex &row, const LabeledIndex &col) const |
| Get the kernel value corresponding to the given LabeledIndices. | |
| void | SetPrediction (int test_index, int prediction) |
Protected Attributes | |
| vector< LabeledIndex > | training_ |
| vector< LabeledIndex > | testing_ |
| Experiment | ( | vector< LabeledIndex > | training, | |
| vector< LabeledIndex > | testing, | |||
| const KernelMatrix & | kernel | |||
| ) |
<kernel> includes pairwise kernel values for all data (both training and testing). The LabeledIndices in <training> and <testing> specify which row of the kernel to look at.
| Experiment | ( | vector< LabeledIndex > | training, | |
| const KernelMatrix & | training_matrix, | |||
| vector< LabeledIndex > | testing, | |||
| const Matrix & | testing_matrix | |||
| ) |
<training_matrix> is a kernel matrix for training examples only. Let N be the number of training examples. Then <testing_matrix> is a NxM Matrix where M is the number of test examples, and the testing[i][j] is the kernel value between the i'th training example and the j'th test example. <training> must be N-dimensional and <testing> must be M-dimensional.
| virtual ~Experiment | ( | ) | [inline, virtual] |
| virtual void Train | ( | ) | [pure virtual] |
| virtual int Test | ( | ) | [pure virtual] |
Make predictions for each testing example.
Returns the number of test examples that were correct. When you implement Test(), you must report results via SetPrediction().
Implemented in ProbSVMExperiment, and SVMExperiment.
| int GetPrediction | ( | int | test_index | ) | const |
Returns the predicted value of the <test_index>th test example.
Can only call this after Test() is called.
| int GetNumCorrect | ( | ) | const |
Get the total number of testing examples that were correctly classified.
| int GetNumCorrect | ( | int | label | ) | const |
Get the number of testing examples that had label <label> that were also correctly classified.
| int GetNumTestExamples | ( | ) | const |
Get the total number of test examples.
| int GetNumTestExamples | ( | int | label | ) | const |
Get the number of text examples with label <label>.
| double GetAccuracy | ( | ) | const |
Same as GetNumCorrect() / GetNumTestExamples().
| double GetAccuracy | ( | int | label | ) | const |
Same as GetNumCorrect(label) / GetNumTestExamples(label).
| double GetKernelValue | ( | int | row, | |
| int | col | |||
| ) | const [protected] |
Get a kernel value (wrapper for KernelMatrix).
| double GetKernelValue | ( | const LabeledIndex & | row, | |
| const LabeledIndex & | col | |||
| ) | const [protected] |
Get the kernel value corresponding to the given LabeledIndices.
| void SetPrediction | ( | int | test_index, | |
| int | prediction | |||
| ) | [protected] |
Call this to tell Experiment's internals that the test example at <test_index> was classified as <prediction>.
vector<LabeledIndex> training_ [protected] |
vector<LabeledIndex> testing_ [protected] |
1.5.1