#include <random-selector.h>
Inheritance diagram for RandomSelector:
Public Member Functions | |
RandomSelector (const vector< int > &labels, int num_train_per_class) | |
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. | |
Protected Member Functions | |
virtual void | SelectExamples () |
Responsible for calling AddTrainingExample and AddTestingExample to generate the lists. | |
const vector< LabeledIndex > & | GetExamples () const |
Get all of the examples (in the same order as given when constructed). | |
vector< LabeledIndex > | InvertSelection (const vector< LabeledIndex > &selection) const |
Returns all instances are NOT in <selection>. | |
vector< LabeledIndex > | InvertSelection (const vector< LabeledIndex > &selection, const vector< LabeledIndex > &superset) const |
Returns all instances in <superset> that are NOT in <selection>. | |
vector< LabeledIndex > | RandomSample (int n, const vector< LabeledIndex > &selection) const |
Return a random sample of size <n> of <selection>. | |
vector< LabeledIndex > | GetInstancesWithLabel (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. |
RandomSelector | ( | const vector< int > & | labels, | |
int | num_train_per_class | |||
) |
void SelectExamples | ( | ) | [protected, virtual] |
Responsible for calling AddTrainingExample and AddTestingExample to generate the lists.
Implements ExampleSelector.
vector< LabeledIndex > GetTrainingExamples | ( | ) | [inherited] |
Returns a vector of LabeledIndices of training instances sorted by index.
vector< LabeledIndex > GetTestingExamples | ( | ) | [inherited] |
Returns a vector of LabeledIndices of testing instances sorted by index.
vector< int > GetUniqueLabels | ( | ) | [inherited] |
Returns a vector containing all the unique labels seen. Sorting is NOT guaranteed.
int GetNumExamples | ( | ) | const [inherited] |
Returns the total number of examples there are.
const vector< LabeledIndex > & GetExamples | ( | ) | const [protected, inherited] |
Get all of the examples (in the same order as given when constructed).
vector< LabeledIndex > InvertSelection | ( | const vector< LabeledIndex > & | selection | ) | const [protected, inherited] |
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, inherited] |
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, inherited] |
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, inherited] |
Gets all elements in <selection> with the given <label>.
<selection> must be sorted. The output will be sorted.
void AddTrainingExample | ( | LabeledIndex | index | ) | [protected, inherited] |
Add a LabeledIndex to the list of designated training examples.
void AddTestingExample | ( | LabeledIndex | index | ) | [protected, inherited] |
Add a LabeledIndex to the list of designated testing examples.