28 init(NULL, 0, use_quadr, keep_lin_terms);
35 init(feats, d, use_quadr, keep_lin_terms);
43 init(feats, d, use_quadr, keep_lin_terms);
52 init(feats, d, use_quadr, keep_lin_terms);
60 use_quadratic = use_quadr;
61 keep_linear_terms = keep_lin_terms;
65 SG_ADD(&use_quadratic,
"use_quadratic",
"Whether to use quadratic features",
67 SG_ADD(&keep_linear_terms,
"keep_linear_terms",
"Whether to keep the linear terms or not",
70 SG_ADD((
CSGObject** ) &sparse_feats,
"sparse_feats",
"Sparse features to work on",
103 int32_t vec_idx)
const
106 dim, use_quadratic, keep_linear_terms);
111 bool use_quadratic,
bool keep_linear_terms)
118 bool use_quadratic,
bool keep_linear_terms)
132 hash_cache[i] = hash;
134 if ( (!use_quadratic) || keep_linear_terms )
150 idx = (hash_cache[i] ^ hash_cache[j]) % dim;
156 int32_t num_nnz_features = 0;
165 int32_t sparse_index = 0;
213 hash_cache[i] = hash;
215 if ( (!use_quadratic) || keep_linear_terms)
231 idx = (hash_cache[i] ^ hash_cache[j]) % dim;
237 sparse_feats ->free_feature_vector(vec_idx1);
243 float64_t* vec2, int32_t vec2_len,
bool abs_val)
258 hash_cache[i] = hash;
260 if ( (!use_quadratic) || keep_linear_terms)
276 idx = (hash_cache[i] ^ hash_cache[j]) % dim;
281 sparse_feats ->free_feature_vector(vec_idx1);
312 return "HashedSparseFeatures";
330 return sparse_feats ->get_num_vectors();
virtual const char * get_name() const =0
static void fill_vector(T *vec, int32_t len, T value)
T sparse_dot(const SGSparseVector< T > &v)
CSparseFeatures< ST > * sparse_feats
virtual int32_t get_dim_feature_space() const
static SGSparseVector< ST > hash_vector(SGVector< ST > vec, int32_t dim, bool use_quadratic=false, bool keep_linear_terms=true)
Template class SparseFeatures implements sparse matrices.
CHashedSparseFeatures(int32_t size=0, bool use_quadr=false, bool keep_lin_terms=true)
#define SG_NOTIMPLEMENTED
virtual EFeatureType get_feature_type() const
virtual ~CHashedSparseFeatures()
Features that support dot products among other operations.
EFeatureClass
shogun feature class
static uint32_t MurmurHash3(uint8_t *data, int32_t len, uint32_t seed)
Class SGObject is the base class of all shogun objects.
virtual int32_t get_nnz_features_for_vector(int32_t num)
This class is identical to the CDenseFeatures class except that it hashes each dimension to a new fea...
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
A File access base class.
virtual void free_feature_iterator(void *iterator)
virtual EFeatureClass get_feature_class() const =0
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
SGSparseVectorEntry< T > * features
virtual const char * get_name() const
virtual CFeatures * duplicate() const
EFeatureType
shogun feature type
all of classes and functions are contained in the shogun namespace
virtual int32_t get_num_vectors() const
The class Features is the base class of all feature objects.
virtual EFeatureClass get_feature_class() const
SGSparseVector< ST > get_hashed_feature_vector(int32_t vec_idx) const
virtual void * get_feature_iterator(int32_t vector_index)
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
static SGSparseVector< ST > hash_vector(SGVector< ST > vec, int32_t dim, bool use_quadratic=false, bool keep_linear_terms=true)
virtual EFeatureType get_feature_type() const =0