12 #ifndef MLPACK_CORE_DATA_MAP_POLICIES_MISSING_POLICY_HPP 13 #define MLPACK_CORE_DATA_MAP_POLICIES_MISSING_POLICY_HPP 16 #include <unordered_map> 49 missingSet(
std::move(missingSet))
81 template<
typename MapType,
typename T>
83 const size_t dimension,
85 std::vector<Datatype>& )
87 static_assert(std::numeric_limits<T>::has_quiet_NaN ==
true,
88 "Cannot use MissingPolicy with types where has_quiet_NaN() is false!");
91 std::stringstream token;
96 MappedType value = std::numeric_limits<MappedType>::quiet_NaN();
100 std::numeric_limits<MappedType>::max(),
MappedType(0));
104 if (token.fail() || !token.eof() ||
105 missingSet.find(
string) != std::end(missingSet))
109 if (maps.count(dimension) == 0 ||
110 maps[dimension].first.count(
string) == 0)
113 typedef std::pair<std::string, MappedType> PairType;
114 maps[dimension].first.insert(PairType(
string, value));
117 if (maps[dimension].second.count(mapValue) == 0)
120 maps[dimension].second.insert(std::make_pair(mapValue,
121 std::vector<std::string>()));
123 maps[dimension].second[mapValue].push_back(
string);
139 std::set<std::string> missingSet;
The core includes that mlpack expects; standard C++ includes and Armadillo.
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...
void MapFirstPass(const std::string &, const size_t)
There is nothing for us to do here, but this is required by the MapPolicy type.
static const bool NeedsFirstPass
This doesn't need a first pass over the data to set up.
MissingPolicy(std::set< std::string > missingSet)
Create the MissingPolicy object with the given missingSet.
MissingPolicy is used as a helper class for DatasetMapper.