classias::binary_data_base< instance_tmpl > Class Template Reference

Inheritance diagram for classias::binary_data_base< instance_tmpl >:

classias::binary_data_with_quark_base< instance_tmpl, attributes_quark_tmpl > classias::candidate_data_base< instance_tmpl, feature_generator_tmpl > classias::candidate_data_with_quark_base< instance_tmpl, attributes_quark_tmpl, labels_quark_tmpl, feature_generator_tmpl > classias::multi_data_base< instance_tmpl, feature_generator_tmpl > classias::multi_data_with_quark_base< instance_tmpl, attributes_quark_tmpl, labels_quark_tmpl, feature_generator_tmpl >

Detailed Description

template<class instance_tmpl>
class classias::binary_data_base< instance_tmpl >

A template class for a collection of binary-classification instances.

This class represents a data set for training a binary classifier. The class stores instances into a vector. This class implements the necessary functions num_attributes(), num_features(), and num_labels() for training algorithms. Do not forget to call set_num_features() to specify the total number of features.

Parameters:
instance_tmpl The type of an instance.


Public Types

typedef instance_tmpl instance_type
 The type of an instance.
typedef std::vector< instance_typeinstances_type
 A type providing a container of instances.
typedef instances_type::size_type size_type
 A type counting the number of pairs in a container.
typedef instances_type::iterator iterator
 A type providing a random-access iterator.
typedef instances_type::const_iterator const_iterator
 A type providing a read-only random-access iterator.
typedef instance_type::attribute_type attribute_type
 The type of an attribute.

Public Member Functions

 binary_data_base ()
 Constructs the object.
virtual ~binary_data_base ()
 Destructs the object.
void clear ()
 Erases all the instances of the data.
bool empty () const
 Tests if the data is empty.
size_type size () const
 Returns the number of instances in the data.
instance_typeoperator[] (size_type i)
 Returns a read/write reference to an instance.
const instance_typeoperator[] (size_type i) const
 Returns a read-only reference to an instance.
iterator begin ()
 Returns a random-access iterator to the first instance.
const_iterator begin () const
 Returns a random-access iterator to the first instance.
iterator end ()
 Returns a random-access iterator pointing just beyond the last instance.
const_iterator end () const
 Returns a random-access iterator pointing just beyond the last instance.
instance_typeback ()
 Returns the reference to the last instance.
instance_typenew_element ()
 Creates and returns a new instance.
void set_user_feature_start (int index)
 Sets the start index of user features.
int get_user_feature_start () const
 Returns the start index of user features.
void set_num_features (int num)
 Sets the total number of features.
int num_attributes () const
 Returns the total number of attributes.
int num_labels () const
 Returns the total number of labels.
int num_features () const
 Returns the total number of features.

Protected Attributes

instances_type instances
 A container of instances.
int m_num_features
 The number of features.
int m_feature_start_index
 The start index of features.


Member Function Documentation

template<class instance_tmpl>
bool classias::binary_data_base< instance_tmpl >::empty (  )  const [inline]

Tests if the data is empty.

Return values:
bool true if the data is empty, false otherwise.

template<class instance_tmpl>
size_type classias::binary_data_base< instance_tmpl >::size (  )  const [inline]

Returns the number of instances in the data.

Return values:
size_type The current size of the data.

template<class instance_tmpl>
instance_type& classias::binary_data_base< instance_tmpl >::operator[] ( size_type  i  )  [inline]

Returns a read/write reference to an instance.

Parameters:
i The index number for an instance.
Return values:
instance_type& Reference to the instance.

template<class instance_tmpl>
const instance_type& classias::binary_data_base< instance_tmpl >::operator[] ( size_type  i  )  const [inline]

Returns a read-only reference to an instance.

Parameters:
i The index number for an instance.
Return values:
const instance_type& Reference to the instance.

template<class instance_tmpl>
iterator classias::binary_data_base< instance_tmpl >::begin (  )  [inline]

Returns a random-access iterator to the first instance.

Return values:
iterator A random-access iterator (for read/write) addressing the first instance in the data or to the location succeeding an empty instance.

