SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
List of all members | 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 26 of file StreamingSimpleFeatures.h.

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

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 ()
- Public Member Functions inherited from CStreamingDotFeatures
 CStreamingDotFeatures ()
 CStreamingDotFeatures (CStreamingFile *file, bool is_labelled, int32_t size)
 CStreamingDotFeatures (CDotFeatures *dot_features, float64_t *lab=NULL)
virtual ~CStreamingDotFeatures ()
virtual void dense_dot_range (float32_t *output, float32_t *alphas, float32_t *vec, int32_t dim, float32_t b, int32_t num_vec=0)
virtual void expand_if_required (float32_t *&vec, int32_t &len)
virtual void expand_if_required (float64_t *&vec, int32_t &len)
virtual void * get_feature_iterator ()
virtual bool get_next_feature (int32_t &index, float32_t &value, void *iterator)
virtual void free_feature_iterator (void *iterator)
- Public Member Functions inherited from CStreamingFeatures
 CStreamingFeatures ()
 CStreamingFeatures (CStreamingFile *file, bool is_labelled, int32_t size)
virtual ~CStreamingFeatures ()
void set_read_functions ()
virtual bool get_has_labels ()
virtual bool is_seekable ()
- Public Member Functions inherited from CFeatures
 CFeatures (int32_t size=0)
 CFeatures (const CFeatures &orig)
 CFeatures (CFile *loader)
virtual ~CFeatures ()
virtual int32_t add_preprocessor (CPreprocessor *p)
 set preprocessor
virtual CPreprocessordel_preprocessor (int32_t num)
 del current preprocessor
CPreprocessorget_preprocessor (int32_t num)
 get current preprocessor
void set_preprocessed (int32_t num)
bool is_preprocessed (int32_t num)
int32_t get_num_preprocessed ()
 get whether specified preprocessor (or all if num=1) was/were already applied
int32_t get_num_preprocessors () const
void clean_preprocessors ()
int32_t get_cache_size ()
virtual bool reshape (int32_t num_features, int32_t num_vectors)
void list_feature_obj ()
virtual void load (CFile *loader)
virtual void save (CFile *writer)
bool check_feature_compatibility (CFeatures *f)
bool has_property (EFeatureProperty p)
void set_property (EFeatureProperty p)
void unset_property (EFeatureProperty p)
virtual void set_subset (CSubset *subset)
virtual void remove_subset ()
virtual void subset_changed_post ()
index_t subset_idx_conversion (index_t idx) const
bool has_subset () const
virtual CFeaturescopy_subset (SGVector< index_t > indices)
- Public Member Functions inherited from CSGObject
 CSGObject ()
 CSGObject (const CSGObject &orig)
virtual ~CSGObject ()
virtual bool is_generic (EPrimitiveType *generic) const
template<class T >
void set_generic ()
void unset_generic ()
virtual void print_serializable (const char *prefix="")
virtual bool save_serializable (CSerializableFile *file, const char *prefix="")
virtual bool load_serializable (CSerializableFile *file, const char *prefix="")
void set_global_io (SGIO *io)
SGIOget_global_io ()
void set_global_parallel (Parallel *parallel)
Parallelget_global_parallel ()
void set_global_version (Version *version)
Versionget_global_version ()
SGVector< char * > get_modelsel_names ()
char * get_modsel_param_descr (const char *param_name)
index_t get_modsel_param_index (const char *param_name)

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.
- Protected Attributes inherited from CStreamingDotFeatures
float32_t combined_weight
 feature weighting in combined dot features
- Protected Attributes inherited from CStreamingFeatures
bool has_labels
 Whether examples are labelled or not.
CStreamingFileworking_file
 The StreamingFile object to read from.
bool seekable
 Whether the stream is seekable.
- Protected Attributes inherited from CFeatures
CSubsetm_subset

Additional Inherited Members

- Public Attributes inherited from CSGObject
SGIOio
Parallelparallel
Versionversion
Parameterm_parameters
Parameterm_model_selection_parameters
- Protected Member Functions inherited from CSGObject
virtual void load_serializable_pre () throw (ShogunException)
virtual void load_serializable_post () throw (ShogunException)
virtual void save_serializable_pre () throw (ShogunException)
virtual void save_serializable_post () throw (ShogunException)

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 7 of file StreamingSimpleFeatures.cpp.

CStreamingSimpleFeatures ( CStreamingFile file,
bool  is_labelled,
int32_t  size 
)

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

Parameters
fileStreamingFile object, input file.
is_labelledWhether examples are labelled or not.
sizeNumber of example objects to be stored in the parser at a time.

