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))
82 template<
typename MapType,
typename T>
84 const size_t dimension,
86 std::vector<Datatype>& )
88 static_assert(std::numeric_limits<T>::has_quiet_NaN ==
true,
89 "Cannot use MissingPolicy with types where has_quiet_NaN() is false!");
92 std::stringstream token;
97 MappedType value = std::numeric_limits<MappedType>::quiet_NaN();
101 std::numeric_limits<MappedType>::max(),
MappedType(0));
105 if (token.fail() || !token.eof() ||
106 missingSet.find(
string) != std::end(missingSet))
110 if (maps.count(dimension) == 0 ||
111 maps[dimension].first.count(
string) == 0)
114 typedef std::pair<std::string, MappedType> PairType;
115 maps[dimension].first.insert(PairType(
string, value));
118 if (maps[dimension].second.count(mapValue) == 0)
121 maps[dimension].second.insert(std::make_pair(mapValue,
122 std::vector<std::string>()));
124 maps[dimension].second[mapValue].push_back(
string);
140 std::set<std::string> missingSet;
Linear algebra utility functions, generally performed on matrices or vectors.
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.