32 init(file, is_labelled, size);
101 for (int32_t i=0; i<current_length; i++) {
102 if (current_vector[i].feat_index < vec2_len) {
122 for (int32_t i=0; i<current_length; i++) {
123 if (current_vector[i].feat_index < vec2_len) {
138 SG_ERROR(
"dimension of vec (=%d) does not match number of features (=%d)\n",
149 for (int32_t i=0; i<num_feat; i++)
150 vec2[sv[i].feat_index]+= alpha*
CMath::abs(sv[i].entry);
154 for (int32_t i=0; i<num_feat; i++)
155 vec2[sv[i].feat_index]+= alpha*sv[i].entry;
166 SG_ERROR(
"dimension of vec (=%d) does not match number of features (=%d)\n",
177 for (int32_t i=0; i<num_feat; i++)
178 vec2[sv[i].feat_index]+= alpha*
CMath::abs(sv[i].entry);
182 for (int32_t i=0; i<num_feat; i++)
183 vec2[sv[i].feat_index]+= alpha*sv[i].entry;
204 for (int32_t i=0; i<current_length; i++)
205 sq += current_vector[i].entry * current_vector[i].entry;
237 parser.set_read_vector_and_label
241 #define GET_FEATURE_TYPE(f_type, sg_type) \ 242 template<> EFeatureType CStreamingSparseFeatures<sg_type>::get_feature_type() const \ 260 #undef GET_FEATURE_TYPE 264 void CStreamingSparseFeatures<T>::init()
274 void CStreamingSparseFeatures<T>::init(CStreamingFile* file,
282 parser.init(file, is_labelled, size);
283 parser.set_free_vector_after_release(
false);
302 int32_t current_length = 0;
306 ret_value = (bool)
parser.get_next_example(current_vector,
317 int32_t current_dimension =
get_vector().get_num_dimensions();
341 parser.finalize_example();
index_t current_vec_index
The current vector index.
virtual void set_vector_reader()
int32_t current_num_features
Number of features in current vector (as seen so far upto the current vector)
virtual int32_t get_num_vectors() const
int64_t get_num_nonzero_entries()
T get_feature(int32_t index)
bool has_labels
Whether examples are labelled or not.
#define SG_NOTIMPLEMENTED
virtual void add_to_dense_vec(float64_t alpha, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
T sparse_dot(const SGSparseVector< T > &v)
virtual void start_parser()
SGSparseVector< T > get_vector()
virtual int32_t get_num_features()
virtual EFeatureClass get_feature_class() const
CStreamingSparseFeatures()
static T sparse_dot(T alpha, SGSparseVectorEntry< T > *avec, int32_t alen, SGSparseVectorEntry< T > *bvec, int32_t blen)
CStreamingFile * working_file
The StreamingFile object to read from.
EFeatureClass
shogun feature class
virtual void reset_stream()
float32_t compute_squared()
A Streaming File access class.
virtual float32_t dot(CStreamingDotFeatures *df)
template class SGSparseVector The assumtion is that the stored SGSparseVectorEntry<T>* vector is orde...
virtual int32_t get_nnz_features_for_vector()
virtual void get_sparse_vector_and_label(SGSparseVectorEntry< bool > *&vector, int32_t &len, float64_t &label)
Streaming features that support dot products among other operations.
float64_t current_label
The current example's label.
SGSparseVector< T > current_sgvector
The current example's feature vector as an SGVector<T>
all of classes and functions are contained in the shogun namespace
virtual float64_t get_label()
void set_read_functions()
virtual void end_parser()
virtual void get_sparse_vector(SGSparseVectorEntry< bool > *&vector, int32_t &len)
CInputParser< SGSparseVectorEntry< T > > parser
The parser object, which reads from input and returns parsed example objects.
template class SGSparseVectorEntry
virtual bool get_next_example()
int32_t set_num_features(int32_t num)
#define GET_FEATURE_TYPE(f_type, sg_type)
virtual int32_t get_dim_feature_space() const
virtual void set_vector_and_label_reader()
T dense_dot(T alpha, T *vec, int32_t dim, T b)
This class implements streaming features with sparse feature vectors. The vector is represented as an...
virtual void release_example()
virtual ~CStreamingSparseFeatures()