SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Member Functions | Protected Attributes
CSparsePolyFeatures Class Reference

Detailed Description

implement DotFeatures for the polynomial kernel

see DotFeatures for further discription

Definition at line 24 of file SparsePolyFeatures.h.

Inheritance diagram for CSparsePolyFeatures:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CSparsePolyFeatures ()
 CSparsePolyFeatures (CSparseFeatures< float64_t > *feat, int32_t degree, bool normalize, int32_t hash_bits)
virtual ~CSparsePolyFeatures ()
 CSparsePolyFeatures (const CSparsePolyFeatures &orig)
virtual int32_t get_dim_feature_space () const
virtual int32_t get_nnz_features_for_vector (int32_t num)
virtual EFeatureType get_feature_type ()
virtual EFeatureClass get_feature_class ()
virtual int32_t get_num_vectors () const
virtual float64_t dot (int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
virtual int32_t get_size ()
virtual void * get_feature_iterator (int32_t vector_index)
bool get_next_feature (int32_t &index, float64_t &value, void *iterator)
void free_feature_iterator (void *iterator)
CFeaturesduplicate () const
virtual const char * get_name () const
virtual float64_t dense_dot (int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
virtual void add_to_dense_vec (float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)

Protected Member Functions

void store_normalization_values ()

Protected Attributes

CSparseFeatures< float64_t > * m_feat
int32_t m_degree
bool m_normalize
int32_t m_input_dimensions
int32_t m_output_dimensions
float64_tm_normalization_values
uint32_t mask
int32_t m_hash_bits

Constructor & Destructor Documentation

default constructor

Definition at line 15 of file SparsePolyFeatures.cpp.

CSparsePolyFeatures ( CSparseFeatures< float64_t > *  feat,
int32_t  degree,
bool  normalize,
int32_t  hash_bits 
)

constructor

Parameters:
featreal features
degreedegree of the polynomial kernel (only degree 2 & 3 are supported)
normalizenormalize kernel
hash_bitsnumber of bits in hashd feature space

Definition at line 30 of file SparsePolyFeatures.cpp.

~CSparsePolyFeatures ( ) [virtual]

Definition at line 48 of file SparsePolyFeatures.cpp.

copy constructor

not implemented!

Parameters:
origoriginal PolyFeature

Definition at line 54 of file SparsePolyFeatures.cpp.


Member Function Documentation

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

compute alpha*x+vec2

Parameters:
alphaalpha
vec_idx1index of first vector x
vec2vec2
vec2_lenlength of vec2
abs_valif true add the absolute value

Implements CDotFeatures.

Definition at line 186 of file SparsePolyFeatures.cpp.

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

compute dot product of vector with index arg1 with an given second vector

Parameters:
vec_idx1index of first vector
vec2second vector
vec2_lenlength of second vector

Implements CDotFeatures.

Definition at line 137 of file SparsePolyFeatures.cpp.

float64_t dot ( int32_t  vec_idx1,
CDotFeatures df,
int32_t  vec_idx2 
) [virtual]

compute dot product between vector1 and vector2, appointed by their indices

Parameters:
vec_idx1index of first vector
dfDotFeatures (of same kind) to compute dot product with
vec_idx2index of second vector

Implements CDotFeatures.

Definition at line 115 of file SparsePolyFeatures.cpp.

CFeatures * duplicate ( ) const [virtual]

duplicate feature object

Returns:
feature object

Implements CFeatures.

Definition at line 253 of file SparsePolyFeatures.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

Implements CDotFeatures.

Definition at line 110 of file SparsePolyFeatures.cpp.

int32_t get_dim_feature_space ( ) const [virtual]

get dimensions of feature space

Returns:
dimensions of feature space

Implements CDotFeatures.

Definition at line 60 of file SparsePolyFeatures.cpp.

get feature class

Returns:
feature class

Implements CFeatures.

Definition at line 79 of file SparsePolyFeatures.cpp.

void * get_feature_iterator ( int32_t  vector_index) [virtual]

iterate over the non-zero features

call get_feature_iterator first, followed by get_next_feature and free_feature_iterator to cleanup

Parameters:
vector_indexthe index of the vector over whose components to iterate over
Returns:
feature iterator (to be passed to get_next_feature)

Implements CDotFeatures.

Definition at line 98 of file SparsePolyFeatures.cpp.

get feature type

Returns:
feature type

Implements CFeatures.

Definition at line 74 of file SparsePolyFeatures.cpp.

virtual const char* get_name ( ) const [virtual]
Returns:
name of class

Implements CSGObject.

Definition at line 154 of file SparsePolyFeatures.h.

bool get_next_feature ( int32_t &  index,
float64_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

Implements CDotFeatures.

Definition at line 104 of file SparsePolyFeatures.cpp.

int32_t get_nnz_features_for_vector ( int32_t  num) [virtual]

get number of non-zero features in vector

Parameters:
numindex of vector
Returns:
number of non-zero features in vector

Implements CDotFeatures.

Definition at line 65 of file SparsePolyFeatures.cpp.

int32_t get_num_vectors ( ) const [virtual]

get number of vectors

Returns:
number of vectors

Implements CFeatures.

Definition at line 84 of file SparsePolyFeatures.cpp.

int32_t get_size ( ) [virtual]
Returns:
size

Implements CFeatures.

Definition at line 93 of file SparsePolyFeatures.cpp.

void store_normalization_values ( ) [protected]

store the norm of each training example

Definition at line 234 of file SparsePolyFeatures.cpp.


Member Data Documentation

int32_t m_degree [protected]

degree of the polynomial kernel

Definition at line 183 of file SparsePolyFeatures.h.

features in original space

Definition at line 181 of file SparsePolyFeatures.h.

int32_t m_hash_bits [protected]

number of bits in hash

Definition at line 195 of file SparsePolyFeatures.h.

int32_t m_input_dimensions [protected]

dimensions of the input space

Definition at line 187 of file SparsePolyFeatures.h.

store norm of each training example

Definition at line 191 of file SparsePolyFeatures.h.

bool m_normalize [protected]

normalize

Definition at line 185 of file SparsePolyFeatures.h.

int32_t m_output_dimensions [protected]

dimensions of the feature space of the polynomial kernel

Definition at line 189 of file SparsePolyFeatures.h.

uint32_t mask [protected]

mask

Definition at line 193 of file SparsePolyFeatures.h.


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

SHOGUN Machine Learning Toolbox - Documentation