mlpack
Public Member Functions | List of all members
mlpack::data::LoadCSV Class Reference

Load the csv file.This class use boost::spirit to implement the parser, please refer to following link http://theboostcpplibraries.com/boost.spirit for quick review. More...

#include <load_csv.hpp>

Public Member Functions

 LoadCSV (const std::string &file)
 Construct the LoadCSV object on the given file. More...
 
template<typename T , typename PolicyType >
void Load (arma::Mat< T > &inout, DatasetMapper< PolicyType > &infoSet, const bool transpose=true)
 Load the file into the given matrix with the given DatasetMapper object. More...
 
template<typename T , typename MapPolicy >
void GetMatrixSize (size_t &rows, size_t &cols, DatasetMapper< MapPolicy > &info)
 Peek at the file to determine the number of rows and columns in the matrix, assuming a non-transposed matrix. More...
 
template<typename T , typename MapPolicy >
void GetTransposeMatrixSize (size_t &rows, size_t &cols, DatasetMapper< MapPolicy > &info)
 Peek at the file to determine the number of rows and columns in the matrix, assuming a transposed matrix. More...
 

Detailed Description

Load the csv file.This class use boost::spirit to implement the parser, please refer to following link http://theboostcpplibraries.com/boost.spirit for quick review.

Constructor & Destructor Documentation

◆ LoadCSV()

mlpack::data::LoadCSV::LoadCSV ( const std::string &  file)

Construct the LoadCSV object on the given file.

This will construct the rules necessary for loading and attempt to open the file.

Spirit rule for parsing quoted string.

Member Function Documentation

◆ GetMatrixSize()

template<typename T , typename MapPolicy >
void mlpack::data::LoadCSV::GetMatrixSize ( size_t &  rows,
size_t &  cols,
DatasetMapper< MapPolicy > &  info 
)
inline

Peek at the file to determine the number of rows and columns in the matrix, assuming a non-transposed matrix.

This will also take a first pass over the data for DatasetMapper, if MapPolicy::NeedsFirstPass is true. The info object will be re-initialized with the correct dimensionality.

Parameters
rowsVariable to be filled with the number of rows.
colsVariable to be filled with the number of columns.
infoDatasetMapper object to use for first pass.

◆ GetTransposeMatrixSize()

template<typename T , typename MapPolicy >
void mlpack::data::LoadCSV::GetTransposeMatrixSize ( size_t &  rows,
size_t &  cols,
DatasetMapper< MapPolicy > &  info 
)
inline

Peek at the file to determine the number of rows and columns in the matrix, assuming a transposed matrix.

This will also take a first pass over the data for DatasetMapper, if MapPolicy::NeedsFirstPass is true. The info object will be re-initialized with the correct dimensionality.

Parameters
rowsVariable to be filled with the number of rows.
colsVariable to be filled with the number of columns.
infoDatasetMapper object to use for first pass.

◆ Load()

template<typename T , typename PolicyType >
void mlpack::data::LoadCSV::Load ( arma::Mat< T > &  inout,
DatasetMapper< PolicyType > &  infoSet,
const bool  transpose = true 
)
inline

Load the file into the given matrix with the given DatasetMapper object.

Throws exceptions on errors.

Parameters
inoutMatrix to load into.
infoSetDatasetMapper to use while loading.
transposeIf true, the matrix should be transposed on loading (default).

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