Reservoir< T > Class Template Reference

Reservoir class to keep examples in reservoir for training. More...

#include <reservoir.h>

List of all members.

Public Member Functions

 Reservoir (int res_size)
 Constructor that initializes the reservoir with the given reservoir size.
 Reservoir (int res_size, long seed)
 Constructor that initializes the reservoir with the given reservoir size and seed for randomness.
void addExample (std::string newEx)
 Inserts new example to the reservoir.
void addExample (int y, T ex)
 Adds example to the reservoir.
int getExampleClass (int index)
 Returns label of example at given index.
const T getExampleFeatureVector (int index)
 Returns feature vector of example at given index.
int getCurrentSize ()
 Returns how much of reservoir is filled.
bool isFull ()
 Returns whether the reservoir is full or not.

Private Member Functions

void swapClassesOfLabels (int i, int j)
 Swaps labels of given two examples.
void swapVectors (int i, int j)
 Swaps feature vectors of given two examples.
void copyExample (int index, int classOfExample, T featureArray)
 Writes given example(label and feature vector) to the given index.
void shuffle ()
 Shuffles examples in the reservoir.
void init (int res_size, long seed)
 Initializes the reservoir with the given reservoir size and seed for randomness.

Private Attributes

int reservoir_size
 size of reservoir
int current_size
 keeps how many examples are in reservoir
int * exampleClasses
 list of labels of examples in reservoir
T * pFeatures
 list of feature vectors of examples in reservoir


Detailed Description

template<class T>
class Reservoir< T >

Reservoir class to keep examples in reservoir for training.


Constructor & Destructor Documentation

template<class T>
Reservoir< T >::Reservoir ( int  res_size  ) 

Constructor that initializes the reservoir with the given reservoir size.

Parameters:
[in] res_size reservoir size

template<class T>
Reservoir< T >::Reservoir ( int  res_size,
long  seed 
)

Constructor that initializes the reservoir with the given reservoir size and seed for randomness.

Parameters:
[in] res_size reservoir size
[in] seed random seed


Member Function Documentation

template<class T>
void Reservoir< T >::addExample ( int  y,
ex 
)

Adds example to the reservoir.

Parameters:
[in] y class of the example
[in] ex feature vector of the example

template<class T>
void Reservoir< T >::addExample ( std::string  newEx  ) 

Inserts new example to the reservoir.

Parameters:
[in] newEx example string in svm format

template<class T>
void Reservoir< T >::copyExample ( int  index,
int  classOfExample,
featureArray 
) [private]

Writes given example(label and feature vector) to the given index.

Parameters:
[in] index index of example where it will be written
[in] classOfExample label of example
[in] featureArray feature vector of example

template<class T>
int Reservoir< T >::getCurrentSize (  ) 

Returns how much of reservoir is filled.

Returns:
# of examples in reservoir

template<class T>
int Reservoir< T >::getExampleClass ( int  index  ) 

Returns label of example at given index.

Parameters:
[in] index index of example in the reservoir
Returns:
label of example

template<class T>
const T Reservoir< T >::getExampleFeatureVector ( int  index  ) 

Returns feature vector of example at given index.

Parameters:
[in] index index of example in the reservoir
Returns:
feature vector of example

template<class T>
void Reservoir< T >::init ( int  res_size,
long  seed 
) [private]

Initializes the reservoir with the given reservoir size and seed for randomness.

Parameters:
[in] res_size reservoir size
[in] seed random seed

template<class T>
bool Reservoir< T >::isFull (  )  [inline]

Returns whether the reservoir is full or not.

Returns:
reservoir is full or not

template<class T>
void Reservoir< T >::shuffle (  )  [private]

Shuffles examples in the reservoir.

template<class T>
void Reservoir< T >::swapClassesOfLabels ( int  i,
int  j 
) [private]

Swaps labels of given two examples.

Parameters:
[in] i position of first example
[in] j position of second example

template<class T>
void Reservoir< T >::swapVectors ( int  i,
int  j 
) [private]

Swaps feature vectors of given two examples.

Parameters:
[in] i position of first example
[in] j position of second example


Member Data Documentation

template<class T>
int Reservoir< T >::current_size [private]

keeps how many examples are in reservoir

template<class T>
int* Reservoir< T >::exampleClasses [private]

list of labels of examples in reservoir

template<class T>
T* Reservoir< T >::pFeatures [private]

list of feature vectors of examples in reservoir

template<class T>
int Reservoir< T >::reservoir_size [private]

size of reservoir


The documentation for this class was generated from the following files:
Generated on Wed Dec 15 10:46:16 2010 for Hazy_System by  doxygen 1.4.7