classias::classify::linear_multi_logistic< model_tmpl > Class Template Reference

Inheritance diagram for classias::classify::linear_multi_logistic< model_tmpl >:

classias::classify::linear_multi< model_tmpl >

Detailed Description

template<class model_tmpl>
class classias::classify::linear_multi_logistic< model_tmpl >

A template class for linear multi-class classifiers with soft-max function (Maximum Entropy models).

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.

Parameters:
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).
See also:
thru_feature_generator_base, dense_feature_generator_base, sparse_feature_generator_base.


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


Constructor & Destructor Documentation

template<class model_tmpl>
classias::classify::linear_multi_logistic< model_tmpl >::linear_multi_logistic ( const model_type model  )  [inline]

Constructs an instance.

Parameters:
model The model associated with the classifier.


Member Function Documentation

template<class model_tmpl>
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 >.

template<class model_tmpl>
value_type classias::classify::linear_multi_logistic< model_tmpl >::prob ( int  i  )  [inline]

Returns the probability for a candidate.

Parameters:
i The index for the candidate.
Returns:
value_type The probability.

template<class model_tmpl>
value_type classias::classify::linear_multi_logistic< model_tmpl >::logprob ( int  i  )  [inline]

Returns the log of the probability for a candidate.

Parameters:
i The index for the candidate.
Returns:
value_type The log of the probability.

template<class model_tmpl>
value_type classias::classify::linear_multi_logistic< model_tmpl >::error ( int  i,
int  r 
) [inline]

Computes the error of a candidate.

Parameters:
i The index for the candidate.
r The index for the reference candidate.
Returns:
value_type The error.

template<class model_tmpl>
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 >.

template<class model_tmpl>
static const char* classias::classify::linear_multi_logistic< model_tmpl >::name (  )  [inline, static]

Returns the name of this classifier.

Returns:
const char* The name of the classifier.

Reimplemented from classias::classify::linear_multi< model_tmpl >.


Copyright (c) 2002-2009 by Naoaki Okazaki
Mon Dec 28 23:41:06 2009