SHOGUN  6.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
StreamingHashedDocDotFeatures.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2013 Evangelos Anagnostopoulos
8  * Copyright (C) 2013 Evangelos Anagnostopoulos
9  */
10 #ifndef _STREAMING_HASHEDDOCDOTFEATURES__H__
11 #define _STREAMING_HASHEDDOCDOTFEATURES__H__
12 
13 #include <shogun/lib/config.h>
14 
17 #include <shogun/lib/Tokenizer.h>
21 
22 namespace shogun
23 {
24 class CStreamingDotFeatures;
25 class CTokenizer;
26 class CHashedDocConverter;
27 
43 {
44 public:
47 
59  CStreamingHashedDocDotFeatures(CStreamingFile* file, bool is_labelled, int32_t size,
60  CTokenizer* tzer, int32_t bits=20);
61 
79  int32_t bits=20, float64_t* lab=NULL);
80 
83 
90  virtual float32_t dot(CStreamingDotFeatures* df);
91 
97  virtual float32_t dense_dot(const float32_t* vec2, int32_t vec2_len);
98 
106  virtual void add_to_dense_vec(float32_t alpha, float32_t* vec2,
107  int32_t vec2_len, bool abs_val=false);
108 
116  virtual int32_t get_dim_feature_space() const;
117 
123  virtual const char* get_name() const;
124 
130  virtual int32_t get_num_vectors() const;
131 
141  virtual void set_vector_reader();
142 
152  virtual void set_vector_and_label_reader();
153 
159  virtual EFeatureType get_feature_type() const;
160 
166  virtual EFeatureClass get_feature_class() const;
167 
172  virtual void start_parser();
173 
177  virtual void end_parser();
178 
186  virtual float64_t get_label();
187 
193  virtual bool get_next_example();
194 
200  virtual void release_example();
201 
207  virtual int32_t get_num_features();
208 
214 
219  void set_normalization(bool normalize);
220 
228  void set_k_skip_n_grams(int32_t k, int32_t n);
229 
230 private:
231  void init(CStreamingFile* file, bool is_labelled, int32_t size, CTokenizer* tzer,
232  int32_t bits, bool normalize, int32_t n_grams, int32_t skips);
233 
234 protected:
235 
237  int32_t num_bits;
238 
241 
244 
247 
250 
253 };
254 }
255 
256 #endif // _STREAMING_HASHEDDOCDOTFEATURES__H__
This class implements streaming features for a document collection. Like in the standard Bag-of-Words...
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
A Streaming File access class.
Definition: StreamingFile.h:34
virtual void add_to_dense_vec(float32_t alpha, float32_t *vec2, int32_t vec2_len, bool abs_val=false)
This class can be used to convert a document collection contained in a CStringFeatures object w...
virtual float32_t dense_dot(const float32_t *vec2, int32_t vec2_len)
The class CTokenizer acts as a base class in order to implement tokenizers. Sub-classes must implemen...
Definition: Tokenizer.h:29
double float64_t
Definition: common.h:60
Streaming features that support dot products among other operations.
float float32_t
Definition: common.h:59
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual float32_t dot(CStreamingDotFeatures *df)

SHOGUN Machine Learning Toolbox - Documentation