template<class instance_tmpl>
const_iterator classias::binary_data_base< instance_tmpl >::begin (  )  const [inline]

Returns a random-access iterator to the first instance.

Return values:
iterator A random-access iterator (for read-only) addressing the first instance in the data or to the location succeeding an empty instance.

template<class instance_tmpl>
iterator classias::binary_data_base< instance_tmpl >::end (  )  [inline]

Returns a random-access iterator pointing just beyond the last instance.

Return values:
iterator A random-access iterator (for read/write) addressing the end of the instance.

template<class instance_tmpl>
const_iterator classias::binary_data_base< instance_tmpl >::end (  )  const [inline]

Returns a random-access iterator pointing just beyond the last instance.

Return values:
iterator A random-access iterator (for read-only) addressing the end of the instance.

template<class instance_tmpl>
instance_type& classias::binary_data_base< instance_tmpl >::back (  )  [inline]

Returns the reference to the last instance.

Return values:
instance_type& The reference pointing to the last instance in the data.

template<class instance_tmpl>
instance_type& classias::binary_data_base< instance_tmpl >::new_element (  )  [inline]

Creates and returns a new instance.

Return values:
instance_type& The reference to the new instance.

template<class instance_tmpl>
void classias::binary_data_base< instance_tmpl >::set_user_feature_start ( int  index  )  [inline]

Sets the start index of user features.

Parameters:
index The start index of user features.

template<class instance_tmpl>
int classias::binary_data_base< instance_tmpl >::get_user_feature_start (  )  const [inline]

Returns the start index of user features.

Returns:
fid_type The start index of user features.

template<class instance_tmpl>
void classias::binary_data_base< instance_tmpl >::set_num_features ( int  num  )  [inline]

Sets the total number of features.

Parameters:
num The number of features.

template<class instance_tmpl>
int classias::binary_data_base< instance_tmpl >::num_attributes (  )  const [inline]

Returns the total number of attributes.

Returns:
int The total number of attributes.

Reimplemented in classias::binary_data_with_quark_base< instance_tmpl, attributes_quark_tmpl >, classias::candidate_data_base< instance_tmpl, feature_generator_tmpl >, classias::candidate_data_with_quark_base< instance_tmpl, attributes_quark_tmpl, labels_quark_tmpl, feature_generator_tmpl >, classias::multi_data_base< instance_tmpl, feature_generator_tmpl >, and classias::multi_data_with_quark_base< instance_tmpl, attributes_quark_tmpl, labels_quark_tmpl, feature_generator_tmpl >.

template<class instance_tmpl>
int classias::binary_data_base< instance_tmpl >::num_labels (  )  const [inline]

Returns the total number of labels.

Returns:
int The total number of labels. This is always 2 for the data collection for binary instances.

Reimplemented in classias::binary_data_with_quark_base< instance_tmpl, attributes_quark_tmpl >, classias::candidate_data_base< instance_tmpl, feature_generator_tmpl >, classias::candidate_data_with_quark_base< instance_tmpl, attributes_quark_tmpl, labels_quark_tmpl, feature_generator_tmpl >, classias::multi_data_base< instance_tmpl, feature_generator_tmpl >, and classias::multi_data_with_quark_base< instance_tmpl, attributes_quark_tmpl, labels_quark_tmpl, feature_generator_tmpl >.

template<class instance_tmpl>
int classias::binary_data_base< instance_tmpl >::num_features (  )  const [inline]

Returns the total number of features.

Returns:
int The total number of features.

Reimplemented in classias::binary_data_with_quark_base< instance_tmpl, attributes_quark_tmpl >, classias::candidate_data_base< instance_tmpl, feature_generator_tmpl >, classias::candidate_data_with_quark_base< instance_tmpl, attributes_quark_tmpl, labels_quark_tmpl, feature_generator_tmpl >, classias::multi_data_base< instance_tmpl, feature_generator_tmpl >, and classias::multi_data_with_quark_base< instance_tmpl, attributes_quark_tmpl, labels_quark_tmpl, feature_generator_tmpl >.


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