presage
0.9.2~beta
|
#include <recencyPredictor.h>
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 |
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.
RecencyPredictor::RecencyPredictor | ( | Configuration * | config, |
ContextTracker * | ct, | ||
const char * | name | ||
) |
Definition at line 29 of file recencyPredictor.cpp.
References config, CUTOFF_THRESHOLD, cutoff_threshold, dispatcher, LAMBDA, lambda, LOGGER, Dispatcher< class_t >::map(), N_0, n_0, Predictor::name, Predictor::PREDICTORS, set_cutoff_threshold(), set_lambda(), Predictor::set_logger(), and set_n_0().
RecencyPredictor::~RecencyPredictor | ( | ) |
Definition at line 54 of file recencyPredictor.cpp.
|
virtual |
Implements Predictor.
Definition at line 126 of file recencyPredictor.cpp.
|
virtual |
Generate prediction.
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().
|
private |
Definition at line 72 of file recencyPredictor.cpp.
References cutoff_threshold, endl(), Predictor::logger, and Utility::toInt().
Referenced by RecencyPredictor().
|
private |
Definition at line 59 of file recencyPredictor.cpp.
References endl(), lambda, Predictor::logger, and Utility::toDouble().
Referenced by RecencyPredictor().
|
private |
Definition at line 65 of file recencyPredictor.cpp.
References endl(), Predictor::logger, n_0, and Utility::toDouble().
Referenced by RecencyPredictor().
|
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.
|
private |
Definition at line 83 of file recencyPredictor.h.
Referenced by RecencyPredictor().
|
private |
Definition at line 87 of file recencyPredictor.h.
Referenced by predict(), RecencyPredictor(), and set_cutoff_threshold().
|
private |
Definition at line 89 of file recencyPredictor.h.
Referenced by RecencyPredictor(), and update().
|
private |
Definition at line 81 of file recencyPredictor.h.
Referenced by RecencyPredictor().
|
private |
Definition at line 85 of file recencyPredictor.h.
Referenced by predict(), RecencyPredictor(), and set_lambda().
|
private |
Definition at line 80 of file recencyPredictor.h.
Referenced by RecencyPredictor().
|
private |
Definition at line 82 of file recencyPredictor.h.
Referenced by RecencyPredictor().
|
private |
Definition at line 86 of file recencyPredictor.h.
Referenced by predict(), RecencyPredictor(), and set_n_0().