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.
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. |
const char* classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl >::name | ( | ) | const [inline] |
Returns the name of the feature generator.
size_t classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl >::num_labels | ( | ) | const [inline] |
Returns the total number of labels.
size_t classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl >::num_features | ( | ) | const [inline] |
Returns the total number of features.
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.
num_attributes | The total number of attributes. |
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.
num_labels | The total number of labels. |
bool classias::sparse_feature_generator_base< attribute_tmpl, label_tmpl, feature_tmpl >::needs_registration | ( | ) | const [inline] |
Returns if this class requires registration.
true
. 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.
a | The attribute. | |
l | The label. |
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.
a | The attribute. | |
l | The label. | |
f | The feature for the attribute and label. |
true
if the pair of the attribute and label is successfully mapped to a feature, which is always true
. 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.
f | The feature. | |
a | The attribute associated with the feature. | |
l | The label associated with the feature. |
if
the feature is successfully associated with the attribute and label.