presage  0.8.7
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
RecencyPredictor Class Reference

#include <recencyPredictor.h>

Inheritance diagram for RecencyPredictor:
Inheritance graph
[legend]
Collaboration diagram for RecencyPredictor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RecencyPredictor (Configuration *, ContextTracker *)
 ~RecencyPredictor ()
virtual Prediction predict (const size_t size, const char **filter) const
 Generate prediction.
virtual void learn (const std::vector< std::string > &change)
virtual void update (const Observable *variable)

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

double lambda
double n_0
size_t cutoff_threshold
Dispatcher< RecencyPredictordispatcher

Static Private Attributes

static const char * LOGGER = "Presage.Predictors.RecencyPredictor.LOGGER"
static const char * LAMBDA = "Presage.Predictors.RecencyPredictor.LAMBDA"
static const char * N_0 = "Presage.Predictors.RecencyPredictor.N_0"
static const char * CUTOFF_THRESHOLD = "Presage.Predictors.RecencyPredictor.CUTOFF_THRESHOLD"

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

Definition at line 54 of file recencyPredictor.cpp.


Member Function Documentation

void RecencyPredictor::learn ( const std::vector< std::string > &  change) [virtual]

Implements Predictor.

Definition at line 122 of file recencyPredictor.cpp.

Prediction RecencyPredictor::predict ( const size_t  size,
const char **  filter 
) const [virtual]

Generate prediction.

Parameters:
sizedesired prediction size
filterfilter

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(), and Prediction::size().

Here is the call graph for this function:

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:

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:

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:

void RecencyPredictor::update ( const Observable variable) [virtual]

Implements Observer.

Definition at line 125 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

const char * RecencyPredictor::CUTOFF_THRESHOLD = "Presage.Predictors.RecencyPredictor.CUTOFF_THRESHOLD" [static, private]

Definition at line 83 of file recencyPredictor.h.

Referenced by RecencyPredictor().

Definition at line 87 of file recencyPredictor.h.

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

Definition at line 89 of file recencyPredictor.h.

Referenced by RecencyPredictor(), and update().

const char * RecencyPredictor::LAMBDA = "Presage.Predictors.RecencyPredictor.LAMBDA" [static, private]

Definition at line 81 of file recencyPredictor.h.

Referenced by RecencyPredictor().

double RecencyPredictor::lambda [private]

Definition at line 85 of file recencyPredictor.h.

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

const char * RecencyPredictor::LOGGER = "Presage.Predictors.RecencyPredictor.LOGGER" [static, private]

Definition at line 80 of file recencyPredictor.h.

Referenced by RecencyPredictor().

const char * RecencyPredictor::N_0 = "Presage.Predictors.RecencyPredictor.N_0" [static, private]

Definition at line 82 of file recencyPredictor.h.

Referenced by RecencyPredictor().

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: