RecencyPredictor Class Reference

`#include <recencyPredictor.h>`

Inheritance diagram for RecencyPredictor:
Collaboration diagram for RecencyPredictor:

## Public Member Functions

| RecencyPredictor (Configuration *, ContextTracker *, const char *)
| ~RecencyPredictor ()
virtual Prediction | predict (const size_t size, const char **filter) const
| Generate prediction. More...
virtual void | learn (const std::vector< std::string > &change)
virtual void | update (const Observable *variable)
Public Member Functions inherited from Predictor
| Predictor (Configuration *configuration, ContextTracker *contextTracker, const char *predictorName="Predictor", const char *shortDescription="", const char *longDescription="")
virtual | ~Predictor ()
const std::string | getName () const
const std::string | getShortDescription () const
const std::string | getLongDescription () const
Public Member Functions inherited from Observer
virtual | ~Observer ()

## Private Member Functions

void | set_lambda (const std::string &value)
void | set_n_0 (const std::string &value)
void | set_cutoff_threshold (const std::string &value)

## Private Attributes

std::string | LOGGER
std::string | LAMBDA
std::string | N_0
std::string | CUTOFF_THRESHOLD
double | lambda
double | n_0
size_t | cutoff_threshold
Dispatcher< RecencyPredictor > | dispatcher

## Additional Inherited Members

Protected Member Functions inherited from Predictor
virtual bool | token_satisfies_filter (const std::string &token, const std::string &prefix, const char **filter) const
virtual void | set_logger (const std::string &level)
Protected Member Functions inherited from Observer
| Observer ()
Protected Attributes inherited from Predictor
const std::string | name
const std::string | shortDescription
const std::string | longDescription
const std::string | PREDICTORS
ContextTracker * | contextTracker
Configuration * | configuration
Logger< char > | logger

## Detailed Description

Recency predictor, a recency promotion statistical predictor.

RecencyPredictor, based on recency promotion principle, generates predictions by assigning exponentially decaying probability values to previously encountered tokens. Tokens are assigned a probability value that decays exponentially with their distance from the current token, thereby promoting context recency

(from Wikipedia) A quantity is said to be subject to exponential decay if it decreases at a rate proportional to its value. Symbolically, this can be expressed as the following differential equation, where N is the quantity and λ is a positive number called the decay constant.

frac{dN}{dt} = -lambda N.

The solution to this equation is below:

N(t) = N_0 e^{-lambda t}

Here N(t) is the quantity at time t, and N0 = N(0) is the (initial) quantity, at time t = 0.

This is the form of the equation that is most commonly used to describe exponential decay. The constant of integration N0 denotes the original quantity at t = 0. (The notation λ for the decay constant is a remnant of the usual notation for an eigenvalue. In this case, λ is the eigenvalue of the opposite of the differentiation operator with N(t) as the corresponding eigenfunction).

Definition at line 64 of file recencyPredictor.h.

## Constructor & Destructor Documentation

## RecencyPredictor()

RecencyPredictor::RecencyPredictor | ( | Configuration * | config,
|  | ContextTracker * | ct,
|  | const char * | name
| ) |  |

Definition at line 29 of file recencyPredictor.cpp.

References CUTOFF_THRESHOLD, cutoff_threshold, dispatcher, Configuration::find(), LAMBDA, lambda, LOGGER, Dispatcher< class_t >::map(), N_0, n_0, Predictor::PREDICTORS, set_cutoff_threshold(), set_lambda(), Predictor::set_logger(), and set_n_0().

Here is the call graph for this function:

## ~RecencyPredictor()

RecencyPredictor::~RecencyPredictor | ( |  | ) |

Definition at line 54 of file recencyPredictor.cpp.

## Member Function Documentation

## learn()

void RecencyPredictor::learn | ( | const std::vector< std::string > & | change | ) |

virtual

Implements Predictor.

Definition at line 126 of file recencyPredictor.cpp.

## predict()

Prediction RecencyPredictor::predict | ( | const size_t | size,
|  | const char ** | filter
| ) |  | const

virtual

Generate prediction.

Parameters

  size | desired prediction size
  filter | filter

Implements Predictor.

Definition at line 79 of file recencyPredictor.cpp.

References Prediction::addSuggestion(), Predictor::contextTracker, cutoff_threshold, endl(), ContextTracker::getPrefix(), ContextTracker::getToken(), lambda, Predictor::logger, n_0, Suggestion::setProbability(), Suggestion::setWord(), Prediction::size(), and Predictor::token_satisfies_filter().

Here is the call graph for this function:

## set_cutoff_threshold()

void RecencyPredictor::set_cutoff_threshold | ( | const std::string & | value | ) |

private

Definition at line 72 of file recencyPredictor.cpp.

References cutoff_threshold, endl(), Predictor::logger, and Utility::toInt().

Referenced by RecencyPredictor().

Here is the call graph for this function:
Here is the caller graph for this function:

## set_lambda()

void RecencyPredictor::set_lambda | ( | const std::string & | value | ) |

private

Definition at line 59 of file recencyPredictor.cpp.

References endl(), lambda, Predictor::logger, and Utility::toDouble().

Referenced by RecencyPredictor().

Here is the call graph for this function:
Here is the caller graph for this function:

## set_n_0()

void RecencyPredictor::set_n_0 | ( | const std::string & | value | ) |

private

Definition at line 65 of file recencyPredictor.cpp.

References endl(), Predictor::logger, n_0, and Utility::toDouble().

Referenced by RecencyPredictor().

Here is the call graph for this function:
Here is the caller graph for this function:

## update()

void RecencyPredictor::update | ( | const Observable * | variable | ) |

virtual

Implements Observer.

Definition at line 129 of file recencyPredictor.cpp.

References Dispatcher< class_t >::dispatch(), dispatcher, endl(), Observable::get_name(), Observable::get_value(), and Predictor::logger.

Here is the call graph for this function:

## Member Data Documentation

## CUTOFF_THRESHOLD

std::string RecencyPredictor::CUTOFF_THRESHOLD

private

Definition at line 83 of file recencyPredictor.h.

Referenced by RecencyPredictor().

## cutoff_threshold

size_t RecencyPredictor::cutoff_threshold

private

Definition at line 87 of file recencyPredictor.h.

Referenced by predict(), RecencyPredictor(), and set_cutoff_threshold().

## dispatcher

Dispatcher<RecencyPredictor> RecencyPredictor::dispatcher

private

Definition at line 89 of file recencyPredictor.h.

Referenced by RecencyPredictor(), and update().

## LAMBDA

std::string RecencyPredictor::LAMBDA

private

Definition at line 81 of file recencyPredictor.h.

Referenced by RecencyPredictor().

## lambda

double RecencyPredictor::lambda

private

Definition at line 85 of file recencyPredictor.h.

Referenced by predict(), RecencyPredictor(), and set_lambda().

## LOGGER

std::string RecencyPredictor::LOGGER

private

Definition at line 80 of file recencyPredictor.h.

Referenced by RecencyPredictor().

## N_0

std::string RecencyPredictor::N_0

private

Definition at line 82 of file recencyPredictor.h.

Referenced by RecencyPredictor().

## n_0

double RecencyPredictor::n_0

private

Definition at line 86 of file recencyPredictor.h.

Referenced by predict(), RecencyPredictor(), and set_n_0().

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

- /build/presage-1beMKb/presage-0.9.1/src/lib/predictors/recencyPredictor.h
- /build/presage-1beMKb/presage-0.9.1/src/lib/predictors/recencyPredictor.cpp