Public Member Functions | Protected Attributes

CStreamingFeatures Class Reference


Detailed Description

Streaming features are features which are used for online algorithms.

Reading/parsing of input, and learning through the algorithm are carried out in separate threads. Input is from a CStreamingFile object.

A StreamingFeatures object usually stores only one example at a time, and any function like dot(), add_to_dense_vec() etc. apply with this example as one implicit operand.

Similarly, when we refer to the "feature vector" of a StreamingFeatures object, it refers to the vector of the example currently stored in that object.

It is up to the user to indicate when he is done using the example so that the next one can be fetched and stored in its place.

Example objects are fetched one-by-one through a CInputParser object, and therefore a StreamingFeatures object must implement the following methods in the derived class:

release_example() must be called before get_next_example().

The feature vector itself may be returned through a derived class since at the moment the parser is templated for each data type.

Thus, a templated or specialized version of get_vector(SGVector<T>) must be implemented in the derived class.

Definition at line 63 of file StreamingFeatures.h.

Inheritance diagram for CStreamingFeatures:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CStreamingFeatures ()
 CStreamingFeatures (CStreamingFile *file, bool is_labelled, int32_t size)
virtual ~CStreamingFeatures ()
void set_read_functions ()
virtual void set_vector_reader ()=0
virtual void set_vector_and_label_reader ()=0
virtual void start_parser ()=0
virtual void end_parser ()=0
virtual float64_t get_label ()=0
virtual bool get_next_example ()=0
virtual void release_example ()=0
virtual int32_t get_num_features ()=0
virtual bool get_has_labels ()
virtual bool is_seekable ()
virtual void reset_stream ()

Protected Attributes

bool has_labels
 Whether examples are labelled or not.
CStreamingFileworking_file
 The StreamingFile object to read from.
bool seekable
 Whether the stream is seekable.

Constructor & Destructor Documentation

Default constructor with no args. Doesn't do anything yet.

Definition at line 72 of file StreamingFeatures.h.

CStreamingFeatures ( CStreamingFile file,
bool  is_labelled,
int32_t  size 
)

Constructor with input information passed.

Parameters:
file CStreamingFile to take input from.
is_labelled Whether examples are labelled or not.
size Number of examples to be held in the parser's "ring".

Definition at line 82 of file StreamingFeatures.h.

virtual ~CStreamingFeatures (  )  [virtual]

Destructor

Definition at line 88 of file StreamingFeatures.h.


Member Function Documentation

virtual void end_parser (  )  [pure virtual]

End the parser. Wait for the parsing thread to complete.

Implemented in CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, CStreamingStringFeatures< T >, and CStreamingVwFeatures.

virtual bool get_has_labels (  )  [virtual]

Return whether the examples are labelled or not.

Returns:
true if labelled, else false

Definition at line 169 of file StreamingFeatures.h.

virtual float64_t get_label (  )  [pure virtual]

Return the label of the current example.

Raise an error if the input has been specified as unlabelled.

Returns:
Label (if labelled example)

Implemented in CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, CStreamingStringFeatures< T >, and CStreamingVwFeatures.

virtual bool get_next_example (  )  [pure virtual]

Indicate to the parser that it must fetch the next example.

Returns:
true on success, false on failure (i.e., no more examples).

Implemented in CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, CStreamingStringFeatures< T >, and CStreamingVwFeatures.

virtual int32_t get_num_features (  )  [pure virtual]

Get the number of features in the current example.

Returns:
number of features in current example

Implemented in CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, CStreamingStringFeatures< T >, and CStreamingVwFeatures.

virtual bool is_seekable (  )  [virtual]

Whether the stream is seekable (to check if multiple epochs are possible), i.e., whether we can process examples in a batch fashion.

A stream can usually seekable when it comes from a file or when it comes from another conventional CFeatures object.

Returns:
true if seekable, else false.

Definition at line 184 of file StreamingFeatures.h.

virtual void release_example (  )  [pure virtual]

Indicate that processing of the current example is done. The parser then considers it safe to dispose of that example and replace it with another one.

Implemented in CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, CStreamingStringFeatures< T >, and CStreamingVwFeatures.

virtual void reset_stream (  )  [virtual]

Function to reset the stream (if possible).

Reimplemented in CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, and CStreamingVwFeatures.

Definition at line 192 of file StreamingFeatures.h.

void set_read_functions (  ) 

Set the vector reading functions.

The functions are implemented specific to the type in the derived class.

Definition at line 96 of file StreamingFeatures.h.

virtual void set_vector_and_label_reader (  )  [pure virtual]

The derived object must set the function which will be used by the parser for reading one vector and label from the file. This function should be a member of the CStreamingFile class.

See the implementation in StreamingSimpleFeatures for details.

Implemented in CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, CStreamingStringFeatures< T >, and CStreamingVwFeatures.

virtual void set_vector_reader (  )  [pure virtual]

The derived object must set the function which will be used for reading one vector from the file. This function should be a member of the CStreamingFile class.

See the implementation in StreamingSimpleFeatures for details.

Implemented in CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, CStreamingStringFeatures< T >, and CStreamingVwFeatures.

virtual void start_parser (  )  [pure virtual]

Start the parser. It stores parsed examples from the input in a separate thread.

Implemented in CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, CStreamingStringFeatures< T >, and CStreamingVwFeatures.


Member Data Documentation

bool has_labels [protected]

Whether examples are labelled or not.

Reimplemented in CStreamingStringFeatures< T >.

Definition at line 201 of file StreamingFeatures.h.

bool seekable [protected]

Whether the stream is seekable.

Definition at line 207 of file StreamingFeatures.h.

The StreamingFile object to read from.

Reimplemented in CStreamingSparseFeatures< T >, and CStreamingStringFeatures< T >.

Definition at line 204 of file StreamingFeatures.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation