SG++
sgpp::datadriven::CSVFileSampleProvider Class Reference

CSVFileSampleProvider allows reading data in CSV format into a sgpp::datadriven::Dataset object. More...

#include <CSVFileSampleProvider.hpp>

Inheritance diagram for sgpp::datadriven::CSVFileSampleProvider:
sgpp::datadriven::FileSampleProvider sgpp::datadriven::SampleProvider

Public Member Functions

SampleProviderclone () const override
 Clone Pattern to allow copying of derived classes. More...
 
 CSVFileSampleProvider ()
 Default constructor. More...
 
DatasetgetAllSamples () override
 Asks to return all available samples. More...
 
size_t getDim () const override
 Returns the maximal dimensionality of the data. More...
 
DatasetgetNextSamples (size_t howMany) override
 Lets the user request a certain amount of samples. More...
 
size_t getNumSamples () const override
 Returns the total amount of samples available in the file. More...
 
void readFile (const std::string &filePath) override
 Open an existing CSV file, parse it and store its contents inside this class. More...
 
void readString (const std::string &input) override
 Currently not implemented. More...
 
- Public Member Functions inherited from sgpp::datadriven::SampleProvider
SampleProvideroperator= (const SampleProvider &rhs)=default
 
SampleProvideroperator= (SampleProvider &&rhs)=default
 
 SampleProvider ()=default
 
 SampleProvider (const SampleProvider &rhs)=default
 
 SampleProvider (SampleProvider &&rhs)=default
 
virtual ~SampleProvider ()=default
 

Detailed Description

CSVFileSampleProvider allows reading data in CSV format into a sgpp::datadriven::Dataset object.

Data can currently only be a file containing CSV data with the first line containing column titles (is skipped).

Constructor & Destructor Documentation

sgpp::datadriven::CSVFileSampleProvider::CSVFileSampleProvider ( )

Default constructor.

Member Function Documentation

SampleProvider * sgpp::datadriven::CSVFileSampleProvider::clone ( ) const
overridevirtual

Clone Pattern to allow copying of derived classes.

Returns
a Pointer to a new instance of sgpp::datadriven::CSVFileSampleProvider with copied state. Caller owns the new object.

Implements sgpp::datadriven::SampleProvider.

Dataset * sgpp::datadriven::CSVFileSampleProvider::getAllSamples ( )
overridevirtual

Asks to return all available samples.

This functionality is designed for returning all available samples from an entire file.

Returns
sgpp::datadriven::Dataset* Pointer to a new sgpp::datadriven::Dataset object. This object is owned by the caller.

Implements sgpp::datadriven::SampleProvider.

References sgpp::datadriven::Dataset::getDimension().

size_t sgpp::datadriven::CSVFileSampleProvider::getDim ( ) const
overridevirtual

Returns the maximal dimensionality of the data.

Returns
dimensionality of the sgpp::datadriven::Dataset.

Implements sgpp::datadriven::SampleProvider.

References sgpp::datadriven::Dataset::getDimension().

Dataset * sgpp::datadriven::CSVFileSampleProvider::getNextSamples ( size_t  howMany)
overridevirtual

Lets the user request a certain amount of samples.

This functionality is is designed for streaming algorithms where data is processed in batches.

Parameters
howManynumber requested amount of samples. The amount of actually provided samples can be smaller, if there is not sufficient data.
Returns
sgpp::datadriven::Dataset* Pointer to a new sgpp::datadriven::Dataset object containing at most the requested amount of samples. This object is owned by the caller.

Implements sgpp::datadriven::SampleProvider.

References sgpp::datadriven::Dataset::getDimension().

size_t sgpp::datadriven::CSVFileSampleProvider::getNumSamples ( ) const
overridevirtual

Returns the total amount of samples available in the file.

Only works after calling readFile or readString.

Returns
the total amount of samples available in the file.

Implements sgpp::datadriven::FileSampleProvider.

References sgpp::datadriven::Dataset::getDimension(), and sgpp::datadriven::Dataset::getNumberInstances().

void sgpp::datadriven::CSVFileSampleProvider::readFile ( const std::string &  filePath)
overridevirtual

Open an existing CSV file, parse it and store its contents inside this class.

Throws if file can not be opened or parsed.

Parameters
filePathPath to an existing file.

Implements sgpp::datadriven::FileSampleProvider.

References sgpp::datadriven::CSVTools::readCSV().

void sgpp::datadriven::CSVFileSampleProvider::readString ( const std::string &  input)
overridevirtual

The documentation for this class was generated from the following files: