mlpack  2.2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Attributes | List of all members
IncrementPolicy Class Reference

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

Public Types

using MappedType = size_t
 

Public Member Functions

template<typename T >
void MapFirstPass (const std::string &string, const size_t dim, std::vector< Datatype > &types)
 Determine if the dimension is numeric or categorical. More...
 
template<typename MapType , typename T >
MapString (const std::string &string, const size_t dimension, MapType &maps, std::vector< Datatype > &types)
 Given the string and the dimension to which the it belongs, 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...
 

Static Public Attributes

static const bool NeedsFirstPass = true
 We do need a first pass over the data to set the dimension types right. More...
 

Detailed Description

IncrementPolicy is used as a helper class for DatasetMapper.

It tells how the strings should be mapped. Purpose of this policy is to map all dimension if one if the variables in a dimension turns out to be a categorical variable. IncrementPolicy maps strings to incrementing unsigned integers (size_t). The first string to be mapped will be mapped to 0, the next to 1 and so on.

Definition at line 29 of file increment_policy.hpp.

Member Typedef Documentation

using MappedType = size_t

Definition at line 33 of file increment_policy.hpp.

Member Function Documentation

void MapFirstPass ( const std::string &  string,
const size_t  dim,
std::vector< Datatype > &  types 
)
inline

Determine if the dimension is numeric or categorical.

Definition at line 42 of file increment_policy.hpp.

References mlpack::data::categorical.

T MapString ( const std::string &  string,
const size_t  dimension,
MapType &  maps,
std::vector< Datatype > &  types 
)
inline

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

If no mapping yet exists, 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 81 of file increment_policy.hpp.

References mlpack::data::categorical, and mlpack::data::numeric.

Referenced by IncrementPolicy::MapTokens().

void 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, all the tokens 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 146 of file increment_policy.hpp.

References IncrementPolicy::MapString().

Member Data Documentation

const bool NeedsFirstPass = true
static

We do need a first pass over the data to set the dimension types right.

Definition at line 36 of file increment_policy.hpp.


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