Experiment Class Reference

#include <experiment.h>

Inheritance diagram for Experiment:

ProbSVMExperiment SVMExperiment List of all members.

Detailed Description

Encapsulates training/testing of any method involving a kernel.

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< LabeledIndextraining_
vector< LabeledIndextesting_


Constructor & Destructor Documentation

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]


Member Function Documentation

virtual void Train (  )  [pure virtual]

Train a model (if applicable).

Implemented in ProbSVMExperiment, and SVMExperiment.

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>.


Member Data Documentation

vector<LabeledIndex> training_ [protected]

vector<LabeledIndex> testing_ [protected]


The documentation for this class was generated from the following files:
Generated on Fri Sep 21 11:39:06 2007 for libpmk2 by  doxygen 1.5.1