mlpack
master
|
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::string > | missingSet |
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.
using mlpack::data::MissingPolicy::MappedType = double |
Definition at line 34 of file missing_policy.hpp.
|
inline |
Definition at line 36 of file missing_policy.hpp.
|
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.
missingSet | Set of strings that should be mapped. |
Definition at line 48 of file missing_policy.hpp.
|
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.
MapType | Type of unordered_map that contains mapped value pairs |
string | String to find/create mapping for. |
dimension | Index of the dimension of the string. |
maps | Unordered map given by the DatasetMapper. |
types | Vector containing the type information about each dimensions. |
Definition at line 69 of file missing_policy.hpp.
References missingSet.
Referenced by MapTokens().
|
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.
eT | Type of armadillo matrix. |
MapType | Type of unordered_map that contains mapped value pairs. |
tokens | Vector of variables inside a dimension. |
row | Position of the given tokens. |
matrix | Matrix to save the data into. |
maps | Maps given by the DatasetMapper class. |
types | Types of each dimensions given by the DatasetMapper class. |
Definition at line 117 of file missing_policy.hpp.
References MapString(), and missingSet.
|
private |
Definition at line 147 of file missing_policy.hpp.
Referenced by MapString(), and MapTokens().