ExampleSelector Class Reference

#include <example-selector.h>

Inheritance diagram for ExampleSelector:

ETHSelector RandomSelector List of all members.

Detailed Description

Splits a list of labels into a training and test set.

ExampleSelector does not specify any particular method of picking a training and test set, nor does it care about the data itself. The only input is a vector of labels, where each element in the vector corresponds to one image (or other data point).

To use ExampleSelector, simply subclass it and implement SelectExamples(). Within this function, designate training and testing examples by using AddTrainingExample() and AddTestingExample(). There are a number of protected member functions at your disposal that could help make things easier.


Public Member Functions

 ExampleSelector (const vector< int > &labels)
virtual ~ExampleSelector ()
vector< LabeledIndexGetTrainingExamples ()
 Returns a vector of LabeledIndices of training instances sorted by index.
vector< LabeledIndexGetTestingExamples ()
 Returns a vector of LabeledIndices of testing instances sorted by index.
vector< int > GetUniqueLabels ()
 Returns a vector containing all the unique labels seen. Sorting is NOT guaranteed.
int GetNumExamples () const
 Returns the total number of examples there are.

Protected Member Functions

const vector< LabeledIndex > & GetExamples () const
 Get all of the examples (in the same order as given when constructed).
vector< LabeledIndexInvertSelection (const vector< LabeledIndex > &selection) const
 Returns all instances are NOT in <selection>.
vector< LabeledIndexInvertSelection (const vector< LabeledIndex > &selection, const vector< LabeledIndex > &superset) const
 Returns all instances in <superset> that are NOT in <selection>.
vector< LabeledIndexRandomSample (int n, const vector< LabeledIndex > &selection) const
 Return a random sample of size <n> of <selection>.
vector< LabeledIndexGetInstancesWithLabel (int label, const vector< LabeledIndex > &selection) const
 Gets all elements in <selection> with the given <label>.
void AddTrainingExample (LabeledIndex index)
 Add a LabeledIndex to the list of designated training examples.
void AddTestingExample (LabeledIndex index)
 Add a LabeledIndex to the list of designated testing examples.
virtual void SelectExamples ()=0
 Responsible for calling AddTrainingExample and AddTestingExample to generate the lists.


Constructor & Destructor Documentation

ExampleSelector ( const vector< int > &  labels  ) 

virtual ~ExampleSelector (  )  [inline, virtual]


Member Function Documentation

vector< LabeledIndex > GetTrainingExamples (  ) 

Returns a vector of LabeledIndices of training instances sorted by index.

vector< LabeledIndex > GetTestingExamples (  ) 

Returns a vector of LabeledIndices of testing instances sorted by index.

vector< int > GetUniqueLabels (  ) 

Returns a vector containing all the unique labels seen. Sorting is NOT guaranteed.

int GetNumExamples (  )  const

Returns the total number of examples there are.

const vector< LabeledIndex > & GetExamples (  )  const [protected]

Get all of the examples (in the same order as given when constructed).

vector< LabeledIndex > InvertSelection ( const vector< LabeledIndex > &  selection  )  const [protected]

Returns all instances are NOT in <selection>.

<selection> must be sorted by index. The output will be sorted by index.

vector< LabeledIndex > InvertSelection ( const vector< LabeledIndex > &  selection,
const vector< LabeledIndex > &  superset 
) const [protected]

Returns all instances in <superset> that are NOT in <selection>.

<selection> and <superset> must be sorted by index. The output will be sorted by index.

vector< LabeledIndex > RandomSample ( int  n,
const vector< LabeledIndex > &  selection 
) const [protected]

Return a random sample of size <n> of <selection>.

<selection> must be sorted by index. If the size of <selection> is less than n, this function will return a vector of size selection.size(). Output is sorted by index.

vector< LabeledIndex > GetInstancesWithLabel ( int  label,
const vector< LabeledIndex > &  selection 
) const [protected]

Gets all elements in <selection> with the given <label>.

<selection> must be sorted. The output will be sorted.

void AddTrainingExample ( LabeledIndex  index  )  [protected]

Add a LabeledIndex to the list of designated training examples.

void AddTestingExample ( LabeledIndex  index  )  [protected]

Add a LabeledIndex to the list of designated testing examples.

virtual void SelectExamples (  )  [protected, pure virtual]

Responsible for calling AddTrainingExample and AddTestingExample to generate the lists.

Implemented in ETHSelector, and RandomSelector.


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