12#ifndef MLPACK_CORE_DATA_MAP_POLICIES_MISSING_POLICY_HPP
13#define MLPACK_CORE_DATA_MAP_POLICIES_MISSING_POLICY_HPP
16#include <unordered_map>
50 missingSet(
std::move(missingSet))
83 template<
typename MapType,
typename T>
85 const size_t dimension,
87 std::vector<Datatype>& )
89 static_assert(std::numeric_limits<T>::has_quiet_NaN ==
true,
90 "Cannot use MissingPolicy with types where has_quiet_NaN() is false!");
93 std::stringstream token;
98 MappedType value = std::numeric_limits<MappedType>::quiet_NaN();
102 std::numeric_limits<MappedType>::max(),
MappedType(0));
106 if (token.fail() || !token.eof() ||
107 missingSet.find(
string) != std::end(missingSet))
111 if (maps.count(dimension) == 0 ||
112 maps[dimension].first.count(
string) == 0)
115 typedef std::pair<std::string, MappedType> PairType;
116 maps[dimension].first.insert(PairType(
string, value));
119 if (maps[dimension].second.count(mapValue) == 0)
122 maps[dimension].second.insert(std::make_pair(mapValue,
123 std::vector<std::string>()));
125 maps[dimension].second[mapValue].push_back(
string);
141 std::set<std::string> missingSet;
MissingPolicy is used as a helper class for DatasetMapper.
void MapFirstPass(const std::string &, const size_t)
There is nothing for us to do here, but this is required by the MapPolicy type.
MissingPolicy(std::set< std::string > missingSet)
Create the MissingPolicy object with the given missingSet.
static const bool NeedsFirstPass
This doesn't need a first pass over the data to set up.
T MapString(const std::string &string, const size_t dimension, MapType &maps, std::vector< Datatype > &)
Given the string and the dimension to which it belongs by the user, and the maps and types given by t...
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.