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
CStreamingDotFeatures Class Reference

Detailed Description

Streaming features that support dot products among other operations.

DotFeatures support the following operations:

Definition at line 42 of file StreamingDotFeatures.h.

Inheritance diagram for CStreamingDotFeatures:
Inheritance graph
[legend]

Public Member Functions

 CStreamingDotFeatures ()
 CStreamingDotFeatures (CStreamingFile *file, bool is_labelled, int32_t size)
 CStreamingDotFeatures (CDotFeatures *dot_features, float64_t *lab=NULL)
virtual ~CStreamingDotFeatures ()
virtual float32_t dot (CStreamingDotFeatures *df)=0
virtual float32_t dense_dot (const float32_t *vec2, int32_t vec2_len)=0
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 add_to_dense_vec (float32_t alpha, float32_t *vec2, int32_t vec2_len, bool abs_val=false)=0
virtual void expand_if_required (float32_t *&vec, int32_t &len)
virtual void expand_if_required (float64_t *&vec, int32_t &len)
virtual int32_t get_dim_feature_space () const =0
virtual void * get_feature_iterator ()
virtual int32_t get_nnz_features_for_vector ()
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 void set_vector_reader ()=0
virtual void set_vector_and_label_reader ()=0
virtual void start_parser ()=0
virtual void end_parser ()=0
virtual float64_t get_label ()=0
virtual bool get_next_example ()=0
virtual void release_example ()=0
virtual int32_t get_num_features ()=0
virtual bool get_has_labels ()
virtual bool is_seekable ()
virtual void reset_stream ()
- Public Member Functions inherited from CFeatures
 CFeatures (int32_t size=0)
 CFeatures (const CFeatures &orig)
 CFeatures (CFile *loader)
virtual CFeaturesduplicate () const =0
virtual ~CFeatures ()
virtual EFeatureType get_feature_type ()=0
virtual EFeatureClass get_feature_class ()=0
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 int32_t get_num_vectors () const =0
virtual bool reshape (int32_t num_features, int32_t num_vectors)
virtual int32_t get_size ()=0
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 const char * get_name () const =0
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
- 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

Constructor

Definition at line 5 of file StreamingDotFeatures.cpp.

CStreamingDotFeatures ( CStreamingFile file,
bool  is_labelled,
int32_t  size 
)

Constructor with input information passed.

Parameters
fileCStreamingFile to take input from.
is_labelledWhether examples are labelled or not.
sizeNumber of examples to be held in the parser's "ring".

Definition at line 11 of file StreamingDotFeatures.cpp.

CStreamingDotFeatures ( CDotFeatures dot_features,
float64_t lab = NULL 
)

Constructor taking a CDotFeatures object and optionally, labels, as args.

The derived class should implement it so that the Streaming*Features class uses the DotFeatures object as the input, getting examples one by one from the DotFeatures object (and labels, if applicable).

Parameters
dot_featuresCDotFeatures object
lablabels (optional)

Definition at line 18 of file StreamingDotFeatures.cpp.

~CStreamingDotFeatures ( )
virtual

Definition at line 25 of file StreamingDotFeatures.cpp.

Member Function Documentation

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

add current vector multiplied with alpha to dense vector, 'vec'

Parameters
alphascalar alpha
vec2real valued vector to add to
vec2_lenlength of vector
abs_valif true add the absolute value

Implemented in CStreamingVwFeatures, CStreamingSparseFeatures< T >, and CStreamingSimpleFeatures< T >.

virtual float32_t dense_dot ( const float32_t vec2,
int32_t  vec2_len 
)
pure virtual

compute dot product between current vector and a dense vector

Parameters
vec2real valued vector
vec2_lenlength of vector

Implemented in CStreamingSparseFeatures< T >, CStreamingVwFeatures, and CStreamingSimpleFeatures< T >.

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

Compute the dot product for all vectors. This function makes use of dense_dot alphas[i] * sparse[i]^T * w + b

Parameters
outputresult for the given vector range
alphasscalars to multiply with, may be NULL
vecdense vector to compute dot product with
dimlength of the dense vector
bbias
num_vecnumber of vectors to operate on (indices 0 to num_vec-1)

If num_vec == 0 or left to its default value, the function attempts to return dot product for all vectors. However, the given output vector must be preallocated!

note that the result will be written to output[0...(num_vec-1)] except when num_vec = 0

Definition at line 29 of file StreamingDotFeatures.cpp.

virtual float32_t dot ( CStreamingDotFeatures df)
pure virtual

compute dot product between vectors of two StreamingDotFeatures objects.

Parameters
dfStreamingDotFeatures (of same kind) to compute dot product with

Implemented in CStreamingVwFeatures, CStreamingSparseFeatures< T >, and CStreamingSimpleFeatures< T >.

void expand_if_required ( float32_t *&  vec,
int32_t &  len 
)
virtual

Expand the vector passed so that it its length is equal to the dimensionality of the features. The previous values are kept intact through realloc, and the new ones are set to zero.

Parameters
vecfloat32_t* vector
lenlength of the vector

Reimplemented in CStreamingSparseFeatures< T >, and CStreamingVwFeatures.

Definition at line 52 of file StreamingDotFeatures.cpp.

void expand_if_required ( float64_t *&  vec,
int32_t &  len 
)
virtual

Expand the vector passed so that it its length is equal to the dimensionality of the features. The previous values are kept intact through realloc, and the new ones are set to zero.

Parameters
vecfloat64_t* vector
lenlength of the vector

Reimplemented in CStreamingSparseFeatures< T >, and CStreamingVwFeatures.

Definition at line 63 of file StreamingDotFeatures.cpp.

void free_feature_iterator ( void *  iterator)
virtual

clean up iterator call this function with the iterator returned by get_first_feature

Parameters
iteratoras returned by get_first_feature

Definition at line 92 of file StreamingDotFeatures.cpp.

virtual int32_t get_dim_feature_space ( ) const
pure 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

Implemented in CStreamingVwFeatures, CStreamingSparseFeatures< T >, and CStreamingSimpleFeatures< T >.

void * get_feature_iterator ( )
virtual

iterate over the non-zero features

call get_feature_iterator first, followed by get_next_feature and free_feature_iterator to cleanup

Returns
feature iterator (to be passed to get_next_feature)

Definition at line 74 of file StreamingDotFeatures.cpp.

bool get_next_feature ( int32_t &  index,
float32_t value,
void *  iterator 
)
virtual

iterate over the non-zero features

call this function with the iterator returned by get_first_feature and call free_feature_iterator to cleanup

Parameters
indexis returned by reference (-1 when not available)
valueis returned by reference
iteratoras returned by get_first_feature
Returns
true if a new non-zero feature got returned

Definition at line 86 of file StreamingDotFeatures.cpp.

int32_t get_nnz_features_for_vector ( )
virtual

get number of non-zero features in vector

(in case accurate estimates are too expensive overestimating is OK)

Returns
number of sparse features in vector

Reimplemented in CStreamingSparseFeatures< T >, CStreamingVwFeatures, and CStreamingSimpleFeatures< T >.

Definition at line 80 of file StreamingDotFeatures.cpp.

Member Data Documentation

float32_t combined_weight
protected

feature weighting in combined dot features

Definition at line 193 of file StreamingDotFeatures.h.


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

SHOGUN Machine Learning Toolbox - Documentation