21 init(NULL,
false, 0, 0,
false,
true);
26 bool is_labelled, int32_t size, int32_t d,
bool use_quadr,
bool keep_lin_terms)
28 init(file, is_labelled, size, d, use_quadr, keep_lin_terms);
33 int32_t d,
bool use_quadr,
bool keep_lin_terms,
float64_t* lab)
39 bool is_labelled = (lab != NULL);
42 init(file, is_labelled, size, d, use_quadr, keep_lin_terms);
44 parser.set_free_vectors_on_destruct(
false);
55 int32_t size, int32_t d,
bool use_quadr,
bool keep_lin_terms)
60 use_quadratic = use_quadr;
61 keep_linear_terms = keep_lin_terms;
63 SG_ADD(&use_quadratic,
"use_quadratic",
"Whether to use quadratic features",
65 SG_ADD(&keep_linear_terms,
"keep_linear_terms",
"Whether to keep the linear terms or not",
68 has_labels = is_labelled;
73 parser.init(file, is_labelled, size);
80 parser.set_free_vector_after_release(
false);
102 for (
index_t i=0; i<current_vector.num_feat_entries; i++)
103 result += vec2[current_vector.features[i].feat_index] * current_vector.features[i].entry;
110 int32_t vec2_len,
bool abs_val)
117 for (
index_t i=0; i<current_vector.num_feat_entries; i++)
118 vec2[current_vector.features[i].feat_index] += alpha * current_vector.features[i].entry;
130 return "StreamingHashedSparseFeatures";
148 SG_DEBUG(
"called inside set_vector_reader\n");
173 if (!parser.is_running())
174 parser.start_parser();
186 return current_label;
193 if (parser.get_next_example(tmp.
features,
197 use_quadratic, keep_linear_terms);
208 parser.finalize_example();
220 return current_vector;
virtual const char * get_name() const =0
virtual void add_to_dense_vec(float32_t alpha, float32_t *vec2, int32_t vec2_len, bool abs_val=false)
virtual void set_vector_reader()
virtual float32_t dense_dot(const float32_t *vec2, int32_t vec2_len)
Template class SparseFeatures implements sparse matrices.
virtual float64_t get_label()
virtual int32_t get_dim_feature_space() const
This class acts as an alternative to the CStreamingSparseFeatures class and their difference is that ...
virtual bool get_next_example()
virtual EFeatureClass get_feature_class() const
virtual CFeatures * duplicate() const
virtual ~CStreamingHashedSparseFeatures()
EFeatureClass
shogun feature class
CStreamingHashedSparseFeatures()
A Streaming File access class.
virtual float32_t dot(CStreamingDotFeatures *df)
SGSparseVector< ST > current_vector
virtual void get_sparse_vector_and_label(SGSparseVectorEntry< bool > *&vector, int32_t &len, float64_t &label)
virtual int32_t get_num_features()
Streaming features that support dot products among other operations.
SGSparseVectorEntry< T > * features
EFeatureType
shogun feature type
virtual void start_parser()
virtual int32_t get_num_vectors() const
all of classes and functions are contained in the shogun namespace
virtual void get_sparse_vector(SGSparseVectorEntry< bool > *&vector, int32_t &len)
The class Features is the base class of all feature objects.
virtual void release_example()
virtual const char * get_name() const
virtual EFeatureType get_feature_type() const
Class CStreamingFileFromSparseFeatures is derived from CStreamingFile and provides an input source fo...
virtual void end_parser()
static SGSparseVector< ST > hash_vector(SGVector< ST > vec, int32_t dim, bool use_quadratic=false, bool keep_linear_terms=true)
virtual void set_vector_and_label_reader()
virtual EFeatureType get_feature_type() const =0
SGSparseVector< ST > get_vector()