mlpack  master
Public Types | Public Member Functions | Private Attributes | List of all members
mlpack::data::MissingPolicy Class Reference

MissingPolicy is used as a helper class for DatasetMapper. More...

Public Types

using MappedType = double
 

Public Member Functions

 MissingPolicy ()
 
 MissingPolicy (std::set< std::string > missingSet)
 Create the MissingPolicy object with the given missingSet. More...
 
template<typename MapType >
MappedType MapString (const std::string &string, const size_t dimension, MapType &maps, std::vector< Datatype > &types)
 Given the string and the dimension to which it belongs by the user, and the maps and types given by the DatasetMapper class, returns its numeric mapping. More...
 
template<typename eT , typename MapType >
void MapTokens (const std::vector< std::string > &tokens, size_t &row, arma::Mat< eT > &matrix, MapType &maps, std::vector< Datatype > &types)
 MapTokens turns vector of strings into numeric variables and puts them into a given matrix. More...
 

Private Attributes

std::set< std::stringmissingSet
 

Detailed Description

MissingPolicy is used as a helper class for DatasetMapper.

It tells how the strings should be mapped. Purpose of this policy is to map all user-defined missing variables into maps so that users can decide what to do with the corrupted data. User-defined missing variables are given by the missingSet. Note that MissingPolicy does not change type of features.

Definition at line 30 of file missing_policy.hpp.

Member Typedef Documentation

Definition at line 34 of file missing_policy.hpp.

Constructor & Destructor Documentation

mlpack::data::MissingPolicy::MissingPolicy ( )
inline

Definition at line 36 of file missing_policy.hpp.

mlpack::data::MissingPolicy::MissingPolicy ( std::set< std::string missingSet)
inlineexplicit

Create the MissingPolicy object with the given missingSet.

Note that the missingSet cannot be changed later; you will have to create a new MissingPolicy object.

Parameters
missingSetSet of strings that should be mapped.

Definition at line 48 of file missing_policy.hpp.

Member Function Documentation

template<typename MapType >
MappedType mlpack::data::MissingPolicy::MapString ( const std::string string,
const size_t  dimension,
MapType &  maps,
std::vector< Datatype > &  types 
)
inline

Given the string and the dimension to which it belongs by the user, and the maps and types given by the DatasetMapper class, returns its numeric mapping.

If no mapping yet exists and the string is included in the missingSet, the string is added to the list of mappings for the given dimension. This function is used as a helper function for DatasetMapper class.

Template Parameters
MapTypeType of unordered_map that contains mapped value pairs
Parameters
stringString to find/create mapping for.
dimensionIndex of the dimension of the string.
mapsUnordered map given by the DatasetMapper.
typesVector containing the type information about each dimensions.

Definition at line 69 of file missing_policy.hpp.

References missingSet.

Referenced by MapTokens().

template<typename eT , typename MapType >
void mlpack::data::MissingPolicy::MapTokens ( const std::vector< std::string > &  tokens,
size_t &  row,
arma::Mat< eT > &  matrix,
MapType &  maps,
std::vector< Datatype > &  types 
)
inline

MapTokens turns vector of strings into numeric variables and puts them into a given matrix.

It is used as a helper function when trying to load files. Each dimension's tokens are given in to this function. If one of the tokens turns out to be a string or one of the missingSet's variables, only the token responsible for it should be mapped using the MapString() funciton.

Template Parameters
eTType of armadillo matrix.
MapTypeType of unordered_map that contains mapped value pairs.
Parameters
tokensVector of variables inside a dimension.
rowPosition of the given tokens.
matrixMatrix to save the data into.
mapsMaps given by the DatasetMapper class.
typesTypes of each dimensions given by the DatasetMapper class.

Definition at line 117 of file missing_policy.hpp.

References MapString(), and missingSet.

Member Data Documentation

std::set<std::string> mlpack::data::MissingPolicy::missingSet
private

Definition at line 147 of file missing_policy.hpp.

Referenced by MapString(), and MapTokens().


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