12 #ifndef MLPACK_CORE_DATA_MAP_POLICIES_INCREMENT_POLICY_HPP 13 #define MLPACK_CORE_DATA_MAP_POLICIES_INCREMENT_POLICY_HPP 16 #include <unordered_map> 37 forceAllMappings(forceAllMappings) { }
48 template<
typename T,
typename InputType>
51 std::vector<Datatype>& types)
66 std::stringstream token;
71 if (token.fail() || !token.eof())
89 template<
typename MapType,
typename T,
typename InputType>
91 const size_t dimension,
93 std::vector<Datatype>& types)
101 std::stringstream token;
106 if (!token.fail() && token.eof())
115 if (maps.count(dimension) == 0 ||
116 maps[dimension].first.count(input) == 0)
119 size_t numMappings = maps[dimension].first.size();
122 if (numMappings == 0)
125 typedef typename std::pair<InputType, MappedType> PairType;
126 maps[dimension].first.insert(PairType(input, numMappings));
129 if (maps[dimension].second.count(numMappings) == 0)
131 maps[dimension].second.insert(std::make_pair(numMappings,
132 std::vector<InputType>()));
134 maps[dimension].second[numMappings].push_back(input);
136 return T(numMappings);
141 return maps[dimension].first.at(input);
147 bool forceAllMappings;
IncrementPolicy is used as a helper class for DatasetMapper.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
T 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 Datase...
static const bool NeedsFirstPass
We do need a first pass over the data to set the dimension types right.
IncrementPolicy(const bool forceAllMappings=false)
void MapFirstPass(const InputType &input, const size_t dim, std::vector< Datatype > &types)
Determine if the dimension is numeric or categorical.