12 #ifndef MLPACK_CORE_DATA_MAP_POLICIES_MISSING_POLICY_HPP 13 #define MLPACK_CORE_DATA_MAP_POLICIES_MISSING_POLICY_HPP 16 #include <unordered_map> 17 #include <boost/bimap.hpp> 49 missingSet(
std::move(missingSet))
68 template <
typename MapType>
70 const size_t dimension,
72 std::vector<Datatype>& types)
79 const double NaN = std::numeric_limits<double>::quiet_NaN();
81 (maps.count(dimension) == 0 ||
82 maps[dimension].first.left.count(
string) == 0))
85 typedef boost::bimap<std::string, MappedType>::value_type PairType;
86 maps[dimension].first.insert(PairType(
string, NaN));
88 size_t& numMappings = maps[dimension].second;
116 template <
typename eT,
typename MapType>
119 arma::Mat<eT>& matrix,
121 std::vector<Datatype>& types)
124 static_assert(std::is_same<eT, double>::value,
"You must use double type " 125 " matrix in order to apply MissingPolicy");
127 std::stringstream token;
128 for (
size_t i = 0; i != tokens.size(); ++i)
130 token.str(tokens[i]);
131 token>>matrix.at(row, i);
136 const eT val =
static_cast<eT
>(this->
MapString(tokens[i], row, maps,
138 matrix.at(row, i) = val;
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
MissingPolicy(std::set< std::string > missingSet)
Create the MissingPolicy object with the given missingSet.
std::set< std::string > missingSet
MappedType MapString(const std::string &string, const size_t dimension, MapType &maps, std::vector< Datatype > &types)
Given the string and the dimension to which it belongs by the user, and the maps and types given by t...
test cpp RESULT_VARIABLE MEX_RESULT_TRASH OUTPUT_VARIABLE MEX_OUTPUT ERROR_VARIABLE MEX_ERROR_TRASH string(REGEX MATCH"Warning: You are using"MEX_WARNING"${MEX_OUTPUT}") if(MEX_WARNING) string(REGEX REPLACE".*using [a-zA-Z]* version \"([0-9.]*)[^\"]*\".*""\\1"OTHER_COMPILER_VERSION"$
void MapTokens(const std::vector< std::string > &tokens, size_t &row, arma::Mat< eT > &matrix, MapType &maps, std::vector< Datatype > &types)
MapTokens turns vector of strings into numeric variables and puts them into a given matrix...
MissingPolicy is used as a helper class for DatasetMapper.