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

Specifies data samples and code used to calibrate incoming sensor data. More...

#include <calibrator.h>

Public Types

using SimpleCalibrateFunc = std::function< double(double)>
 Transforms each dimension of incoming samples of live sensor data. More...
 
using CalibrateFunc = std::function< vector< double >(vector< double >)>
 Transforms incoming samples of live sensor data. More...
 

Public Member Functions

 Calibrator ()
 
 Calibrator (SimpleCalibrateFunc f)
 
 Calibrator (CalibrateFunc f)
 
CalibratorsetCalibrateFunction (CalibrateFunc f)
 
CalibratorsetCalibrateFunction (SimpleCalibrateFunc f)
 
CalibratoraddCalibrateProcess (CalibrateProcess cp)
 
CalibratoraddCalibrateProcess (const string &name, const string &description, const CalibrateProcess::CalibratorCallback cb)
 
vector< CalibrateProcess > & getCalibrateProcesses ()
 
vector< double > calibrate (vector< double > input)
 
bool isCalibrated ()
 

Detailed Description

Specifies data samples and code used to calibrate incoming sensor data.

A Calibrator consists of two basic parts. The calibration function transforms each sample of incoming live sensor data. It's called with data coming from the input stream and its output is passed to the machine learning pipeline. Note that incoming data is processed by the calibration function before being stored in a training sample (i.e. training samples record calibrated data).

The calibration processes (CalibrateProcess instances) consist of a data sample to be collected by the user and a callback for processing that data sample once it's collected. Typically, the calibration process callback performs some analysis of the data sample collected by the user and stores that information for later use by the calibration function. For instance, a calibration process callback might record the mean values of data in the sample and use it as a baseline to be subtracted from future live sensor inputs in the calibration function.

The calibration function will not be called until the user has collected a sample of data for each CalibrateProcess instance and the corresponding callbacks have run. There is, however, no guarantee about the order in which the CalibrateProcess callbacks will be executed, as it depends on the order in which the user collects the corresponding samples of calibration data.

To tell the ESP system to use a Calibrator, pass it to useCalibrator() in your setup() function.

Examples:
user_accelerometer_gestures.cpp, user_accelerometer_poses.cpp, user_accelerometer_walk_detection.cpp, and user_sudden_motion.cpp.

Member Typedef Documentation

using Calibrator::CalibrateFunc = std::function<vector<double>(vector<double>)>

Transforms incoming samples of live sensor data.

CalibrateFunc allows for more complex transformations of incoming sensor data, e.g. for different dimensions of a sample to be transformed in different way, or for transformations that need to be be calculated using multiple dimensions of the incoming data. Note that currently the number of input dimensions must equal the number of output dimensions (i.e. the vector returned by the calibration function must have the same size as the vector passed in to the calibration function), although this may change in the future.

using Calibrator::SimpleCalibrateFunc = std::function<double(double)>

Transforms each dimension of incoming samples of live sensor data.

SimpleCalibrateFunc are used in cases where the same transformation should be applied to each dimension of incoming sensor data. The function is called on each dimension of incoming data.

Constructor & Destructor Documentation

Calibrator::Calibrator ( )
inline

Create a Calibrator without specifying a calibration function. If you use this constructor, you'll need to specify the calibration function with setCalibrateFunction().

Calibrator::Calibrator ( SimpleCalibrateFunc  f)
inline

Create a Calibrator with the specified SimpleCalibrateFunc. This function will be applied to incoming live sensor data.

Calibrator::Calibrator ( CalibrateFunc  f)
inline

Create a Calibrator with the specified CalibrateFunc. This function will be applied to incoming live sensor data.

Member Function Documentation

Calibrator & Calibrator::addCalibrateProcess ( CalibrateProcess  cp)

Add a CalibrateProcess to this Calibrator. The CalibrateProcess instances in the active Calibrator (as set by useCalibrator()) are the ones that will be shown to the user in the interface.

Returns
*this, to allow for chaining of Calibrator methods
Examples:
user_accelerometer_gestures.cpp, user_accelerometer_poses.cpp, user_accelerometer_walk_detection.cpp, and user_sudden_motion.cpp.
Calibrator & Calibrator::addCalibrateProcess ( const string &  name,
const string &  description,
const CalibrateProcess::CalibratorCallback  cb 
)

Shortcut for adding a new CalibrateProcess to this Calibrator. This creates a new CalibrateProcess with the specified name, description, and callback and adds it to the Calibrator. See CalibrateProcess::CalibrationProcess() for a description of the arguments.

Returns
*this, to allow for chaining of Calibrator methods
vector< double > Calibrator::calibrate ( vector< double >  input)

Calibrate the input data using functions registered. If a CalibrateFunc is provided and set, use it to calibrate the input; otherwise, SimpleCalibrateFunc must be set and will be used.

Parameters
input,aninput vector
Returns
output, the filtered result
vector<CalibrateProcess>& Calibrator::getCalibrateProcesses ( )
inline

Get the CalibrateProcess instances in this Calibrator.

bool Calibrator::isCalibrated ( )

Returns true if all calibrate processes are calibrated.

Calibrator & Calibrator::setCalibrateFunction ( CalibrateFunc  f)

Set the calibration function. Replaces any currently set calibration function.

Returns
*this, to allow for chaining of Calibrator methods
Examples:
user_accelerometer_gestures.cpp, user_accelerometer_poses.cpp, user_accelerometer_walk_detection.cpp, and user_sudden_motion.cpp.
Calibrator & Calibrator::setCalibrateFunction ( SimpleCalibrateFunc  f)

Set the calibration function. Replaces any currently set calibration function.

Returns
*this, to allow for chaining of Calibrator methods

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