Classes | |
struct | BindingDetails |
This structure holds all of the information about bindings documentation. More... | |
class | BindingName |
class | Example |
struct | IsStdVector |
Metaprogramming structure for vector detection. More... | |
struct | IsStdVector< std::vector< T, A > > |
Metaprogramming structure for vector detection. More... | |
class | LongDescription |
class | NullOutStream |
Used for Log::Debug when not compiled with debugging symbols. More... | |
struct | ParamData |
This structure holds all of the information about a single parameter, including its value (which is set when ParseCommandLine() is called). More... | |
class | Params |
The Params class holds all information about the parameters passed to a specific binding. More... | |
class | PrefixedOutStream |
Allows us to output to an ostream with a prefix at the beginning of each line, in the same way we would output to cout or cerr. More... | |
class | SeeAlso |
class | ShortDescription |
class | Timers |
Typedefs | |
template < typename T > | |
using | Option = mlpack::bindings::cli::CLIOption< T > |
Functions | |
std::string | CamelCase (std::string s, bool lower) |
Given an snake_case like, e.g., "logistic_regression", return CamelCase(e.g. More... | |
template < typename DataType , typename DimType > | |
void | CheckSameDimensionality (const DataType &data, const DimType &dimension, const std::string &callerDescription, const std::string &addInfo="dataset") |
Check for if the given dataset dimension matches with the model's. More... | |
template < typename DataType > | |
void | CheckSameDimensionality (const DataType &data, const size_t &dimension, const std::string &callerDescription, const std::string &addInfo="dataset") |
An overload of CheckSameDimensionality() where the dimension to be checked is known second param is unsigned long int. More... | |
template < typename DataType , typename LabelsType > | |
void | CheckSameSizes (const DataType &data, const LabelsType &label, const std::string &callerDescription, const std::string &addInfo="labels") |
Check for if the given data points & labels have same size. More... | |
template < typename DataType > | |
void | CheckSameSizes (const DataType &data, const size_t &size, const std::string &callerDescription, const std::string &addInfo="labels") |
An overload of CheckSameSizes() where the size to be checked is known previously. More... | |
void | DisableBacktrace () |
Disable backtraces. More... | |
void | DisableVerbose () |
Turn verbose output off. More... | |
void | EnableTimers () |
Enable timing. More... | |
void | EnableVerbose () |
Turn verbose output on. More... | |
template < typename T > | |
T * | GetParamPtr (util::Params &p, const std::string ¶mName) |
Return a pointer. More... | |
template < typename T > | |
T & | GetParamWithInfo (util::Params ¶ms, const std::string ¶mName) |
Return the matrix part of a matrix + dataset info parameter. More... | |
std::string | GetVersion () |
This will return either "mlpack x.y.z" or "mlpack master-XXXXXXX" depending on whether or not this is a stable version of mlpack or a git repository. More... | |
std::string | HyphenateString (const std::string &str, const std::string &prefix, const bool force=false) |
Hyphenate a string or split it onto multiple 80-character lines, with some amount of padding on each line. More... | |
std::string | HyphenateString (const std::string &str, int padding) |
Hyphenate a string or split it onto multiple 80-character lines, with some amount of padding on each line. More... | |
void | ReportIgnoredParam (util::Params ¶ms, const std::vector< std::pair< std::string, bool >> &constraints, const std::string ¶mName) |
Report that a parameter is ignored, if each of the constraints given are satisfied. More... | |
void | ReportIgnoredParam (const std::string ¶mName, const std::string &reason) |
If the given parameter is passed, report that it is ignored, supplying a custom reason. More... | |
void | RequireAtLeastOnePassed (util::Params ¶ms, const std::vector< std::string > &constraints, const bool fatal=true, const std::string &customErrorMessage="") |
Require that at least one of the given parameters in the constraints set was passed to the IO object; otherwise, issue a warning or fatal error, optionally with the given custom error message. More... | |
void | RequireNoneOrAllPassed (util::Params ¶ms, const std::vector< std::string > &constraints, const bool fatal=true, const std::string &customErrorMessage="") |
Require that either none or all of the given parameters in the constraints set were passed to the IO object; otherwise, issue a warning or fatal error, optionally with the given custom error message. More... | |
void | RequireOnlyOnePassed (util::Params ¶ms, const std::vector< std::string > &constraints, const bool fatal=true, const std::string &customErrorMessage="", const bool allowNone=false) |
Require that only one of the given parameters in the constraints set was passed to the IO object; otherwise, issue a warning or fatal error, optionally with the given custom error message. More... | |
template < typename T > | |
void | RequireParamInSet (util::Params ¶ms, const std::string ¶mName, const std::vector< T > &set, const bool fatal, const std::string &errorMessage) |
Require that a given parameter is in a set of allowable parameters. More... | |
template < typename T > | |
void | RequireParamValue (util::Params ¶ms, const std::string ¶mName, const std::function< bool(T)> &conditional, const bool fatal, const std::string &errorMessage) |
Require that a given parameter satisfies the given conditional function. More... | |
void | ResetTimers () |
Reset the status of all timers. More... | |
template < typename T > | |
void | SetParam (util::Params &p, const std::string &identifier, T &value) |
Set the parameter to the given value. More... | |
template < typename T > | |
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. More... | |
template < typename T > | |
void | SetParamPtr (util::Params ¶ms, const std::string &identifier, T *value, const bool copy) |
Set the parameter to the given value, given that the type is a pointer. More... | |
template < typename T > | |
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. More... | |
std::string | StripType (std::string cppType) |
Given a C++ type name, turn it into something that has no special characters that can simply be printed. More... | |
std::string | ToLower (const std::string &input) |
Convert a string to lowercase letters. More... | |
using Option = mlpack::bindings::tests::TestOption<T> |
Definition at line 70 of file mlpack_main.hpp.
|
inline |
Given an snake_case like, e.g., "logistic_regression", return CamelCase(e.g.
"LogisticRegression") that can be used in bindings.
s | input string. |
lower | is of bool type. If lower is true then output must be lowerCamelCase else UpperCamelCase. |
Definition at line 26 of file camel_case.hpp.
Referenced by mlpack::bindings::go::PrintDefnInput(), mlpack::bindings::go::PrintDoc(), mlpack::bindings::go::PrintInputProcessing(), mlpack::bindings::go::PrintMethodConfig(), mlpack::bindings::go::PrintMethodInit(), and mlpack::bindings::go::PrintOutputProcessing().
|
inline |
Check for if the given dataset dimension matches with the model's.
data | dataset. |
dimension | Dimension of the model. |
callerDescription | A description of the caller that can be used for error generation. |
addInfo | Name to use for dataset for precise error generation. Default is "dataset"; for example, "weights" could also be used. |
Definition at line 78 of file size_checks.hpp.
|
inline |
An overload of CheckSameDimensionality() where the dimension to be checked is known second param is unsigned long int.
Definition at line 99 of file size_checks.hpp.
|
inline |
Check for if the given data points & labels have same size.
data | data. |
labels | Labels. |
callerDescription | A description of the caller that can be used for error generation. |
addInfo | Name to use for labels for precise error generation. Default is "labels"; for example, "weights" could also be used. |
Definition at line 31 of file size_checks.hpp.
Referenced by mlpack::data::Split(), and mlpack::data::StratifiedSplit().
|
inline |
An overload of CheckSameSizes() where the size to be checked is known previously.
The second parameter is of type unsigned int.
Definition at line 51 of file size_checks.hpp.
|
inline |
Disable backtraces.
Definition at line 79 of file io_util.hpp.
References PrefixedOutStream::backtrace, and Log::Fatal.
Referenced by GetParamWithInfo().
|
inline |
Turn verbose output off.
Definition at line 71 of file io_util.hpp.
References PrefixedOutStream::ignoreInput, and Log::Info.
Referenced by GetParamWithInfo().
|
inline |
Enable timing.
Definition at line 92 of file io_util.hpp.
References Timer::EnableTiming().
Referenced by GetParamWithInfo().
|
inline |
Turn verbose output on.
Definition at line 63 of file io_util.hpp.
References PrefixedOutStream::ignoreInput, and Log::Info.
Referenced by GetParamWithInfo().
T * GetParamPtr | ( | util::Params & | params, |
const std::string & | paramName | ||
) |
Return a pointer.
This function exists to work around Cython's seeming lack of support for template pointer types.
Definition at line 55 of file io_util.hpp.
References Params::Get().
Referenced by SetParamWithInfo().
T& mlpack::util::GetParamWithInfo | ( | util::Params & | params, |
const std::string & | paramName | ||
) |
Return the matrix part of a matrix + dataset info parameter.
Definition at line 123 of file io_util.hpp.
References PrefixedOutStream::backtrace, DisableBacktrace(), DisableVerbose(), EnableTimers(), Timer::EnableTiming(), EnableVerbose(), Log::Fatal, Params::Get(), PrefixedOutStream::ignoreInput, Log::Info, Timer::ResetAll(), and ResetTimers().
std::string mlpack::util::GetVersion | ( | ) |
This will return either "mlpack x.y.z" or "mlpack master-XXXXXXX" depending on whether or not this is a stable version of mlpack or a git repository.
Referenced by mlpack::bindings::cli::ParseCommandLine().
|
inline |
Hyphenate a string or split it onto multiple 80-character lines, with some amount of padding on each line.
This is used for option output.
str | String to hyphenate (splits are on ' '). |
prefix | Prefix to hyphenate a string with. |
force | Hyphenate the string even if the length is less then 80. |
std::invalid_argument | if prefix.size() >= 80. |
Definition at line 27 of file hyphenate_string.hpp.
Referenced by HyphenateString(), mlpack::bindings::python::PrintDoc(), mlpack::bindings::r::PrintDoc(), and mlpack::bindings::go::PrintDoc().
|
inline |
Hyphenate a string or split it onto multiple 80-character lines, with some amount of padding on each line.
This is used for option output.
str | String to hyphenate (splits are on ' '). |
padding | Amount of padding on the left for each new line. |
Definition at line 82 of file hyphenate_string.hpp.
References HyphenateString().
void mlpack::util::ReportIgnoredParam | ( | util::Params & | params, |
const std::vector< std::pair< std::string, bool >> & | constraints, | ||
const std::string & | paramName | ||
) |
Report that a parameter is ignored, if each of the constraints given are satisfied.
The constraints should be a set of string/bool pairs. If all of the constraints are true, and the given parameter in 'paramName' is passed, then a warning will be issued noting that the parameter is ignored. The warning will go to Log::Warn.
params | Set of parameters to check. |
constraints | Set of constraints. |
paramName | Name of parameter to check. |
void mlpack::util::ReportIgnoredParam | ( | const std::string & | paramName, |
const std::string & | reason | ||
) |
If the given parameter is passed, report that it is ignored, supplying a custom reason.
The reason should specify, in short and clear terms, why the parameter is ignored. So, for example, the output may be similar to:
and in this case a good reason might be "SGD is not being used as an optimizer". Be sure that when you write the reason, the full message makes sense.
paramName | Name of parameter to check. |
reason | Reason that parameter is ignored, if it is passed. |
void mlpack::util::RequireAtLeastOnePassed | ( | util::Params & | params, |
const std::vector< std::string > & | constraints, | ||
const bool | fatal = true , |
||
const std::string & | customErrorMessage = "" |
||
) |
Require that at least one of the given parameters in the constraints set was passed to the IO object; otherwise, issue a warning or fatal error, optionally with the given custom error message.
This uses the correct binding type name for each parameter (i.e. '–parameter' for CLI bindings, 'parameter' for Python bindings).
This can be used with a set of only one constraint and the output is still sensible.
If you use a custom error message, be aware that the given output will be similar to, for example:
so when you write your custom error message, be sure that the sentence makes sense. The custom error message should not have a capitalized first character and no ending punctuation (a '!' will be added by this function).
params | Set of parameters to check. |
constraints | Set of parameters from which only one should be passed. |
fatal | If true, output goes to Log::Fatal instead of Log::Warn and an exception is thrown. |
customErrorMessage | Error message to append. |
void mlpack::util::RequireNoneOrAllPassed | ( | util::Params & | params, |
const std::vector< std::string > & | constraints, | ||
const bool | fatal = true , |
||
const std::string & | customErrorMessage = "" |
||
) |
Require that either none or all of the given parameters in the constraints set were passed to the IO object; otherwise, issue a warning or fatal error, optionally with the given custom error message.
This uses the correct binding type name for each parameter (i.e. '–parameter' for CLI bindings, 'parameter' for Python bindings).
If you use a custom error message, be aware that the given output will be similar to, for example:
so when you write your custom error message, be sure that the sentence makes sense. The custom error message should not have a capitalized first character and no ending punctuation (a '!' will be added by this function).
params | Set of parameters to check. |
constraints | Set of parameters of which none or all should be passed. |
fatal | If true, output goes to Log::Fatal instead of Log::Warn and an exception is thrown. |
customErrorMessage | Error message to append. |
void mlpack::util::RequireOnlyOnePassed | ( | util::Params & | params, |
const std::vector< std::string > & | constraints, | ||
const bool | fatal = true , |
||
const std::string & | customErrorMessage = "" , |
||
const bool | allowNone = false |
||
) |
Require that only one of the given parameters in the constraints set was passed to the IO object; otherwise, issue a warning or fatal error, optionally with the given custom error message.
This uses the correct binding type name for each parameter (i.e. '–parameter' for CLI bindings, 'parameter' for Python bindings).
If you use a custom error message, be aware that the given output will be similar to, for example:
so when you write your custom error message, be sure that the sentence makes sense. The custom error message should not have a capitalized first character and no ending punctuation (a '!' will be added by this function).
params | Set of parameters to check. |
constraints | Set of parameters from which only one should be passed. |
fatal | If true, output goes to Log::Fatal instead of Log::Warn and an exception is thrown. |
customErrorMessage | Error message to append. |
allowNone | If true, then no error message will be thrown if none of the parameters in the constraints were passed. |
void mlpack::util::RequireParamInSet | ( | util::Params & | params, |
const std::string & | paramName, | ||
const std::vector< T > & | set, | ||
const bool | fatal, | ||
const std::string & | errorMessage | ||
) |
Require that a given parameter is in a set of allowable parameters.
This is probably most useful with T = std::string. If fatal is true, then an exception is thrown. An error message is not optional and must be specified. The error message does not need to specify the values in the set; this function will already output them. So, for example, the output may be similar to:
so when you write the error message, make sure that the message makes sense. For example, in the message above, a good error message might be "unknown weak learner type".
T | Type of parameter. |
params | Set of parameters to check. |
paramName | Name of parameter to check. |
set | Set of valid values for parameter. |
fatal | If true, an exception is thrown and output goes to Log::Fatal. |
errorMessage | Error message to output. |
void mlpack::util::RequireParamValue | ( | util::Params & | params, |
const std::string & | paramName, | ||
const std::function< bool(T)> & | conditional, | ||
const bool | fatal, | ||
const std::string & | errorMessage | ||
) |
Require that a given parameter satisfies the given conditional function.
This is useful for, e.g., checking that a given parameter is greater than 0. If fatal is true, then an exception is thrown. An error message is not optional and must be specified. The error message should specify, in clear terms, what the value of the parameter should be. So, for example, the output may be similar to:
and in this case a good error message might be "number of iterations must be positive". Be sure that when you write the error message, the message makes sense.
T | Type of parameter to check. |
params | Set of parameters to check. |
paramName | Name of parameter to check. |
conditional | Function to use to check parameter value; should return 'true' if the parameter value is okay. |
fatal | If true, an exception is thrown and output goes to Log::Fatal. |
errorMessage | Error message to output. |
|
inline |
Reset the status of all timers.
Definition at line 84 of file io_util.hpp.
References Timer::ResetAll().
Referenced by GetParamWithInfo().
|
inline |
Set the parameter to the given value.
identifier | Name of parameter. |
value | Value to set parameter to. |
This function exists to work around Cython's lack of support for lvalue references.
identifier | Name of parameter. |
value | Value to set parameter to. |
Definition at line 29 of file io_util.hpp.
References Params::Get().
|
inline |
Set the parameter to the given value, given that the type is a pointer.
identifier | Name of parameter. |
value | Value to set parameter to. |
Definition at line 43 of file io_util.hpp.
References Params::Get().
|
inline |
Set the parameter to the given value, given that the type is a pointer.
This function exists to work around both Cython's lack of support for lvalue references and also its seeming lack of support for template pointer types.
identifier | Name of parameter. |
value | Value to set parameter to. |
copy | Whether or not the object should be copied. |
Definition at line 50 of file io_util.hpp.
References Params::Get().
|
inline |
Set the parameter (which is a matrix/DatasetInfo tuple) to the given value.
Definition at line 62 of file io_util.hpp.
References mlpack::data::categorical, Params::Get(), GetParamPtr(), DatasetMapper< PolicyType, InputType >::MapString(), and DatasetMapper< PolicyType, InputType >::Type().
|
inline |
Given a C++ type name, turn it into something that has no special characters that can simply be printed.
This is similar to but not identical to mlpack::util::StripType().
cppType | C++ type as a string. |
Definition at line 27 of file strip_type.hpp.
Referenced by mlpack::bindings::julia::GetJuliaType(), mlpack::bindings::r::GetRType(), mlpack::bindings::r::PrintInputProcessing(), mlpack::bindings::julia::PrintModelTypeImport(), mlpack::bindings::julia::PrintParamDefn(), and mlpack::bindings::r::PrintSerializeUtil().
|
inline |
Convert a string to lowercase letters.
input | The string to convert. |
Definition at line 23 of file to_lower.hpp.