Definition at line 14 of file StreamingSimpleFeatures.cpp.

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

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

Parameters
simple_featuresSimpleFeatures object of same type
lablabels array, float64_t*

Definition at line 24 of file StreamingSimpleFeatures.cpp.

Destructor.

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

Definition at line 52 of file StreamingSimpleFeatures.cpp.

Member Function Documentation

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
alphaalpha
vec2vector to add to
vec2_lenlength of vector
abs_valtrue if abs of current_vector should be taken

Implements CStreamingDotFeatures.

Definition at line 91 of file StreamingSimpleFeatures.cpp.

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
alphaalpha
vec2vector to add to
vec2_lenlength of vector
abs_valtrue if abs of current_vector should be taken

Definition at line 107 of file StreamingSimpleFeatures.cpp.

float32_t dense_dot ( const float32_t vec2,
int32_t  vec2_len 
)
virtual

Dot product with another dense vector.

Parameters
vec2The dense vector with which to take the dot product.
vec2_lenlength of vector
Returns
Dot product as a float32_t.

Implements CStreamingDotFeatures.

Definition at line 69 of file StreamingSimpleFeatures.cpp.

float64_t dense_dot ( const float64_t vec2,
int32_t  vec2_len 
)
virtual

Dot product with another float64_t type dense vector.

Parameters
vec2The dense vector with which to take the dot product.
vec2_lenlength of vector
Returns
Dot product as a float64_t.

Definition at line 80 of file StreamingSimpleFeatures.cpp.

float32_t dot ( SGVector< T >  vec)
virtual

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

Parameters
vecThe vector with which to calculate the dot product.
Returns
Dot product as a float32_t

Definition at line 269 of file StreamingSimpleFeatures.cpp.

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
dfCStreamingDotFeatures object.
Returns
Dot product.

Implements CStreamingDotFeatures.

Definition at line 254 of file StreamingSimpleFeatures.cpp.

CFeatures * duplicate ( ) const
virtual

Duplicate the object.

Returns
a duplicate object as CFeatures*

Implements CFeatures.

Definition at line 128 of file StreamingSimpleFeatures.cpp.

void end_parser ( )
virtual

Ends the parsing thread.

Waits for the thread to join.

Implements CStreamingFeatures.

Definition at line 208 of file StreamingSimpleFeatures.cpp.

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 248 of file StreamingSimpleFeatures.cpp.

EFeatureClass get_feature_class ( )
virtual

Return the feature class

Returns
C_STREAMING_SIMPLE

Implements CFeatures.

Definition at line 288 of file StreamingSimpleFeatures.cpp.

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 234 of file StreamingSimpleFeatures.cpp.

virtual const char* get_name ( ) const
virtual

Return the name.

Returns
StreamingSimpleFeatures

Implements CSGObject.

Definition at line 252 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 214 of file StreamingSimpleFeatures.cpp.

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 123 of file StreamingSimpleFeatures.cpp.

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 282 of file StreamingSimpleFeatures.cpp.

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 133 of file StreamingSimpleFeatures.cpp.

int32_t get_size ( )
virtual

Return the size of one T object.

Returns
Size of T.

Implements CFeatures.

Definition at line 140 of file StreamingSimpleFeatures.cpp.

SGVector< T > get_vector ( )

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

Returns
The vector as SGVector<T>

Definition at line 225 of file StreamingSimpleFeatures.cpp.

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 242 of file StreamingSimpleFeatures.cpp.

void reset_stream ( )
virtual

Reset a file back to the first example if possible.

Reimplemented from CStreamingFeatures.

Definition at line 57 of file StreamingSimpleFeatures.cpp.

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 152 of file StreamingSimpleFeatures.cpp.

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 146 of file StreamingSimpleFeatures.cpp.

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 201 of file StreamingSimpleFeatures.cpp.

Member Data Documentation

float32_t combined_weight
protected

feature weighting in combined dot features

Definition at line 287 of file StreamingSimpleFeatures.h.

float64_t current_label
protected

The current example's label.

Definition at line 299 of file StreamingSimpleFeatures.h.

int32_t current_length
protected

Number of features in current example.

Definition at line 302 of file StreamingSimpleFeatures.h.

SGVector<T> current_sgvector
protected

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

Definition at line 293 of file StreamingSimpleFeatures.h.

T* current_vector
protected

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

Definition at line 296 of file StreamingSimpleFeatures.h.

CInputParser<T> parser
protected

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

Definition at line 290 of file StreamingSimpleFeatures.h.


The documentation for this class was generated from the following files:

SHOGUN Machine Learning Toolbox - Documentation