#include <reservoir.h>
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 | |
Constructor that initializes the reservoir with the given reservoir size.
| [in] | res_size | reservoir size |
Constructor that initializes the reservoir with the given reservoir size and seed for randomness.
| [in] | res_size | reservoir size |
| [in] | seed | random seed |
| void Reservoir< T >::addExample | ( | int | y, | |
| T | ex | |||
| ) |
Adds example to the reservoir.
| [in] | y | class of the example |
| [in] | ex | feature vector of the example |
| void Reservoir< T >::addExample | ( | std::string | newEx | ) |
Inserts new example to the reservoir.
| [in] | newEx | example string in svm format |
| void Reservoir< T >::copyExample | ( | int | index, | |
| int | classOfExample, | |||
| T | featureArray | |||
| ) | [private] |
Writes given example(label and feature vector) to the given index.
| [in] | index | index of example where it will be written |
| [in] | classOfExample | label of example |
| [in] | featureArray | feature vector of example |
| int Reservoir< T >::getCurrentSize | ( | ) |
Returns how much of reservoir is filled.
| int Reservoir< T >::getExampleClass | ( | int | index | ) |
Returns label of example at given index.
| [in] | index | index of example in the reservoir |
| const T Reservoir< T >::getExampleFeatureVector | ( | int | index | ) |
Returns feature vector of example at given index.
| [in] | index | index of example in the reservoir |
| void Reservoir< T >::init | ( | int | res_size, | |
| long | seed | |||
| ) | [private] |
Initializes the reservoir with the given reservoir size and seed for randomness.
| [in] | res_size | reservoir size |
| [in] | seed | random seed |
| bool Reservoir< T >::isFull | ( | ) | [inline] |
Returns whether the reservoir is full or not.
| void Reservoir< T >::shuffle | ( | ) | [private] |
Shuffles examples in the reservoir.
| void Reservoir< T >::swapClassesOfLabels | ( | int | i, | |
| int | j | |||
| ) | [private] |
Swaps labels of given two examples.
| [in] | i | position of first example |
| [in] | j | position of second example |
| void Reservoir< T >::swapVectors | ( | int | i, | |
| int | j | |||
| ) | [private] |
Swaps feature vectors of given two examples.
| [in] | i | position of first example |
| [in] | j | position of second example |
int Reservoir< T >::current_size [private] |
keeps how many examples are in reservoir
int* Reservoir< T >::exampleClasses [private] |
list of labels of examples in reservoir
list of feature vectors of examples in reservoir
int Reservoir< T >::reservoir_size [private] |
size of reservoir
1.4.7