Inheritance diagram for classias::classify::linear_multi_logistic< model_tmpl >:
This template class implements a multi classifier with a linear discriminant model. The types of features, feature generators, and models are customizable. Any type that yields a feature weight with operator [] is acceptable for a model. A feature generator must convert a pair of an attribute and a label into a feature identifier that is compatible with the argument type of the operator
[] of the model.
An instance is designed to have multiple candidates, and the candidate that yields the highest score is chosen as a classification result. The number of candidates must be set by resize() before computing candidate scores. Call set(), inner_product(), or scale() functions to compute the score of a candidate. After computing the score of all candidates, call finalize() function to determine the candidate with the highest score.
model_tmpl | The type of a model (container of feature weights). Any type that yields a feature weight with operator [] is usable (e.g., arrays, std::vector , std::map ). |
Public Types | |
typedef model_tmpl | model_type |
The type of a model. | |
typedef model_type::value_type | value_type |
The type of a feature weight. | |
typedef linear_multi< model_tmpl > | base_type |
The type of the base class. | |
Public Member Functions | |
linear_multi_logistic (const model_type &model) | |
Constructs an instance. | |
virtual | ~linear_multi_logistic () |
Destructs an instance. | |
void | clear () |
Resets the classification result. | |
value_type | prob (int i) |
Returns the probability for a candidate. | |
value_type | logprob (int i) |
Returns the log of the probability for a candidate. | |
value_type | error (int i, int r) |
Computes the error of a candidate. | |
void | finalize () |
Finalize the classification. | |
Static Public Member Functions | |
static const char * | name () |
Returns the name of this classifier. | |
Protected Attributes | |
value_type | m_lognorm |
classias::classify::linear_multi_logistic< model_tmpl >::linear_multi_logistic | ( | const model_type & | model | ) | [inline] |
Constructs an instance.
model | The model associated with the classifier. |
void classias::classify::linear_multi_logistic< model_tmpl >::clear | ( | ) | [inline] |
Resets the classification result.
Call this function before sending a next classification instance.
Reimplemented from classias::classify::linear_multi< model_tmpl >.
value_type classias::classify::linear_multi_logistic< model_tmpl >::prob | ( | int | i | ) | [inline] |
Returns the probability for a candidate.
i | The index for the candidate. |
value_type classias::classify::linear_multi_logistic< model_tmpl >::logprob | ( | int | i | ) | [inline] |
Returns the log of the probability for a candidate.
i | The index for the candidate. |
value_type classias::classify::linear_multi_logistic< model_tmpl >::error | ( | int | i, | |
int | r | |||
) | [inline] |
Computes the error of a candidate.
i | The index for the candidate. | |
r | The index for the reference candidate. |
void classias::classify::linear_multi_logistic< model_tmpl >::finalize | ( | ) | [inline] |
Finalize the classification.
Call this function before using argmax(), prob(), logprob(), and error() function.
Reimplemented from classias::classify::linear_multi< model_tmpl >.
static const char* classias::classify::linear_multi_logistic< model_tmpl >::name | ( | ) | [inline, static] |
Returns the name of this classifier.
Reimplemented from classias::classify::linear_multi< model_tmpl >.