13 #ifndef MLPACK_BINDINGS_PYTHON_CYTHON_IO_UTIL_HPP 14 #define MLPACK_BINDINGS_PYTHON_CYTHON_IO_UTIL_HPP 32 inline void SetParam(util::Params& params,
33 const std::string& identifier,
36 params.Get<T>(identifier) = std::move(value);
51 const std::string& identifier,
55 params.
Get<T*>(identifier) = copy ?
new T(*value) : value;
63 const std::string& identifier,
67 typedef typename std::tuple<data::DatasetInfo, T> TupleType;
68 typedef typename T::elem_type eT;
71 const size_t dimensions = matrix.n_rows;
72 std::get<1>(params.
Get<TupleType>(identifier)) = std::move(matrix);
76 bool hasCategoricals =
false;
77 for (
size_t i = 0; i < dimensions; ++i)
82 hasCategoricals =
true;
89 arma::vec maxs = arma::max(
90 std::get<1>(params.
Get<TupleType>(identifier)), 1);
92 for (
size_t i = 0; i < dimensions; ++i)
97 for (
size_t j = 0; j < (size_t) maxs[i]; ++j)
99 std::ostringstream oss;
114 const std::string& paramName)
116 return params.
Get<T*>(paramName);
124 const std::string& paramName)
127 typedef std::tuple<data::DatasetInfo, T> TupleType;
128 return std::get<1>(params.
Get<TupleType>(paramName));
T MapString(const InputType &input, const size_t dimension)
Given the input and the dimension to which it belongs, return its numeric mapping.
void SetParamPtr(util::Params &p, const std::string &identifier, T *value)
Set the parameter to the given value, given that the type is a pointer.
bool backtrace
If true, on a fatal error, a backtrace will be printed if HAS_BFD_DL is defined.
Auxiliary information for a dataset, including mappings to/from strings (or other types) and the data...
void ResetTimers()
Reset the status of all timers.
Linear algebra utility functions, generally performed on matrices or vectors.
void DisableVerbose()
Turn verbose output off.
bool ignoreInput
Discards input, prints nothing if true.
Datatype Type(const size_t dimension) const
Return the type of a given dimension (numeric or categorical).
void DisableBacktrace()
Disable backtraces.
void SetParam(util::Params &p, const std::string &identifier, T &value)
Set the parameter to the given value.
static MLPACK_EXPORT util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
void EnableTimers()
Enable timing.
static MLPACK_EXPORT util::PrefixedOutStream Info
Prints informational messages if –verbose is specified, prefixed with [INFO ].
DatasetMapper< data::IncrementPolicy > DatasetInfo
T & Get(const std::string &identifier)
Get the value of type T found for the parameter specified by identifier.
static void EnableTiming()
Enable timing of mlpack programs.
static void ResetAll()
Stop and reset all running timers.
void EnableVerbose()
Turn verbose output on.
The Params class holds all information about the parameters passed to a specific binding.
T & GetParamWithInfo(util::Params ¶ms, const std::string ¶mName)
Return the matrix part of a matrix + dataset info parameter.
void SetParamWithInfo(util::Params ¶ms, const std::string &identifier, T &matrix, const bool *dims)
Set the parameter (which is a matrix/DatasetInfo tuple) to the given value.
T * GetParamPtr(util::Params &p, const std::string ¶mName)
Return a pointer.