Public Member Functions | Protected Attributes

CStreamingSimpleFeatures< T > Class Template Reference


Detailed Description

template<class T>
class shogun::CStreamingSimpleFeatures< T >

This class implements streaming features with dense feature vectors.

The current example is stored as a combination of current_vector and current_label.

Definition at line 27 of file StreamingSimpleFeatures.h.

Inheritance diagram for CStreamingSimpleFeatures< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CStreamingSimpleFeatures ()
 CStreamingSimpleFeatures (CStreamingFile *file, bool is_labelled, int32_t size)
 CStreamingSimpleFeatures (CSimpleFeatures< T > *simple_features, float64_t *lab=NULL)
 ~CStreamingSimpleFeatures ()
virtual void set_vector_reader ()
virtual void set_vector_and_label_reader ()
virtual void start_parser ()
virtual void end_parser ()
virtual void reset_stream ()
virtual bool get_next_example ()
SGVector< T > get_vector ()
virtual float64_t get_label ()
virtual void release_example ()
virtual int32_t get_dim_feature_space () const
virtual float32_t dot (SGVector< T > vec)
virtual float32_t dot (CStreamingDotFeatures *df)
virtual float32_t dense_dot (const float32_t *vec2, int32_t vec2_len)
virtual float64_t dense_dot (const float64_t *vec2, int32_t vec2_len)
virtual void add_to_dense_vec (float32_t alpha, float32_t *vec2, int32_t vec2_len, bool abs_val=false)
virtual void add_to_dense_vec (float64_t alpha, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
virtual int32_t get_nnz_features_for_vector ()
int32_t get_num_features ()
virtual EFeatureType get_feature_type ()
virtual EFeatureClass get_feature_class ()
virtual CFeaturesduplicate () const
virtual const char * get_name () const
virtual int32_t get_num_vectors () const
virtual int32_t get_size ()

Protected Attributes

float32_t combined_weight
 feature weighting in combined dot features
CInputParser< T > parser
 The parser object, which reads from input and returns parsed example objects.
SGVector< T > current_sgvector
 The current example's feature vector as an SGVector<T>
T * current_vector
 The current example's feature vector as a T*.
float64_t current_label
 The current example's label.
int32_t current_length
 Number of features in current example.

Constructor & Destructor Documentation

Default constructor.

Sets the reading functions to be CStreamingFile::get_*_vector and get_*_vector_and_label depending on the type T.

Definition at line 38 of file StreamingSimpleFeatures.h.

CStreamingSimpleFeatures ( CStreamingFile file,
bool  is_labelled,
int32_t  size 
)

Constructor taking args. Initializes the parser with the given args.

Parameters:
file StreamingFile object, input file.
is_labelled Whether examples are labelled or not.
size Number of example objects to be stored in the parser at a time.

Definition at line 54 of file StreamingSimpleFeatures.h.

CStreamingSimpleFeatures ( CSimpleFeatures< T > *  simple_features,
float64_t lab = NULL 
)

Constructor taking a SimpleFeatures object and a labels array as args.

Parameters:
simple_features SimpleFeatures object of same type
lab labels array, float64_t*

Definition at line 71 of file StreamingSimpleFeatures.h.

Destructor.

Ends the parsing thread. (Waits for pthread_join to complete)

Definition at line 104 of file StreamingSimpleFeatures.h.


Member Function Documentation

virtual void add_to_dense_vec ( float32_t  alpha,
float32_t vec2,
int32_t  vec2_len,
bool  abs_val = false 
) [virtual]

Add alpha*current_vector to another dense vector. Takes the absolute value of current_vector if specified.

Parameters:
alpha alpha
vec2 vector to add to
vec2_len length of vector
abs_val true if abs of current_vector should be taken

Implements CStreamingDotFeatures.

Definition at line 270 of file StreamingSimpleFeatures.h.

virtual void add_to_dense_vec ( float64_t  alpha,
float64_t vec2,
int32_t  vec2_len,
bool  abs_val = false 
) [virtual]

Add alpha*current_vector to another float64_t type dense vector. Takes the absolute value of current_vector if specified.

Parameters:
alpha alpha
vec2 vector to add to
vec2_len length of vector
abs_val true if abs of current_vector should be taken

Definition at line 295 of file StreamingSimpleFeatures.h.

virtual float32_t dense_dot ( const float32_t vec2,
int32_t  vec2_len 
) [virtual]

Dot product with another dense vector.

Parameters:
vec2 The dense vector with which to take the dot product.
vec2_len length of vector
Returns:
Dot product as a float32_t.

Implements CStreamingDotFeatures.

Definition at line 232 of file StreamingSimpleFeatures.h.

virtual float64_t dense_dot ( const float64_t vec2,
int32_t  vec2_len 
) [virtual]

Dot product with another float64_t type dense vector.

Parameters:
vec2 The dense vector with which to take the dot product.
vec2_len length of vector
Returns:
Dot product as a float64_t.

Definition at line 250 of file StreamingSimpleFeatures.h.

float32_t dot ( CStreamingDotFeatures df  )  [virtual]

Dot product taken with another StreamingDotFeatures object.

Currently only works if it is a CStreamingSimpleFeatures object. It takes the dot product of the current_vectors of both objects.

Parameters:
df CStreamingDotFeatures object.
Returns:
Dot product.

Implements CStreamingDotFeatures.

Definition at line 521 of file StreamingSimpleFeatures.h.

float32_t dot ( SGVector< T >  vec  )  [virtual]

Dot product using the current vector and another vector, passed as arg.

Parameters:
vec The vector with which to calculate the dot product.
Returns:
Dot product as a float32_t

Definition at line 536 of file StreamingSimpleFeatures.h.

virtual CFeatures* duplicate (  )  const [virtual]

Duplicate the object.

Returns:
a duplicate object as CFeatures*

Implements CFeatures.

Definition at line 346 of file StreamingSimpleFeatures.h.

void end_parser (  )  [virtual]

Ends the parsing thread.

Waits for the thread to join.

Implements CStreamingFeatures.

Definition at line 475 of file StreamingSimpleFeatures.h.

int32_t get_dim_feature_space (  )  const [virtual]

obtain the dimensionality of the feature space

(not mix this up with the dimensionality of the input space, usually obtained via get_num_features())

Returns:
dimensionality

Implements CStreamingDotFeatures.

Definition at line 515 of file StreamingSimpleFeatures.h.

EFeatureClass get_feature_class (  )  [virtual]

Return the feature class

Returns:
C_STREAMING_SIMPLE

Implements CFeatures.

Definition at line 555 of file StreamingSimpleFeatures.h.

virtual EFeatureType get_feature_type (  )  [virtual]

Return the feature type, depending on T.

Returns:
Feature type as EFeatureType

Implements CFeatures.

float64_t get_label (  )  [virtual]

Return the label of the current example as a float.

Examples must be labelled, otherwise an error occurs.

Returns:
The label as a float64_t.

Implements CStreamingFeatures.

Definition at line 501 of file StreamingSimpleFeatures.h.

virtual const char* get_name ( void   )  const [virtual]

Return the name.

Returns:
StreamingSimpleFeatures

Implements CSGObject.

Definition at line 356 of file StreamingSimpleFeatures.h.

bool get_next_example (  )  [virtual]

Instructs the parser to return the next example.

This example is stored as the current_example in this object.

Returns:
True on success, false if there are no more examples, or an error occurred.

Implements CStreamingFeatures.

Definition at line 481 of file StreamingSimpleFeatures.h.

virtual int32_t get_nnz_features_for_vector (  )  [virtual]

get number of non-zero features in vector

Returns:
number of non-zero features in vector

Reimplemented from CStreamingDotFeatures.

Definition at line 315 of file StreamingSimpleFeatures.h.

int32_t get_num_features (  )  [virtual]

Return the number of features in the current example.

Returns:
number of features as int

Implements CStreamingFeatures.

Definition at line 549 of file StreamingSimpleFeatures.h.

virtual int32_t get_num_vectors (  )  const [virtual]

Return the number of vectors stored in this object.

Returns:
1 if current_vector exists, else 0.

Implements CFeatures.

Definition at line 363 of file StreamingSimpleFeatures.h.

virtual int32_t get_size (  )  [virtual]

Return the size of one T object.

Returns:
Size of T.

Implements CFeatures.

Definition at line 375 of file StreamingSimpleFeatures.h.

SGVector< T > get_vector (  ) 

Return the current feature vector as an SGVector<T>.

Returns:
The vector as SGVector<T>

Definition at line 492 of file StreamingSimpleFeatures.h.

void release_example (  )  [virtual]

Release the current example, indicating to the parser that it has been processed by the learning algorithm.

The parser is then free to throw away that example.

Implements CStreamingFeatures.

Definition at line 509 of file StreamingSimpleFeatures.h.

virtual void reset_stream (  )  [virtual]

Reset a file back to the first example if possible.

Reimplemented from CStreamingFeatures.

Definition at line 149 of file StreamingSimpleFeatures.h.

void set_vector_and_label_reader (  )  [virtual]

Sets the read function (in case the examples are labelled) to get_*_vector_and_label from CStreamingFile.

The exact function depends on type T.

The parser uses the function set by this while reading labelled examples.

Implements CStreamingFeatures.

Definition at line 419 of file StreamingSimpleFeatures.h.

void set_vector_reader (  )  [virtual]

Sets the read function (in case the examples are unlabelled) to get_*_vector() from CStreamingFile.

The exact function depends on type T.

The parser uses the function set by this while reading unlabelled examples.

Implements CStreamingFeatures.

Definition at line 414 of file StreamingSimpleFeatures.h.

void start_parser (  )  [virtual]

Starts the parsing thread.

To be called before trying to use any feature vectors from this object.

Implements CStreamingFeatures.

Definition at line 468 of file StreamingSimpleFeatures.h.


Member Data Documentation

feature weighting in combined dot features

Reimplemented from CStreamingDotFeatures.

Definition at line 396 of file StreamingSimpleFeatures.h.

float64_t current_label [protected]

The current example's label.

Definition at line 408 of file StreamingSimpleFeatures.h.

int32_t current_length [protected]

Number of features in current example.

Definition at line 411 of file StreamingSimpleFeatures.h.

SGVector<T> current_sgvector [protected]

The current example's feature vector as an SGVector<T>

Definition at line 402 of file StreamingSimpleFeatures.h.

T* current_vector [protected]

The current example's feature vector as a T*.

Definition at line 405 of file StreamingSimpleFeatures.h.

CInputParser<T> parser [protected]

The parser object, which reads from input and returns parsed example objects.

Definition at line 399 of file StreamingSimpleFeatures.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation