ESP  0.1
The Example-based Sensor Predictions (ESP) system tries to bring machine learning to the maker community.
TrainingDataManager Class Reference

TrainingDataManager class encloses GRT::TimeSeriesClassificationData and improves upon by adding utility functions that relabel, delete or trim some training samples. More...

#include <training-data-manager.h>

Public Member Functions

 TrainingDataManager (uint32_t num_classes)
 
bool setNumDimensions (uint32_t dim)
 
bool setDatasetName (const std::string name)
 
bool setDatasetName (const char *const name)
 
GRT::TimeSeriesClassificationData getAllData ()
 
uint32_t getNumLabels ()
 
uint32_t getTotalNumSamples ()
 
bool setNameForLabel (const std::string name, uint32_t label)
 This will modify the default name for this label, changing it from "Label X" to name. More...
 
std::string getLabelName (uint32_t label)
 
std::string getSampleName (uint32_t label, uint32_t index)
 Format the sample name. Default label name is "Label X", and the sample name is "Label X [Y]" Default name can be changed by setNameForLabel. More...
 
bool setSampleName (uint32_t, uint32_t, const std::string)
 
bool addSample (uint32_t label, const GRT::MatrixDouble &sample)
 Add new sample. Returns false if the label is larger than configured number of classes. More...
 
uint32_t getNumSampleForLabel (uint32_t label)
 
GRT::MatrixDouble getSample (uint32_t label, uint32_t index)
 Get the sample by label and index. More...
 
bool deleteSample (uint32_t label, uint32_t index)
 Remove sample by label and the index. More...
 
bool deleteAllSamples ()
 Remove all samples. More...
 
bool deleteAllSamplesWithLabel (uint32_t label)
 Remove all samples. More...
 
bool relabelSample (uint32_t label, uint32_t index, uint32_t new_label)
 Relabel a sample from label to new_label. More...
 
bool trimSample (uint32_t label, uint32_t index, uint32_t start, uint32_t end)
 Trim sample. What's left will be [start, end], closed interval. More...
 
bool hasSampleScore (uint32_t label, uint32_t index)
 
double getSampleScore (uint32_t label, uint32_t index)
 
bool setSampleScore (uint32_t label, uint32_t index, double score)
 
bool hasSampleClassLikelihoods (uint32_t label, uint32_t index)
 
vector< double > getSampleClassLikelihoods (uint32_t label, uint32_t index)
 
bool setSampleClassLikelihoods (uint32_t label, uint32_t index, vector< double > likelihoods)
 
bool save (const std::string &filename)
 
bool load (const std::string &filename)
 

Detailed Description

TrainingDataManager class encloses GRT::TimeSeriesClassificationData and improves upon by adding utility functions that relabel, delete or trim some training samples.

This class will take the sole mutable ownership of the enclosed data. All operations over the training data have to gone through this class.

Training data can be viewed as a collection of training samples, where each sample consists of a label (which class this sample belongs to) and the data (a time-series data).

A few key augmentation to the underlying TimeSeriesClassificationData:

  1. Edit (relabel, delete or trim individual samples).
  2. Name individual sample.

Each individual sample is addressable by (label, index) tuple. Label starts from 1 and index starts from 0.

Constructor & Destructor Documentation

TrainingDataManager::TrainingDataManager ( uint32_t  num_classes)

Member Function Documentation

bool TrainingDataManager::addSample ( uint32_t  label,
const GRT::MatrixDouble &  sample 
)

Add new sample. Returns false if the label is larger than configured number of classes.

bool TrainingDataManager::deleteAllSamples ( )

Remove all samples.

bool TrainingDataManager::deleteAllSamplesWithLabel ( uint32_t  label)

Remove all samples.

bool TrainingDataManager::deleteSample ( uint32_t  label,
uint32_t  index 
)

Remove sample by label and the index.

GRT::TimeSeriesClassificationData TrainingDataManager::getAllData ( )
inline
std::string TrainingDataManager::getLabelName ( uint32_t  label)
uint32_t TrainingDataManager::getNumLabels ( )
inline
uint32_t TrainingDataManager::getNumSampleForLabel ( uint32_t  label)
GRT::MatrixDouble TrainingDataManager::getSample ( uint32_t  label,
uint32_t  index 
)

Get the sample by label and index.

std::vector< double > TrainingDataManager::getSampleClassLikelihoods ( uint32_t  label,
uint32_t  index 
)
std::string TrainingDataManager::getSampleName ( uint32_t  label,
uint32_t  index 
)

Format the sample name. Default label name is "Label X", and the sample name is "Label X [Y]" Default name can be changed by setNameForLabel.

double TrainingDataManager::getSampleScore ( uint32_t  label,
uint32_t  index 
)
uint32_t TrainingDataManager::getTotalNumSamples ( )
inline
bool TrainingDataManager::hasSampleClassLikelihoods ( uint32_t  label,
uint32_t  index 
)
bool TrainingDataManager::hasSampleScore ( uint32_t  label,
uint32_t  index 
)
bool TrainingDataManager::load ( const std::string &  filename)
bool TrainingDataManager::relabelSample ( uint32_t  label,
uint32_t  index,
uint32_t  new_label 
)

Relabel a sample from label to new_label.

bool TrainingDataManager::save ( const std::string &  filename)
inline
bool TrainingDataManager::setDatasetName ( const std::string  name)
bool TrainingDataManager::setDatasetName ( const char *const  name)
bool TrainingDataManager::setNameForLabel ( const std::string  name,
uint32_t  label 
)

This will modify the default name for this label, changing it from "Label X" to name.

bool TrainingDataManager::setNumDimensions ( uint32_t  dim)
bool TrainingDataManager::setSampleClassLikelihoods ( uint32_t  label,
uint32_t  index,
vector< double >  likelihoods 
)
bool TrainingDataManager::setSampleName ( uint32_t  label,
uint32_t  index,
const std::string  new_name 
)
bool TrainingDataManager::setSampleScore ( uint32_t  label,
uint32_t  index,
double  score 
)
bool TrainingDataManager::trimSample ( uint32_t  label,
uint32_t  index,
uint32_t  start,
uint32_t  end 
)

Trim sample. What's left will be [start, end], closed interval.


The documentation for this class was generated from the following files: