classias::train::lbfgs_logistic_multi< data_tmpl, model_tmpl > Class Template Reference

Inheritance diagram for classias::train::lbfgs_logistic_multi< data_tmpl, model_tmpl >:

classias::train::lbfgs_base< model_tmpl >

Detailed Description

template<class data_tmpl, class model_tmpl = weight_vector>
class classias::train::lbfgs_logistic_multi< data_tmpl, model_tmpl >

Gradient descent with L-BFGS for multi classification.

Parameters:
data_tmpl The type of the data set for training.
model_tmpl The type of the feature weights.


Public Member Functions

 lbfgs_logistic_multi ()
 Constructs the object.
virtual ~lbfgs_logistic_multi ()
 Destructs the object.
void clear ()
 Resets the internal states and parameters to default.
void train (const data_type &data, std::ostream &os, int holdout=-1, bool acconly=true)
 Trains a model on a data set.

Protected Types

typedef data_tmpl data_type
 A type representing a data set for training.
typedef model_tmpl model_type
 The type implementing a model (weight vector for features).
typedef lbfgs_base< model_tmpl > base_class
 A synonym of the base class.
typedef lbfgs_logistic_multi<
data_type, model_tmpl > 
this_class
 A synonym of this class.
typedef model_type::value_type value_type
 The type representing a value.
typedef data_type::instance_type instance_type
 A type representing an instance in the training data.
typedef data_type::const_iterator const_iterator
 A type providing a read-only random-access iterator for instances.
typedef instance_type::attributes_type attributes_type
 A type representing an attribute.
typedef data_type::feature_generator_type feature_generator_type
 A type representing a feature generator.
typedef data_type::attribute_type attribute_type
 A type representing a candidate for an instance.
typedef classify::linear_multi_logistic<
model_type
error_type
 The type of a classifier.

Protected Member Functions

virtual value_type loss_and_gradient (const value_type *x, value_type *g, const int n)
 Computes the loss and gradients of the data set.
void holdout_evaluation ()
 Performs a holdout evaluation.
template<class feature_generator_type, class iterator_type>
void add_weights (value_type *w, int l, feature_generator_type &fgen, iterator_type first, iterator_type last, value_type delta)
 Adds a value to weights associated with a feature vector.

Protected Attributes

value_typem_oexps
 An array [K] of observation expectations.
const data_typem_data
 A data set for training.
bool m_acconly
 The flag indicating whether.


Member Function Documentation

template<class data_tmpl, class model_tmpl = weight_vector>
virtual value_type classias::train::lbfgs_logistic_multi< data_tmpl, model_tmpl >::loss_and_gradient ( const value_type x,
value_type g,
const int  n 
) [inline, protected, virtual]

Computes the loss and gradients of the data set.

Parameters:
x The current feature weights.
g The gradient vector to which this function stores.
n The number of features.
Returns:
value_type The loss of the data set on the current weights.

Implements classias::train::lbfgs_base< model_tmpl >.

template<class data_tmpl, class model_tmpl = weight_vector>
void classias::train::lbfgs_logistic_multi< data_tmpl, model_tmpl >::train ( const data_type data,
std::ostream &  os,
int  holdout = -1,
bool  acconly = true 
) [inline]

Trains a model on a data set.

Parameters:
data The data set for training (and holdout evaluation).
os The output stream for progress reports.
holdout The group number for holdout evaluation. Specify a negative value if a holdout evaluation is unnecessary.
acconly The flag indicating whether precision, recall, and F1 scores are unnecessary.

template<class data_tmpl, class model_tmpl = weight_vector>
template<class feature_generator_type, class iterator_type>
void classias::train::lbfgs_logistic_multi< data_tmpl, model_tmpl >::add_weights ( value_type w,
int  l,
feature_generator_type fgen,
iterator_type  first,
iterator_type  last,
value_type  delta 
) [inline, protected]

Adds a value to weights associated with a feature vector.

Parameters:
w The weight vector to which an update occurs.
l The candidate index.
fgen The feature generator.
first The iterator pointing to the first element of the feature vector.
last The iterator pointing just beyond the last element of the feature vector.
delta The value to be added to the weights.


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