Public Member Functions | Protected Attributes

CStreamingDotFeatures Class Reference


Detailed Description

Streaming features that support dot products among other operations.

DotFeatures support the following operations:

\[r = {\bf x} \cdot {\bf x'}\]

\[r = {\bf x} \cdot {\bf z}\]

\[ {\bf z'} = \alpha {\bf x} + {\bf z} \]

Definition at line 44 of file StreamingDotFeatures.h.

Inheritance diagram for CStreamingDotFeatures:
Inheritance graph
[legend]

List of all members.

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)

Protected Attributes

float32_t combined_weight
 feature weighting in combined dot features

Constructor & Destructor Documentation

Constructor

Definition at line 53 of file StreamingDotFeatures.h.

CStreamingDotFeatures ( CStreamingFile file,
bool  is_labelled,
int32_t  size 
)

Constructor with input information passed.

Parameters:
file CStreamingFile to take input from.
is_labelled Whether examples are labelled or not.
size Number of examples to be held in the parser's "ring".

Definition at line 67 of file StreamingDotFeatures.h.

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_features CDotFeatures object
lab labels (optional)

Definition at line 86 of file StreamingDotFeatures.h.

virtual ~CStreamingDotFeatures (  )  [virtual]

Definition at line 92 of file StreamingDotFeatures.h.


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:
alpha scalar alpha
vec2 real valued vector to add to
vec2_len length of vector
abs_val if true add the absolute value

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

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:
vec2 real valued vector
vec2_len length of vector

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

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]

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

Parameters:
output result for the given vector range
alphas scalars to multiply with, may be NULL
vec dense vector to compute dot product with
dim length of the dense vector
b bias
num_vec number 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 126 of file StreamingDotFeatures.h.

virtual float32_t dot ( CStreamingDotFeatures df  )  [pure virtual]

compute dot product between vectors of two StreamingDotFeatures objects.

Parameters:
df StreamingDotFeatures (of same kind) to compute dot product with

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

virtual 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:
vec float32_t* vector
len length of the vector

Reimplemented in CStreamingSparseFeatures< T >, and CStreamingVwFeatures.

Definition at line 165 of file StreamingDotFeatures.h.

virtual 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:
vec float64_t* vector
len length of the vector

Reimplemented in CStreamingSparseFeatures< T >, and CStreamingVwFeatures.

Definition at line 184 of file StreamingDotFeatures.h.

virtual void free_feature_iterator ( void *  iterator  )  [virtual]

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

Parameters:
iterator as returned by get_first_feature

Definition at line 249 of file StreamingDotFeatures.h.

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 CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, and CStreamingVwFeatures.

virtual 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 210 of file StreamingDotFeatures.h.

virtual 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:
index is returned by reference (-1 when not available)
value is returned by reference
iterator as returned by get_first_feature
Returns:
true if a new non-zero feature got returned

Definition at line 238 of file StreamingDotFeatures.h.

virtual 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 CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, and CStreamingVwFeatures.

Definition at line 222 of file StreamingDotFeatures.h.


Member Data Documentation

feature weighting in combined dot features

Reimplemented in CStreamingSimpleFeatures< T >.

Definition at line 259 of file StreamingDotFeatures.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