classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl > Class Template Reference


Detailed Description

template<class attribute_tmpl, class label_tmpl, class feature_tmpl>
class classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl >

Feature generator for combinations of attributes and labels that exist in the training data.

This feature generator assigns a feature for every combination of attributes and labels that exist in the training data. The number of features is the unique number of combinations between attributes and labels. A conversion between attribute-label space and feature space is slower than dense_feature_generator_base, but feature space will be compact.

Parameters:
attribute_tmpl The type of an attribute.
label_tmpl The type of a label.
feature_tmpl The type of a feature.


Public Types

typedef attribute_tmpl attribute_type
 The type of an attribute.
typedef label_tmpl label_type
 The type of a label.
typedef feature_tmpl feature_type
 The type of a feature.

Public Member Functions

 sparse_feature_generator_base ()
 Constructs an object.
virtual ~sparse_feature_generator_base ()
 Destructs an object.
const char * name () const
 Returns the name of the feature generator.
size_t num_labels () const
 Returns the total number of labels.
size_t num_features () const
 Returns the total number of features.
void set_num_attributes (size_t num_attributes)
 Sets the total number of attributes.
void set_num_labels (size_t num_labels)
 Sets the total number of labels.
bool needs_registration () const
 Returns if this class requires registration.
feature_type regist (const attribute_type &a, const label_type &l)
 Registers an association between an attribute and label.
bool forward (const attribute_type &a, const label_type &l, feature_type &f) const
 Returns the feature associated with a pair of an attribute and label.
bool backward (const feature_type &f, attribute_type &a, label_type &l) const
 Returns the attribute and label associated with a feature.

Protected Types

typedef quark2_base< attribute_type,
label_type
feature_generator_type
 Class for associations from (attribute, label) to feature.

Protected Attributes

size_t m_num_labels
 The total number of labels.
size_t m_num_attributes
 The total number of attributes.
feature_generator_type m_features
 Associations between (attribute, label) and features.


Member Function Documentation

template<class attribute_tmpl, class label_tmpl, class feature_tmpl>
const char* classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl >::name (  )  const [inline]

Returns the name of the feature generator.

Returns:
const char* The feature name.

template<class attribute_tmpl, class label_tmpl, class feature_tmpl>
size_t classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl >::num_labels (  )  const [inline]

Returns the total number of labels.

Returns:
size_t The total number of labels.

template<class attribute_tmpl, class label_tmpl, class feature_tmpl>
size_t classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl >::num_features (  )  const [inline]

Returns the total number of features.

Returns:
size_t The total number of features.

template<class attribute_tmpl, class label_tmpl, class feature_tmpl>
void classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl >::set_num_attributes ( size_t  num_attributes  )  [inline]

Sets the total number of attributes.

Parameters:
num_attributes The total number of attributes.

template<class attribute_tmpl, class label_tmpl, class feature_tmpl>
void classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl >::set_num_labels ( size_t  num_labels  )  [inline]

Sets the total number of labels.

Parameters:
num_labels The total number of labels.

template<class attribute_tmpl, class label_tmpl, class feature_tmpl>
bool classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl >::needs_registration (  )  const [inline]

Returns if this class requires registration.

Returns:
bool This class always returns true.

template<class attribute_tmpl, class label_tmpl, class feature_tmpl>
feature_type classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl >::regist ( const attribute_type a,
const label_type l 
) [inline]

Registers an association between an attribute and label.

Parameters:
a The attribute.
l The label.
Returns:
feature_type The feature for the attribute and label.

template<class attribute_tmpl, class label_tmpl, class feature_tmpl>
bool classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl >::forward ( const attribute_type a,
const label_type l,
feature_type f 
) const [inline]

Returns the feature associated with a pair of an attribute and label.

Parameters:
a The attribute.
l The label.
f The feature for the attribute and label.
Returns:
bool true if the pair of the attribute and label is successfully mapped to a feature, which is always true.

template<class attribute_tmpl, class label_tmpl, class feature_tmpl>
bool classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl >::backward ( const feature_type f,
attribute_type a,
label_type l 
) const [inline]

Returns the attribute and label associated with a feature.

Parameters:
f The feature.
a The attribute associated with the feature.
l The label associated with the feature.
Returns:
bool if the feature is successfully associated with the attribute and label.


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