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);
48 int32_t d,
bool use_quadr,
bool keep_lin_terms) :
CDotFeatures()
51 init(feats, d, use_quadr, keep_lin_terms);
60 init(feats, d, use_quadr, keep_lin_terms);
123 bool same_vec = (df ==
this) && (vec_idx1 == vec_idx2);
147 hash_cache[i] = h_idx;
150 result += vec2[h_idx %
dim] * vec[i];
157 int32_t n_idx = i * vec.
size() + i;
159 result += vec2[idx] * vec[i] * vec[i];
161 for (
index_t j=i+1; j<vec.size(); j++)
163 idx = (hash_cache[i] ^ hash_cache[j]) %
dim;
164 result += vec2[idx] * vec[i] * vec[j];
175 float64_t* vec2, int32_t vec2_len,
bool abs_val)
190 hash_cache[i] = h_idx;
193 vec2[h_idx %
dim] += val * vec[i];
200 int32_t n_idx = i * vec.
size() + i;
202 vec2[idx] += val * vec[i] * vec[i];
204 for (
index_t j=i+1; j<vec.size(); j++)
206 idx = (hash_cache[i] ^ hash_cache[j]) %
dim;
207 vec2[idx] += val * vec[i] * vec[j];
242 return "HashedDenseFeatures";
280 int32_t hash_cache_size = use_quadratic ? vec.
vlen : 0;
287 hash_cache[i] = hash;
289 if ( (!use_quadratic) || keep_linear_terms)
290 h_vec[hash %
dim] += vec[i];
299 h_vec[idx] += vec[i] * vec[i];
301 for (
index_t j=i+1; j<vec.size(); j++)
303 idx = (hash_cache[i] ^ hash_cache[j]) % dim;
304 h_vec[idx] += vec[i] * vec[j];
309 int32_t num_nnz_feats = 0;
318 int32_t sparse_feat_index = 0;
324 hashed_vector.
features[sparse_feat_index++].
entry = h_vec[i];
328 return hashed_vector;
virtual const char * get_name() const =0
CDenseFeatures< ST > * dense_feats
virtual EFeatureType get_feature_type() const
static SGSparseVector< ST > hash_vector(SGVector< ST > vec, int32_t dim, bool use_quadratic=false, bool keep_linear_terms=true)
#define SG_NOTIMPLEMENTED
This class is identical to the CDenseFeatures class except that it hashes each dimension to a new fea...
T sparse_dot(const SGSparseVector< T > &v)
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)
virtual const char * get_name() const
virtual CFeatures * duplicate() const
Class SGObject is the base class of all shogun objects.
virtual int32_t get_dim_feature_space() const
A File access base class.
SGSparseVector< ST > get_hashed_feature_vector(int32_t vec_idx)
virtual EFeatureClass get_feature_class() const =0
CHashedDenseFeatures(int32_t size=0, bool use_quadr=false, bool keep_lin_terms=true)
static void fill_vector(T *vec, int32_t len, T value)
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
virtual void free_feature_iterator(void *iterator)
virtual EFeatureClass get_feature_class() const
EFeatureType
shogun feature type
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
The class DenseFeatures implements dense feature matrices.
all of classes and functions are contained in the shogun namespace
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
The class Features is the base class of all feature objects.
virtual int32_t get_num_vectors() const
virtual int32_t get_nnz_features_for_vector(int32_t num)
virtual void load(CFile *loader)
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
virtual ~CHashedDenseFeatures()
virtual void * get_feature_iterator(int32_t vector_index)
virtual EFeatureType get_feature_type() const =0
SGSparseVectorEntry< T > * features