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

Public Types

using MappedType = size_t
 

Public Member Functions

 IncrementPolicy (const bool forceAllMappings=false)
 
template
<
typename
T
,
typename
InputType
>
void MapFirstPass (const InputType &input, const size_t dim, std::vector< Datatype > &types)
 Determine if the dimension is numeric or categorical. More...

 
template
<
typename
MapType
,
typename
T
,
typename
InputType
>
MapString (const InputType &input, const size_t dimension, MapType &maps, std::vector< Datatype > &types)
 Given the input and the dimension to which the it belongs, and the maps and types given by the DatasetMapper class, returns its numeric mapping. 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 of the variables in a dimension turns out to be a categorical variable. IncrementPolicy maps strings to incrementing unsigned integers (size_t). The first input to be mapped will be mapped to 0, the next to 1 and so on.

If the 'forceAllMappings' parameter is set to true, this will always map. Otherwise, inputs will only be mapped if they cannot be cast to the output type via a stringstream extraction.

Definition at line 33 of file increment_policy.hpp.

Member Typedef Documentation

◆ MappedType

using MappedType = size_t

Definition at line 40 of file increment_policy.hpp.

Constructor & Destructor Documentation

◆ IncrementPolicy()

IncrementPolicy ( const bool  forceAllMappings = false)
inline

Definition at line 36 of file increment_policy.hpp.

Member Function Documentation

◆ MapFirstPass()

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

Determine if the dimension is numeric or categorical.

Definition at line 49 of file increment_policy.hpp.

References mlpack::data::categorical.

◆ MapString()

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

Given the input 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 input 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
inputInput to find/create mapping for.
dimensionIndex of the dimension of the input.
mapsUnordered map given by the DatasetMapper.
typesVector containing the type information about each dimensions.

Definition at line 90 of file increment_policy.hpp.

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

Member Data Documentation

◆ NeedsFirstPass

const bool NeedsFirstPass = true
static

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

Definition at line 43 of file increment_policy.hpp.


The documentation for this class was generated from the following file:
  • /home/jenkins-mlpack/mlpack.org/_src/mlpack-git/src/mlpack/core/data/map_policies/increment_policy.hpp