\section{mlpack\+:\+:data Namespace Reference}
\label{namespacemlpack_1_1data}\index{mlpack\+::data@{mlpack\+::data}}


Functions to load and save matrices and models.  


\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
class \textbf{ Bag\+Of\+Words\+Encoding\+Policy}
\begin{DoxyCompactList}\small\item\em Definition of the \doxyref{Bag\+Of\+Words\+Encoding\+Policy}{p.}{classmlpack_1_1data_1_1BagOfWordsEncodingPolicy} class. \end{DoxyCompactList}\item 
class \textbf{ Char\+Extract}
\begin{DoxyCompactList}\small\item\em The class is used to split a string into characters. \end{DoxyCompactList}\item 
class \textbf{ Custom\+Imputation}
\begin{DoxyCompactList}\small\item\em A simple custom imputation class. \end{DoxyCompactList}\item 
class \textbf{ Dataset\+Mapper}
\begin{DoxyCompactList}\small\item\em Auxiliary information for a dataset, including mappings to/from strings (or other types) and the datatype of each dimension. \end{DoxyCompactList}\item 
class \textbf{ Dictionary\+Encoding\+Policy}
\begin{DoxyCompactList}\small\item\em Dicitonary\+Enocding\+Policy is used as a helper class for \doxyref{String\+Encoding}{p.}{classmlpack_1_1data_1_1StringEncoding}. \end{DoxyCompactList}\item 
struct \textbf{ Has\+Serialize}
\item 
struct \textbf{ Has\+Serialize\+Function}
\item 
class \textbf{ Image\+Info}
\begin{DoxyCompactList}\small\item\em Implements meta-\/data of images required by \doxyref{data\+::\+Load}{p.}{namespacemlpack_1_1data_a19805d6585ac8b0be7c4e4b7f081977c} and \doxyref{data\+::\+Save}{p.}{namespacemlpack_1_1data_a16bc794b14db0ab126595b19a32a5bc0} for loading and saving images into arma\+::\+Mat. \end{DoxyCompactList}\item 
class \textbf{ Imputer}
\begin{DoxyCompactList}\small\item\em Given a dataset of a particular datatype, replace user-\/specified missing value with a variable dependent on the Strategy\+Type and Mapper\+Type. \end{DoxyCompactList}\item 
class \textbf{ Increment\+Policy}
\begin{DoxyCompactList}\small\item\em \doxyref{Increment\+Policy}{p.}{classmlpack_1_1data_1_1IncrementPolicy} is used as a helper class for \doxyref{Dataset\+Mapper}{p.}{classmlpack_1_1data_1_1DatasetMapper}. \end{DoxyCompactList}\item 
class \textbf{ Listwise\+Deletion}
\begin{DoxyCompactList}\small\item\em A complete-\/case analysis to remove the values containing mapped\+Value. \end{DoxyCompactList}\item 
class \textbf{ Load\+C\+SV}
\begin{DoxyCompactList}\small\item\em Load the csv file.\+This class use boost\+::spirit to implement the parser, please refer to following link {\tt http\+://theboostcpplibraries.\+com/boost.\+spirit} for quick review. \end{DoxyCompactList}\item 
class \textbf{ Max\+Abs\+Scaler}
\begin{DoxyCompactList}\small\item\em A simple Max\+Abs Scaler class. \end{DoxyCompactList}\item 
class \textbf{ Mean\+Imputation}
\begin{DoxyCompactList}\small\item\em A simple mean imputation class. \end{DoxyCompactList}\item 
class \textbf{ Mean\+Normalization}
\begin{DoxyCompactList}\small\item\em A simple Mean Normalization class. \end{DoxyCompactList}\item 
class \textbf{ Median\+Imputation}
\begin{DoxyCompactList}\small\item\em This is a class implementation of simple median imputation. \end{DoxyCompactList}\item 
class \textbf{ Min\+Max\+Scaler}
\begin{DoxyCompactList}\small\item\em A simple Min\+Max Scaler class. \end{DoxyCompactList}\item 
class \textbf{ Missing\+Policy}
\begin{DoxyCompactList}\small\item\em \doxyref{Missing\+Policy}{p.}{classmlpack_1_1data_1_1MissingPolicy} is used as a helper class for \doxyref{Dataset\+Mapper}{p.}{classmlpack_1_1data_1_1DatasetMapper}. \end{DoxyCompactList}\item 
class \textbf{ P\+C\+A\+Whitening}
\begin{DoxyCompactList}\small\item\em A simple \doxyref{P\+C\+A\+Whitening}{p.}{classmlpack_1_1data_1_1PCAWhitening} class. \end{DoxyCompactList}\item 
class \textbf{ Scaling\+Model}
\begin{DoxyCompactList}\small\item\em The model to save to disk. \end{DoxyCompactList}\item 
class \textbf{ Split\+By\+Any\+Of}
\begin{DoxyCompactList}\small\item\em The \doxyref{Split\+By\+Any\+Of}{p.}{classmlpack_1_1data_1_1SplitByAnyOf} class tokenizes a string using a set of delimiters. \end{DoxyCompactList}\item 
class \textbf{ Standard\+Scaler}
\begin{DoxyCompactList}\small\item\em A simple Standard Scaler class. \end{DoxyCompactList}\item 
class \textbf{ String\+Encoding}
\begin{DoxyCompactList}\small\item\em The class translates a set of strings into numbers using various encoding algorithms. \end{DoxyCompactList}\item 
class \textbf{ String\+Encoding\+Dictionary}
\begin{DoxyCompactList}\small\item\em This class provides a dictionary interface for the purpose of string encoding. \end{DoxyCompactList}\item 
class \textbf{ String\+Encoding\+Dictionary$<$ boost\+::string\+\_\+view $>$}
\item 
class \textbf{ String\+Encoding\+Dictionary$<$ int $>$}
\item 
struct \textbf{ String\+Encoding\+Policy\+Traits}
\begin{DoxyCompactList}\small\item\em This is a template struct that provides some information about various encoding policies. \end{DoxyCompactList}\item 
struct \textbf{ String\+Encoding\+Policy\+Traits$<$ Dictionary\+Encoding\+Policy $>$}
\begin{DoxyCompactList}\small\item\em The specialization provides some information about the dictionary encoding policy. \end{DoxyCompactList}\item 
class \textbf{ Tf\+Idf\+Encoding\+Policy}
\begin{DoxyCompactList}\small\item\em Definition of the \doxyref{Tf\+Idf\+Encoding\+Policy}{p.}{classmlpack_1_1data_1_1TfIdfEncodingPolicy} class. \end{DoxyCompactList}\item 
class \textbf{ Z\+C\+A\+Whitening}
\begin{DoxyCompactList}\small\item\em A simple \doxyref{Z\+C\+A\+Whitening}{p.}{classmlpack_1_1data_1_1ZCAWhitening} class. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$typename Token\+Type $>$ }\\using \textbf{ Bag\+Of\+Words\+Encoding} = \textbf{ String\+Encoding}$<$ \textbf{ Bag\+Of\+Words\+Encoding\+Policy}, \textbf{ String\+Encoding\+Dictionary}$<$ Token\+Type $>$ $>$
\begin{DoxyCompactList}\small\item\em A convenient alias for the \doxyref{String\+Encoding}{p.}{classmlpack_1_1data_1_1StringEncoding} class with \doxyref{Bag\+Of\+Words\+Encoding\+Policy}{p.}{classmlpack_1_1data_1_1BagOfWordsEncodingPolicy} and the default dictionary for the given token type. \end{DoxyCompactList}\item 
using \textbf{ Dataset\+Info} = \textbf{ Dataset\+Mapper}$<$ \textbf{ data\+::\+Increment\+Policy} $>$
\item 
{\footnotesize template$<$typename Token\+Type $>$ }\\using \textbf{ Dictionary\+Encoding} = \textbf{ String\+Encoding}$<$ \textbf{ Dictionary\+Encoding\+Policy}, \textbf{ String\+Encoding\+Dictionary}$<$ Token\+Type $>$ $>$
\begin{DoxyCompactList}\small\item\em A convenient alias for the \doxyref{String\+Encoding}{p.}{classmlpack_1_1data_1_1StringEncoding} class with \doxyref{Dictionary\+Encoding\+Policy}{p.}{classmlpack_1_1data_1_1DictionaryEncodingPolicy} and the default dictionary for the given token type. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Token\+Type $>$ }\\using \textbf{ Tf\+Idf\+Encoding} = \textbf{ String\+Encoding}$<$ \textbf{ Tf\+Idf\+Encoding\+Policy}, \textbf{ String\+Encoding\+Dictionary}$<$ Token\+Type $>$ $>$
\begin{DoxyCompactList}\small\item\em A convenient alias for the \doxyref{String\+Encoding}{p.}{classmlpack_1_1data_1_1StringEncoding} class with \doxyref{Tf\+Idf\+Encoding\+Policy}{p.}{classmlpack_1_1data_1_1TfIdfEncodingPolicy} and the default dictionary for the given token type. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ Datatype} \+: bool \{ \newline
\textbf{ numeric} = 0, 
\newline
\textbf{ categorical} = 1
 \}\begin{DoxyCompactList}\small\item\em The Datatype enum specifies the types of data mlpack algorithms can use. \end{DoxyCompactList}
\item 
enum \textbf{ format} \{ \newline
\textbf{ autodetect}, 
\newline
\textbf{ text}, 
\newline
\textbf{ xml}, 
\newline
\textbf{ binary}
 \}\begin{DoxyCompactList}\small\item\em Define the formats we can read through \doxyref{boost\+::serialization}{p.}{namespaceboost_1_1serialization}. \end{DoxyCompactList}
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$typename T $>$ }\\void \textbf{ Binarize} (const arma\+::\+Mat$<$ T $>$ \&input, arma\+::\+Mat$<$ T $>$ \&output, const double threshold)
\begin{DoxyCompactList}\small\item\em Given an input dataset and threshold, set values greater than threshold to 1 and values less than or equal to the threshold to 0. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename T $>$ }\\void \textbf{ Binarize} (const arma\+::\+Mat$<$ T $>$ \&input, arma\+::\+Mat$<$ T $>$ \&output, const double threshold, const size\+\_\+t dimension)
\begin{DoxyCompactList}\small\item\em Given an input dataset and threshold, set values greater than threshold to 1 and values less than or equal to the threshold to 0. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename eT $>$ }\\void \textbf{ Confusion\+Matrix} (const arma\+::\+Row$<$ size\+\_\+t $>$ predictors, const arma\+::\+Row$<$ size\+\_\+t $>$ responses, arma\+::\+Mat$<$ eT $>$ \&output, const size\+\_\+t num\+Classes)
\begin{DoxyCompactList}\small\item\em A confusion matrix is a summary of prediction results on a classification problem. \end{DoxyCompactList}\item 
std\+::string \textbf{ Extension} (const std\+::string \&filename)
\item 
\textbf{ H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM} (serialize, Has\+Serialize\+Check)
\item 
bool \textbf{ Image\+Format\+Supported} (const std\+::string \&file\+Name, const bool save=false)
\begin{DoxyCompactList}\small\item\em Checks if the given image filename is supported. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename T $>$ }\\bool \textbf{ Is\+Na\+N\+Inf} (T \&val, const std\+::string \&token)
\begin{DoxyCompactList}\small\item\em See if the token is a NaN or an Inf, and if so, set the value accordingly and return a boolean representing whether or not it is. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename eT $>$ }\\bool \textbf{ Load} (const std\+::string \&filename, arma\+::\+Mat$<$ eT $>$ \&matrix, const bool fatal=false, const bool transpose=true)
\begin{DoxyCompactList}\small\item\em Loads a matrix from file, guessing the filetype from the extension. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename eT $>$ }\\bool \textbf{ Load} (const std\+::string \&filename, arma\+::\+Col$<$ eT $>$ \&vec, const bool fatal=false)
\begin{DoxyCompactList}\small\item\em Don\textquotesingle{}t document these with doxygen; these declarations aren\textquotesingle{}t helpful to users. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename eT $>$ }\\bool \textbf{ Load} (const std\+::string \&filename, arma\+::\+Row$<$ eT $>$ \&rowvec, const bool fatal=false)
\begin{DoxyCompactList}\small\item\em Load a row vector from a file, guessing the filetype from the extension. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename eT , typename Policy\+Type $>$ }\\bool \textbf{ Load} (const std\+::string \&filename, arma\+::\+Mat$<$ eT $>$ \&matrix, \textbf{ Dataset\+Mapper}$<$ Policy\+Type $>$ \&info, const bool fatal=false, const bool transpose=true)
\begin{DoxyCompactList}\small\item\em Loads a matrix from a file, guessing the filetype from the extension and mapping categorical features with a \doxyref{Dataset\+Mapper}{p.}{classmlpack_1_1data_1_1DatasetMapper} object. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename T $>$ }\\bool \textbf{ Load} (const std\+::string \&filename, const std\+::string \&name, T \&t, const bool fatal=false, \textbf{ format} f=format\+::autodetect)
\begin{DoxyCompactList}\small\item\em Don\textquotesingle{}t document these with doxygen; they aren\textquotesingle{}t helpful for users to know about. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename eT $>$ }\\bool \textbf{ Load} (const std\+::string \&filename, arma\+::\+Mat$<$ eT $>$ \&matrix, \textbf{ Image\+Info} \&info, const bool fatal=false)
\begin{DoxyCompactList}\small\item\em Image load/save interfaces. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename eT $>$ }\\bool \textbf{ Load} (const std\+::vector$<$ std\+::string $>$ \&files, arma\+::\+Mat$<$ eT $>$ \&matrix, \textbf{ Image\+Info} \&info, const bool fatal=false)
\begin{DoxyCompactList}\small\item\em Load the image file into the given matrix. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename eT $>$ }\\void \textbf{ Load\+A\+R\+FF} (const std\+::string \&filename, arma\+::\+Mat$<$ eT $>$ \&matrix)
\begin{DoxyCompactList}\small\item\em A utility function to load an A\+R\+FF dataset as numeric features (that is, as an Armadillo matrix without any modification). \end{DoxyCompactList}\item 
{\footnotesize template$<$typename eT , typename Policy\+Type $>$ }\\void \textbf{ Load\+A\+R\+FF} (const std\+::string \&filename, arma\+::\+Mat$<$ eT $>$ \&matrix, \textbf{ Dataset\+Mapper}$<$ Policy\+Type $>$ \&info)
\begin{DoxyCompactList}\small\item\em A utility function to load an A\+R\+FF dataset as numeric and categorical features, using the Dataset\+Info structure for mapping. \end{DoxyCompactList}\item 
bool \textbf{ Load\+Image} (const std\+::string \&filename, arma\+::\+Mat$<$ unsigned char $>$ \&matrix, \textbf{ Image\+Info} \&info, const bool fatal=false)
\item 
{\footnotesize template$<$typename eT , typename Row\+Type $>$ }\\void \textbf{ Normalize\+Labels} (const Row\+Type \&labels\+In, arma\+::\+Row$<$ size\+\_\+t $>$ \&labels, arma\+::\+Col$<$ eT $>$ \&mapping)
\begin{DoxyCompactList}\small\item\em Given a set of labels of a particular datatype, convert them to unsigned labels in the range [0, n) where n is the number of different labels. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename eT , typename Row\+Type $>$ }\\void \textbf{ One\+Hot\+Encoding} (const Row\+Type \&labels\+In, arma\+::\+Mat$<$ eT $>$ \&output)
\begin{DoxyCompactList}\small\item\em Given a set of labels of a particular datatype, convert them to binary vector. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename eT $>$ }\\void \textbf{ Revert\+Labels} (const arma\+::\+Row$<$ size\+\_\+t $>$ \&labels, const arma\+::\+Col$<$ eT $>$ \&mapping, arma\+::\+Row$<$ eT $>$ \&labels\+Out)
\begin{DoxyCompactList}\small\item\em Given a set of labels that have been mapped to the range [0, n), map them back to the original labels given by the \textquotesingle{}mapping\textquotesingle{} vector. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename eT $>$ }\\bool \textbf{ Save} (const std\+::string \&filename, const arma\+::\+Mat$<$ eT $>$ \&matrix, const bool fatal=false, bool transpose=true)
\begin{DoxyCompactList}\small\item\em Saves a matrix to file, guessing the filetype from the extension. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename T $>$ }\\bool \textbf{ Save} (const std\+::string \&filename, const std\+::string \&name, T \&t, const bool fatal=false, \textbf{ format} f=format\+::autodetect)
\begin{DoxyCompactList}\small\item\em Saves a model to file, guessing the filetype from the extension, or, optionally, saving the specified format. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename eT $>$ }\\bool \textbf{ Save} (const std\+::string \&filename, arma\+::\+Mat$<$ eT $>$ \&matrix, \textbf{ Image\+Info} \&info, const bool fatal=false)
\begin{DoxyCompactList}\small\item\em Save the image file from the given matrix. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename eT $>$ }\\bool \textbf{ Save} (const std\+::vector$<$ std\+::string $>$ \&files, arma\+::\+Mat$<$ eT $>$ \&matrix, \textbf{ Image\+Info} \&info, const bool fatal=false)
\begin{DoxyCompactList}\small\item\em Save the image file from the given matrix. \end{DoxyCompactList}\item 
bool \textbf{ Save\+Image} (const std\+::string \&filename, arma\+::\+Mat$<$ unsigned char $>$ \&image, \textbf{ Image\+Info} \&info, const bool fatal=false)
\begin{DoxyCompactList}\small\item\em Helper function to save files. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename T , typename U $>$ }\\void \textbf{ Split} (const arma\+::\+Mat$<$ T $>$ \&input, const arma\+::\+Row$<$ U $>$ \&input\+Label, arma\+::\+Mat$<$ T $>$ \&train\+Data, arma\+::\+Mat$<$ T $>$ \&test\+Data, arma\+::\+Row$<$ U $>$ \&train\+Label, arma\+::\+Row$<$ U $>$ \&test\+Label, const double test\+Ratio)
\begin{DoxyCompactList}\small\item\em Given an input dataset and labels, split into a training set and test set. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename T $>$ }\\void \textbf{ Split} (const arma\+::\+Mat$<$ T $>$ \&input, arma\+::\+Mat$<$ T $>$ \&train\+Data, arma\+::\+Mat$<$ T $>$ \&test\+Data, const double test\+Ratio)
\begin{DoxyCompactList}\small\item\em Given an input dataset, split into a training set and test set. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename T , typename U $>$ }\\std\+::tuple$<$ arma\+::\+Mat$<$ T $>$, arma\+::\+Mat$<$ T $>$, arma\+::\+Row$<$ U $>$, arma\+::\+Row$<$ U $>$ $>$ \textbf{ Split} (const arma\+::\+Mat$<$ T $>$ \&input, const arma\+::\+Row$<$ U $>$ \&input\+Label, const double test\+Ratio)
\begin{DoxyCompactList}\small\item\em Given an input dataset and labels, split into a training set and test set. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename T $>$ }\\std\+::tuple$<$ arma\+::\+Mat$<$ T $>$, arma\+::\+Mat$<$ T $>$ $>$ \textbf{ Split} (const arma\+::\+Mat$<$ T $>$ \&input, const double test\+Ratio)
\begin{DoxyCompactList}\small\item\em Given an input dataset, split into a training set and test set. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Functions to load and save matrices and models. 

Functions to load and save matrices.

\subsection{Typedef Documentation}
\mbox{\label{namespacemlpack_1_1data_a728f5dac92331960e1e5822919dd2a41}} 
\index{mlpack\+::data@{mlpack\+::data}!Bag\+Of\+Words\+Encoding@{Bag\+Of\+Words\+Encoding}}
\index{Bag\+Of\+Words\+Encoding@{Bag\+Of\+Words\+Encoding}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Bag\+Of\+Words\+Encoding}
{\footnotesize\ttfamily using \textbf{ Bag\+Of\+Words\+Encoding} =  \textbf{ String\+Encoding}$<$\textbf{ Bag\+Of\+Words\+Encoding\+Policy}, \textbf{ String\+Encoding\+Dictionary}$<$Token\+Type$>$ $>$}



A convenient alias for the \doxyref{String\+Encoding}{p.}{classmlpack_1_1data_1_1StringEncoding} class with \doxyref{Bag\+Of\+Words\+Encoding\+Policy}{p.}{classmlpack_1_1data_1_1BagOfWordsEncodingPolicy} and the default dictionary for the given token type. 


\begin{DoxyTemplParams}{Template Parameters}
{\em Token\+Type} & Type of the tokens. \\
\hline
\end{DoxyTemplParams}


Definition at line 167 of file bag\+\_\+of\+\_\+words\+\_\+encoding\+\_\+policy.\+hpp.

\mbox{\label{namespacemlpack_1_1data_aa243ad7e4d29363b858bbc92b732921d}} 
\index{mlpack\+::data@{mlpack\+::data}!Dataset\+Info@{Dataset\+Info}}
\index{Dataset\+Info@{Dataset\+Info}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Dataset\+Info}
{\footnotesize\ttfamily typedef \textbf{ Dataset\+Mapper}$<$ \textbf{ Increment\+Policy}, std\+::string $>$ \textbf{ Dataset\+Info}}



Definition at line 196 of file dataset\+\_\+mapper.\+hpp.

\mbox{\label{namespacemlpack_1_1data_aaa7ca4dc9e2a0d1189d7717b98c01933}} 
\index{mlpack\+::data@{mlpack\+::data}!Dictionary\+Encoding@{Dictionary\+Encoding}}
\index{Dictionary\+Encoding@{Dictionary\+Encoding}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Dictionary\+Encoding}
{\footnotesize\ttfamily using \textbf{ Dictionary\+Encoding} =  \textbf{ String\+Encoding}$<$\textbf{ Dictionary\+Encoding\+Policy}, \textbf{ String\+Encoding\+Dictionary}$<$Token\+Type$>$ $>$}



A convenient alias for the \doxyref{String\+Encoding}{p.}{classmlpack_1_1data_1_1StringEncoding} class with \doxyref{Dictionary\+Encoding\+Policy}{p.}{classmlpack_1_1data_1_1DictionaryEncodingPolicy} and the default dictionary for the given token type. 


\begin{DoxyTemplParams}{Template Parameters}
{\em Token\+Type} & Type of the tokens. \\
\hline
\end{DoxyTemplParams}


Definition at line 146 of file dictionary\+\_\+encoding\+\_\+policy.\+hpp.

\mbox{\label{namespacemlpack_1_1data_adc64c1431b690f470d4949729d31191f}} 
\index{mlpack\+::data@{mlpack\+::data}!Tf\+Idf\+Encoding@{Tf\+Idf\+Encoding}}
\index{Tf\+Idf\+Encoding@{Tf\+Idf\+Encoding}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Tf\+Idf\+Encoding}
{\footnotesize\ttfamily using \textbf{ Tf\+Idf\+Encoding} =  \textbf{ String\+Encoding}$<$\textbf{ Tf\+Idf\+Encoding\+Policy}, \textbf{ String\+Encoding\+Dictionary}$<$Token\+Type$>$ $>$}



A convenient alias for the \doxyref{String\+Encoding}{p.}{classmlpack_1_1data_1_1StringEncoding} class with \doxyref{Tf\+Idf\+Encoding\+Policy}{p.}{classmlpack_1_1data_1_1TfIdfEncodingPolicy} and the default dictionary for the given token type. 


\begin{DoxyTemplParams}{Template Parameters}
{\em Token\+Type} & Type of the tokens. \\
\hline
\end{DoxyTemplParams}


Definition at line 345 of file tf\+\_\+idf\+\_\+encoding\+\_\+policy.\+hpp.



\subsection{Enumeration Type Documentation}
\mbox{\label{namespacemlpack_1_1data_aa7714fa0b7efc7b31cbda21da607c5b6}} 
\index{mlpack\+::data@{mlpack\+::data}!Datatype@{Datatype}}
\index{Datatype@{Datatype}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Datatype}
{\footnotesize\ttfamily enum \textbf{ Datatype} \+: bool}



The Datatype enum specifies the types of data mlpack algorithms can use. 

The vast majority of mlpack algorithms can only use numeric data (i.\+e. float/double/etc.), but some algorithms can use categorical data, specified via this Datatype enum and the \doxyref{Dataset\+Mapper}{p.}{classmlpack_1_1data_1_1DatasetMapper} class. \begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{numeric@{numeric}!mlpack\+::data@{mlpack\+::data}}\index{mlpack\+::data@{mlpack\+::data}!numeric@{numeric}}}\mbox{\label{namespacemlpack_1_1data_aa7714fa0b7efc7b31cbda21da607c5b6a1b5484703e716389553255e6f11f12ec}} 
numeric&\\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{categorical@{categorical}!mlpack\+::data@{mlpack\+::data}}\index{mlpack\+::data@{mlpack\+::data}!categorical@{categorical}}}\mbox{\label{namespacemlpack_1_1data_aa7714fa0b7efc7b31cbda21da607c5b6a2992a7ab833605792145cd40762644c7}} 
categorical&\\
\hline

\end{DoxyEnumFields}


Definition at line 24 of file datatype.\+hpp.

\mbox{\label{namespacemlpack_1_1data_a387137c43ed9616d39ba90e890d181eb}} 
\index{mlpack\+::data@{mlpack\+::data}!format@{format}}
\index{format@{format}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{format}
{\footnotesize\ttfamily enum \textbf{ format}}



Define the formats we can read through \doxyref{boost\+::serialization}{p.}{namespaceboost_1_1serialization}. 

\begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{autodetect@{autodetect}!mlpack\+::data@{mlpack\+::data}}\index{mlpack\+::data@{mlpack\+::data}!autodetect@{autodetect}}}\mbox{\label{namespacemlpack_1_1data_a387137c43ed9616d39ba90e890d181eba7038b9ea9dd309cf5cc8f7122f6c0cee}} 
autodetect&\\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{text@{text}!mlpack\+::data@{mlpack\+::data}}\index{mlpack\+::data@{mlpack\+::data}!text@{text}}}\mbox{\label{namespacemlpack_1_1data_a387137c43ed9616d39ba90e890d181eba0e17259309839615d215adfe7a44fb50}} 
text&\\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{xml@{xml}!mlpack\+::data@{mlpack\+::data}}\index{mlpack\+::data@{mlpack\+::data}!xml@{xml}}}\mbox{\label{namespacemlpack_1_1data_a387137c43ed9616d39ba90e890d181ebac0a194d2e3cadd6447861e57368c2581}} 
xml&\\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{binary@{binary}!mlpack\+::data@{mlpack\+::data}}\index{mlpack\+::data@{mlpack\+::data}!binary@{binary}}}\mbox{\label{namespacemlpack_1_1data_a387137c43ed9616d39ba90e890d181eba4c41ae0ac8cc59e0caeaa4984dd5d469}} 
binary&\\
\hline

\end{DoxyEnumFields}


Definition at line 20 of file format.\+hpp.



\subsection{Function Documentation}
\mbox{\label{namespacemlpack_1_1data_a28da72e55467d0872681827b30b490ac}} 
\index{mlpack\+::data@{mlpack\+::data}!Binarize@{Binarize}}
\index{Binarize@{Binarize}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Binarize()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily void mlpack\+::data\+::\+Binarize (\begin{DoxyParamCaption}\item[{const arma\+::\+Mat$<$ T $>$ \&}]{input,  }\item[{arma\+::\+Mat$<$ T $>$ \&}]{output,  }\item[{const double}]{threshold }\end{DoxyParamCaption})}



Given an input dataset and threshold, set values greater than threshold to 1 and values less than or equal to the threshold to 0. 

This overload applies the changes to all dimensions.


\begin{DoxyCode}
arma::Mat<double> input = loadData();
arma::Mat<double> output;
\textcolor{keywordtype}{double} threshold = 0.5;

\textcolor{comment}{// Binarize the whole Matrix. All positive values in will be set to 1 and}
\textcolor{comment}{// the values less than or equal to 0.5 will become 0.}
Binarize<double>(input, output, threshold);
\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em input} & Input matrix to Binarize. \\
\hline
{\em output} & Matrix you want to save binarized data into. \\
\hline
{\em threshold} & Threshold can by any number. \\
\hline
\end{DoxyParams}


Definition at line 41 of file binarize.\+hpp.



References omp\+\_\+size\+\_\+t.

\mbox{\label{namespacemlpack_1_1data_a39606420520e81f5e87d6ea1e64c27ae}} 
\index{mlpack\+::data@{mlpack\+::data}!Binarize@{Binarize}}
\index{Binarize@{Binarize}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Binarize()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily void mlpack\+::data\+::\+Binarize (\begin{DoxyParamCaption}\item[{const arma\+::\+Mat$<$ T $>$ \&}]{input,  }\item[{arma\+::\+Mat$<$ T $>$ \&}]{output,  }\item[{const double}]{threshold,  }\item[{const size\+\_\+t}]{dimension }\end{DoxyParamCaption})}



Given an input dataset and threshold, set values greater than threshold to 1 and values less than or equal to the threshold to 0. 

This overload takes a dimension and applys the changes to the given dimension.


\begin{DoxyCode}
arma::Mat<double> input = loadData();
arma::Mat<double> output;
\textcolor{keywordtype}{double} threshold = 0.5;
\textcolor{keywordtype}{size\_t} dimension = 0;

\textcolor{comment}{// Binarize the first dimension. All positive values in the first dimension}
\textcolor{comment}{// will be set to 1 and the values less than or equal to 0 will become 0.}
Binarize<double>(input, output, threshold, dimension);
\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em input} & Input matrix to Binarize. \\
\hline
{\em output} & Matrix you want to save binarized data into. \\
\hline
{\em threshold} & Threshold can by any number. \\
\hline
{\em dimension} & Feature to apply the Binarize function. \\
\hline
\end{DoxyParams}


Definition at line 77 of file binarize.\+hpp.



References omp\+\_\+size\+\_\+t.

\mbox{\label{namespacemlpack_1_1data_a3bb1b3de86790e53265efa63e5965d41}} 
\index{mlpack\+::data@{mlpack\+::data}!Confusion\+Matrix@{Confusion\+Matrix}}
\index{Confusion\+Matrix@{Confusion\+Matrix}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Confusion\+Matrix()}
{\footnotesize\ttfamily void mlpack\+::data\+::\+Confusion\+Matrix (\begin{DoxyParamCaption}\item[{const arma\+::\+Row$<$ size\+\_\+t $>$}]{predictors,  }\item[{const arma\+::\+Row$<$ size\+\_\+t $>$}]{responses,  }\item[{arma\+::\+Mat$<$ eT $>$ \&}]{output,  }\item[{const size\+\_\+t}]{num\+Classes }\end{DoxyParamCaption})}



A confusion matrix is a summary of prediction results on a classification problem. 

The number of correct and incorrect predictions are summarized by count and broken down by each class. For example, for 2 classes, the function call will be


\begin{DoxyCode}
ConfusionMatrix(predictors, responses, output, 2)
\end{DoxyCode}


In this case, the output matrix will be of size 2 $\ast$ 2\+:


\begin{DoxyCode}
     0     1
0    TP    FN
1    FP    TN
\end{DoxyCode}


The confusion matrix for two labels will look like what is shown above. In this confusion matrix, TP represents the number of true positives, FP represents the number of false positives, FN represents the number of false negatives, and TN represents the number of true negatives.

When generalizing to 2 or more classes, the row index of the confusion matrix represents the predicted classes and column index represents the actual class.


\begin{DoxyParams}{Parameters}
{\em predictors} & Vector of data points. \\
\hline
{\em responses} & The measured data for each point. \\
\hline
{\em output} & Matrix which is represented as confusion matrix. \\
\hline
{\em num\+Classes} & Number of classes. \\
\hline
\end{DoxyParams}
\mbox{\label{namespacemlpack_1_1data_a5a13b28050a64b446916c067e1466951}} 
\index{mlpack\+::data@{mlpack\+::data}!Extension@{Extension}}
\index{Extension@{Extension}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Extension()}
{\footnotesize\ttfamily std\+::string mlpack\+::data\+::\+Extension (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{filename }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Definition at line 21 of file extension.\+hpp.

\mbox{\label{namespacemlpack_1_1data_acb5cb8a6b868db7d521f8efbe03b6728}} 
\index{mlpack\+::data@{mlpack\+::data}!H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM@{H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM}}
\index{H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM@{H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M()}
{\footnotesize\ttfamily mlpack\+::data\+::\+H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM (\begin{DoxyParamCaption}\item[{serialize}]{,  }\item[{Has\+Serialize\+Check}]{ }\end{DoxyParamCaption})}

\mbox{\label{namespacemlpack_1_1data_a6814f77346f5af80d2c25ef3206713cb}} 
\index{mlpack\+::data@{mlpack\+::data}!Image\+Format\+Supported@{Image\+Format\+Supported}}
\index{Image\+Format\+Supported@{Image\+Format\+Supported}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Image\+Format\+Supported()}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Image\+Format\+Supported (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{file\+Name,  }\item[{const bool}]{save = {\ttfamily false} }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Checks if the given image filename is supported. 


\begin{DoxyParams}{Parameters}
{\em filename} & Name of the image file. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Boolean value indicating success if it is an image. 
\end{DoxyReturn}
\mbox{\label{namespacemlpack_1_1data_a3799ea79b454b97c5f79a82db6958a1b}} 
\index{mlpack\+::data@{mlpack\+::data}!Is\+Na\+N\+Inf@{Is\+Na\+N\+Inf}}
\index{Is\+Na\+N\+Inf@{Is\+Na\+N\+Inf}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Is\+Na\+N\+Inf()}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Is\+Na\+N\+Inf (\begin{DoxyParamCaption}\item[{T \&}]{val,  }\item[{const std\+::string \&}]{token }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



See if the token is a NaN or an Inf, and if so, set the value accordingly and return a boolean representing whether or not it is. 



Definition at line 27 of file is\+\_\+naninf.\+hpp.

\mbox{\label{namespacemlpack_1_1data_a19805d6585ac8b0be7c4e4b7f081977c}} 
\index{mlpack\+::data@{mlpack\+::data}!Load@{Load}}
\index{Load@{Load}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Load()\hspace{0.1cm}{\footnotesize\ttfamily [1/7]}}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Load (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{filename,  }\item[{arma\+::\+Mat$<$ eT $>$ \&}]{matrix,  }\item[{const bool}]{fatal = {\ttfamily false},  }\item[{const bool}]{transpose = {\ttfamily true} }\end{DoxyParamCaption})}



Loads a matrix from file, guessing the filetype from the extension. 

This will transpose the matrix at load time (unless the transpose parameter is set to false). If the filetype cannot be determined, an error will be given.

The supported types of files are the same as found in Armadillo\+:


\begin{DoxyItemize}
\item C\+SV (csv\+\_\+ascii), denoted by .csv, or optionally .txt
\item T\+SV (raw\+\_\+ascii), denoted by .tsv, .csv, or .txt
\item A\+S\+C\+II (raw\+\_\+ascii), denoted by .txt
\item Armadillo A\+S\+C\+II (arma\+\_\+ascii), also denoted by .txt
\item P\+GM (pgm\+\_\+binary), denoted by .pgm
\item P\+PM (ppm\+\_\+binary), denoted by .ppm
\item Raw binary (raw\+\_\+binary), denoted by .bin
\item Armadillo binary (arma\+\_\+binary), denoted by .bin
\item H\+D\+F5, denoted by .hdf, .hdf5, .h5, or .he5
\end{DoxyItemize}

If the file extension is not one of those types, an error will be given. This is preferable to Armadillo\textquotesingle{}s default behavior of loading an unknown filetype as raw\+\_\+binary, which can have very confusing effects.

If the parameter \textquotesingle{}fatal\textquotesingle{} is set to true, a std\+::runtime\+\_\+error exception will be thrown if the matrix does not load successfully. The parameter \textquotesingle{}transpose\textquotesingle{} controls whether or not the matrix is transposed after loading. In most cases, because data is generally stored in a row-\/major format and mlpack requires column-\/major matrices, this should be left at its default value of \textquotesingle{}true\textquotesingle{}.


\begin{DoxyParams}{Parameters}
{\em filename} & Name of file to load. \\
\hline
{\em matrix} & Matrix to load contents of file into. \\
\hline
{\em fatal} & If an error should be reported as fatal (default false). \\
\hline
{\em transpose} & If true, transpose the matrix after loading. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Boolean value indicating success or failure of load. 
\end{DoxyReturn}


Referenced by mlpack\+::bindings\+::cli\+::\+Get\+Param().

\mbox{\label{namespacemlpack_1_1data_adb0c6adf83024427e47a03bd7fbfb885}} 
\index{mlpack\+::data@{mlpack\+::data}!Load@{Load}}
\index{Load@{Load}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Load()\hspace{0.1cm}{\footnotesize\ttfamily [2/7]}}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Load (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{filename,  }\item[{arma\+::\+Col$<$ eT $>$ \&}]{vec,  }\item[{const bool}]{fatal = {\ttfamily false} }\end{DoxyParamCaption})}



Don\textquotesingle{}t document these with doxygen; these declarations aren\textquotesingle{}t helpful to users. 

Load a column vector from a file, guessing the filetype from the extension.

The supported types of files are the same as found in Armadillo\+:


\begin{DoxyItemize}
\item C\+SV (csv\+\_\+ascii), denoted by .csv, or optionally .txt
\item T\+SV (raw\+\_\+ascii), denoted by .tsv, .csv, or .txt
\item A\+S\+C\+II (raw\+\_\+ascii), denoted by .txt
\item Armadillo A\+S\+C\+II (arma\+\_\+ascii), also denoted by .txt
\item P\+GM (pgm\+\_\+binary), denoted by .pgm
\item P\+PM (ppm\+\_\+binary), denoted by .ppm
\item Raw binary (raw\+\_\+binary), denoted by .bin
\item Armadillo binary (arma\+\_\+binary), denoted by .bin
\item H\+D\+F5, denoted by .hdf, .hdf5, .h5, or .he5
\end{DoxyItemize}

If the file extension is not one of those types, an error will be given. This is preferable to Armadillo\textquotesingle{}s default behavior of loading an unknown filetype as raw\+\_\+binary, which can have very confusing effects.

If the parameter \textquotesingle{}fatal\textquotesingle{} is set to true, a std\+::runtime\+\_\+error exception will be thrown if the matrix does not load successfully.


\begin{DoxyParams}{Parameters}
{\em filename} & Name of file to load. \\
\hline
{\em colvec} & Column vector to load contents of file into. \\
\hline
{\em fatal} & If an error should be reported as fatal (default false). \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Boolean value indicating success or failure of load. 
\end{DoxyReturn}
\mbox{\label{namespacemlpack_1_1data_ac5679a4dc8c6129e3895a1089855d25d}} 
\index{mlpack\+::data@{mlpack\+::data}!Load@{Load}}
\index{Load@{Load}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Load()\hspace{0.1cm}{\footnotesize\ttfamily [3/7]}}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Load (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{filename,  }\item[{arma\+::\+Row$<$ eT $>$ \&}]{rowvec,  }\item[{const bool}]{fatal = {\ttfamily false} }\end{DoxyParamCaption})}



Load a row vector from a file, guessing the filetype from the extension. 

The supported types of files are the same as found in Armadillo\+:


\begin{DoxyItemize}
\item C\+SV (csv\+\_\+ascii), denoted by .csv, or optionally .txt
\item T\+SV (raw\+\_\+ascii), denoted by .tsv, .csv, or .txt
\item A\+S\+C\+II (raw\+\_\+ascii), denoted by .txt
\item Armadillo A\+S\+C\+II (arma\+\_\+ascii), also denoted by .txt
\item P\+GM (pgm\+\_\+binary), denoted by .pgm
\item P\+PM (ppm\+\_\+binary), denoted by .ppm
\item Raw binary (raw\+\_\+binary), denoted by .bin
\item Armadillo binary (arma\+\_\+binary), denoted by .bin
\item H\+D\+F5, denoted by .hdf, .hdf5, .h5, or .he5
\end{DoxyItemize}

If the file extension is not one of those types, an error will be given. This is preferable to Armadillo\textquotesingle{}s default behavior of loading an unknown filetype as raw\+\_\+binary, which can have very confusing effects.

If the parameter \textquotesingle{}fatal\textquotesingle{} is set to true, a std\+::runtime\+\_\+error exception will be thrown if the matrix does not load successfully.


\begin{DoxyParams}{Parameters}
{\em filename} & Name of file to load. \\
\hline
{\em colvec} & Column vector to load contents of file into. \\
\hline
{\em fatal} & If an error should be reported as fatal (default false). \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Boolean value indicating success or failure of load. 
\end{DoxyReturn}
\mbox{\label{namespacemlpack_1_1data_a9af06d46f91871c42f38e30aac5d4666}} 
\index{mlpack\+::data@{mlpack\+::data}!Load@{Load}}
\index{Load@{Load}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Load()\hspace{0.1cm}{\footnotesize\ttfamily [4/7]}}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Load (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{filename,  }\item[{arma\+::\+Mat$<$ eT $>$ \&}]{matrix,  }\item[{\textbf{ Dataset\+Mapper}$<$ Policy\+Type $>$ \&}]{info,  }\item[{const bool}]{fatal = {\ttfamily false},  }\item[{const bool}]{transpose = {\ttfamily true} }\end{DoxyParamCaption})}



Loads a matrix from a file, guessing the filetype from the extension and mapping categorical features with a \doxyref{Dataset\+Mapper}{p.}{classmlpack_1_1data_1_1DatasetMapper} object. 

This will transpose the matrix (unless the transpose parameter is set to false). This particular overload of \doxyref{Load()}{p.}{namespacemlpack_1_1data_a19805d6585ac8b0be7c4e4b7f081977c} can only load text-\/based formats, such as those given below\+:


\begin{DoxyItemize}
\item C\+SV (csv\+\_\+ascii), denoted by .csv, or optionally .txt
\item T\+SV (raw\+\_\+ascii), denoted by .tsv, .csv, or .txt
\item A\+S\+C\+II (raw\+\_\+ascii), denoted by .txt
\end{DoxyItemize}

If the file extension is not one of those types, an error will be given. This is preferable to Armadillo\textquotesingle{}s default behavior of loading an unknown filetype as raw\+\_\+binary, which can have very confusing effects.

If the parameter \textquotesingle{}fatal\textquotesingle{} is set to true, a std\+::runtime\+\_\+error exception will be thrown if the matrix does not load successfully. The parameter \textquotesingle{}transpose\textquotesingle{} controls whether or not the matrix is transposed after loading. In most cases, because data is generally stored in a row-\/major format and mlpack requires column-\/major matrices, this should be left at its default value of \textquotesingle{}true\textquotesingle{}.

The \doxyref{Dataset\+Mapper}{p.}{classmlpack_1_1data_1_1DatasetMapper} object passed to this function will be re-\/created, so any mappings from previous loads will be lost.


\begin{DoxyParams}{Parameters}
{\em filename} & Name of file to load. \\
\hline
{\em matrix} & Matrix to load contents of file into. \\
\hline
{\em info} & \doxyref{Dataset\+Mapper}{p.}{classmlpack_1_1data_1_1DatasetMapper} object to populate with mappings and data types. \\
\hline
{\em fatal} & If an error should be reported as fatal (default false). \\
\hline
{\em transpose} & If true, transpose the matrix after loading. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Boolean value indicating success or failure of load. 
\end{DoxyReturn}
\mbox{\label{namespacemlpack_1_1data_ac0441d5f7e76f0fcdeec487d4a9732ac}} 
\index{mlpack\+::data@{mlpack\+::data}!Load@{Load}}
\index{Load@{Load}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Load()\hspace{0.1cm}{\footnotesize\ttfamily [5/7]}}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Load (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{filename,  }\item[{const std\+::string \&}]{name,  }\item[{T \&}]{t,  }\item[{const bool}]{fatal = {\ttfamily false},  }\item[{\textbf{ format}}]{f = {\ttfamily format\+:\+:autodetect} }\end{DoxyParamCaption})}



Don\textquotesingle{}t document these with doxygen; they aren\textquotesingle{}t helpful for users to know about. 

Load a model from a file, guessing the filetype from the extension, or, optionally, loading the specified format. If automatic extension detection is used and the filetype cannot be determined, an error will be given.

The supported types of files are the same as what is supported by the \doxyref{boost\+::serialization}{p.}{namespaceboost_1_1serialization} library\+:


\begin{DoxyItemize}
\item text, denoted by .txt
\item xml, denoted by .xml
\item binary, denoted by .bin
\end{DoxyItemize}

The format parameter can take any of the values in the \textquotesingle{}format\textquotesingle{} enum\+: \textquotesingle{}format\+::autodetect\textquotesingle{}, \textquotesingle{}format\+::text\textquotesingle{}, \textquotesingle{}format\+::xml\textquotesingle{}, and \textquotesingle{}format\+::binary\textquotesingle{}. The autodetect functionality operates on the file extension (so, \char`\"{}file.\+txt\char`\"{} would be autodetected as text).

The name parameter should be specified to indicate the name of the structure to be loaded. This should be the same as the name that was used to save the structure (otherwise, the loading procedure will fail).

If the parameter \textquotesingle{}fatal\textquotesingle{} is set to true, then an exception will be thrown in the event of load failure. Otherwise, the method will return false and the relevant error information will be printed to \doxyref{Log\+::\+Warn}{p.}{classmlpack_1_1Log_af8dd463e0db2840410fe6b1165429d5b}. \mbox{\label{namespacemlpack_1_1data_aa05aba27ed8693c1c4ed538240a549b1}} 
\index{mlpack\+::data@{mlpack\+::data}!Load@{Load}}
\index{Load@{Load}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Load()\hspace{0.1cm}{\footnotesize\ttfamily [6/7]}}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Load (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{filename,  }\item[{arma\+::\+Mat$<$ eT $>$ \&}]{matrix,  }\item[{\textbf{ Image\+Info} \&}]{info,  }\item[{const bool}]{fatal = {\ttfamily false} }\end{DoxyParamCaption})}



Image load/save interfaces. 

Load the image file into the given matrix.


\begin{DoxyParams}{Parameters}
{\em filename} & Name of the image file. \\
\hline
{\em matrix} & Matrix to load the image into. \\
\hline
{\em info} & An object of \doxyref{Image\+Info}{p.}{classmlpack_1_1data_1_1ImageInfo} class. \\
\hline
{\em fatal} & If an error should be reported as fatal (default false). \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Boolean value indicating success or failure of load. 
\end{DoxyReturn}
\mbox{\label{namespacemlpack_1_1data_adf6afb44303645116a32d1ed168e0ff1}} 
\index{mlpack\+::data@{mlpack\+::data}!Load@{Load}}
\index{Load@{Load}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Load()\hspace{0.1cm}{\footnotesize\ttfamily [7/7]}}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Load (\begin{DoxyParamCaption}\item[{const std\+::vector$<$ std\+::string $>$ \&}]{files,  }\item[{arma\+::\+Mat$<$ eT $>$ \&}]{matrix,  }\item[{\textbf{ Image\+Info} \&}]{info,  }\item[{const bool}]{fatal = {\ttfamily false} }\end{DoxyParamCaption})}



Load the image file into the given matrix. 


\begin{DoxyParams}{Parameters}
{\em files} & A vector consisting of filenames. \\
\hline
{\em matrix} & Matrix to save the image from. \\
\hline
{\em info} & An object of \doxyref{Image\+Info}{p.}{classmlpack_1_1data_1_1ImageInfo} class. \\
\hline
{\em fatal} & If an error should be reported as fatal (default false). \\
\hline
{\em transpose} & If true, transpose the matrix after loading. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Boolean value indicating success or failure of load. 
\end{DoxyReturn}
\mbox{\label{namespacemlpack_1_1data_a951a7dc1fd86524b8dd245bb91841731}} 
\index{mlpack\+::data@{mlpack\+::data}!Load\+A\+R\+FF@{Load\+A\+R\+FF}}
\index{Load\+A\+R\+FF@{Load\+A\+R\+FF}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Load\+A\+R\+F\+F()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily void mlpack\+::data\+::\+Load\+A\+R\+FF (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{filename,  }\item[{arma\+::\+Mat$<$ eT $>$ \&}]{matrix }\end{DoxyParamCaption})}



A utility function to load an A\+R\+FF dataset as numeric features (that is, as an Armadillo matrix without any modification). 

An exception will be thrown if any features are non-\/numeric. \mbox{\label{namespacemlpack_1_1data_aa2a4a09a274c068e08373200fe611422}} 
\index{mlpack\+::data@{mlpack\+::data}!Load\+A\+R\+FF@{Load\+A\+R\+FF}}
\index{Load\+A\+R\+FF@{Load\+A\+R\+FF}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Load\+A\+R\+F\+F()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily void mlpack\+::data\+::\+Load\+A\+R\+FF (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{filename,  }\item[{arma\+::\+Mat$<$ eT $>$ \&}]{matrix,  }\item[{\textbf{ Dataset\+Mapper}$<$ Policy\+Type $>$ \&}]{info }\end{DoxyParamCaption})}



A utility function to load an A\+R\+FF dataset as numeric and categorical features, using the Dataset\+Info structure for mapping. 

An exception will be thrown upon failure.

A pre-\/existing Dataset\+Info object can be passed in, but if the dimensionality of the given Dataset\+Info object (info.\+Dimensionality()) does not match the dimensionality of the data, a std\+::invalid\+\_\+argument exception will be thrown. If an empty Dataset\+Info object is given (constructed with the default constructor or otherwise, so that info.\+Dimensionality() is 0), it will be set to the right dimensionality.

This ability to pass in pre-\/existing Dataset\+Info objects is very necessary when, e.\+g., loading a test set after training. If the same Dataset\+Info from loading the training set is not used, then the test set may be loaded with different mappings---which can cause horrible problems!


\begin{DoxyParams}{Parameters}
{\em filename} & Name of A\+R\+FF file to load. \\
\hline
{\em matrix} & Matrix to load data into. \\
\hline
{\em info} & Dataset\+Info object; can be default-\/constructed or pre-\/existing from another call to \doxyref{Load\+A\+R\+F\+F()}{p.}{namespacemlpack_1_1data_a951a7dc1fd86524b8dd245bb91841731}. \\
\hline
\end{DoxyParams}
\mbox{\label{namespacemlpack_1_1data_a01155770d761c5cf686a666f3622caa5}} 
\index{mlpack\+::data@{mlpack\+::data}!Load\+Image@{Load\+Image}}
\index{Load\+Image@{Load\+Image}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Load\+Image()}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Load\+Image (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{filename,  }\item[{arma\+::\+Mat$<$ unsigned char $>$ \&}]{matrix,  }\item[{\textbf{ Image\+Info} \&}]{info,  }\item[{const bool}]{fatal = {\ttfamily false} }\end{DoxyParamCaption})}

\mbox{\label{namespacemlpack_1_1data_a664b3fa5243889e2aed47ee750f840ed}} 
\index{mlpack\+::data@{mlpack\+::data}!Normalize\+Labels@{Normalize\+Labels}}
\index{Normalize\+Labels@{Normalize\+Labels}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Normalize\+Labels()}
{\footnotesize\ttfamily void mlpack\+::data\+::\+Normalize\+Labels (\begin{DoxyParamCaption}\item[{const Row\+Type \&}]{labels\+In,  }\item[{arma\+::\+Row$<$ size\+\_\+t $>$ \&}]{labels,  }\item[{arma\+::\+Col$<$ eT $>$ \&}]{mapping }\end{DoxyParamCaption})}



Given a set of labels of a particular datatype, convert them to unsigned labels in the range [0, n) where n is the number of different labels. 

Also, a reverse mapping from the new label to the old value is stored in the \textquotesingle{}mapping\textquotesingle{} vector.


\begin{DoxyParams}{Parameters}
{\em labels\+In} & Input labels of arbitrary datatype. \\
\hline
{\em labels} & Vector that unsigned labels will be stored in. \\
\hline
{\em mapping} & Reverse mapping to convert new labels back to old labels. \\
\hline
\end{DoxyParams}
\mbox{\label{namespacemlpack_1_1data_a57ba987709fadab2453d8d16f1fae522}} 
\index{mlpack\+::data@{mlpack\+::data}!One\+Hot\+Encoding@{One\+Hot\+Encoding}}
\index{One\+Hot\+Encoding@{One\+Hot\+Encoding}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{One\+Hot\+Encoding()}
{\footnotesize\ttfamily void mlpack\+::data\+::\+One\+Hot\+Encoding (\begin{DoxyParamCaption}\item[{const Row\+Type \&}]{labels\+In,  }\item[{arma\+::\+Mat$<$ eT $>$ \&}]{output }\end{DoxyParamCaption})}



Given a set of labels of a particular datatype, convert them to binary vector. 

The categorical values be mapped to integer values. Then, each integer value is represented as a binary vector that is all zero values except the index of the integer, which is marked with a 1.


\begin{DoxyParams}{Parameters}
{\em labels\+In} & Input labels of arbitrary datatype. \\
\hline
{\em output} & Binary matrix. \\
\hline
\end{DoxyParams}
\mbox{\label{namespacemlpack_1_1data_a901fe08dcdc58734f64a864dbdef0a28}} 
\index{mlpack\+::data@{mlpack\+::data}!Revert\+Labels@{Revert\+Labels}}
\index{Revert\+Labels@{Revert\+Labels}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Revert\+Labels()}
{\footnotesize\ttfamily void mlpack\+::data\+::\+Revert\+Labels (\begin{DoxyParamCaption}\item[{const arma\+::\+Row$<$ size\+\_\+t $>$ \&}]{labels,  }\item[{const arma\+::\+Col$<$ eT $>$ \&}]{mapping,  }\item[{arma\+::\+Row$<$ eT $>$ \&}]{labels\+Out }\end{DoxyParamCaption})}



Given a set of labels that have been mapped to the range [0, n), map them back to the original labels given by the \textquotesingle{}mapping\textquotesingle{} vector. 


\begin{DoxyParams}{Parameters}
{\em labels} & Set of normalized labels to convert. \\
\hline
{\em mapping} & Mapping to use to convert labels. \\
\hline
{\em labels\+Out} & Vector to store new labels in. \\
\hline
\end{DoxyParams}
\mbox{\label{namespacemlpack_1_1data_a16bc794b14db0ab126595b19a32a5bc0}} 
\index{mlpack\+::data@{mlpack\+::data}!Save@{Save}}
\index{Save@{Save}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Save()\hspace{0.1cm}{\footnotesize\ttfamily [1/4]}}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Save (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{filename,  }\item[{const arma\+::\+Mat$<$ eT $>$ \&}]{matrix,  }\item[{const bool}]{fatal = {\ttfamily false},  }\item[{bool}]{transpose = {\ttfamily true} }\end{DoxyParamCaption})}



Saves a matrix to file, guessing the filetype from the extension. 

This will transpose the matrix at save time. If the filetype cannot be determined, an error will be given.

The supported types of files are the same as found in Armadillo\+:


\begin{DoxyItemize}
\item C\+SV (csv\+\_\+ascii), denoted by .csv, or optionally .txt
\item A\+S\+C\+II (raw\+\_\+ascii), denoted by .txt
\item Armadillo A\+S\+C\+II (arma\+\_\+ascii), also denoted by .txt
\item P\+GM (pgm\+\_\+binary), denoted by .pgm
\item P\+PM (ppm\+\_\+binary), denoted by .ppm
\item Raw binary (raw\+\_\+binary), denoted by .bin
\item Armadillo binary (arma\+\_\+binary), denoted by .bin
\item H\+D\+F5 (hdf5\+\_\+binary), denoted by .hdf5, .hdf, .h5, or .he5
\end{DoxyItemize}

If the file extension is not one of those types, an error will be given. If the \textquotesingle{}fatal\textquotesingle{} parameter is set to true, a std\+::runtime\+\_\+error exception will be thrown upon failure. If the \textquotesingle{}transpose\textquotesingle{} parameter is set to true, the matrix will be transposed before saving. Generally, because mlpack stores matrices in a column-\/major format and most datasets are stored on disk as row-\/major, this parameter should be left at its default value of \textquotesingle{}true\textquotesingle{}.


\begin{DoxyParams}{Parameters}
{\em filename} & Name of file to save to. \\
\hline
{\em matrix} & Matrix to save into file. \\
\hline
{\em fatal} & If an error should be reported as fatal (default false). \\
\hline
{\em transpose} & If true, transpose the matrix before saving. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Boolean value indicating success or failure of save. 
\end{DoxyReturn}
\mbox{\label{namespacemlpack_1_1data_af30f8bfca9b924d6d935c9f1fae91778}} 
\index{mlpack\+::data@{mlpack\+::data}!Save@{Save}}
\index{Save@{Save}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Save()\hspace{0.1cm}{\footnotesize\ttfamily [2/4]}}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Save (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{filename,  }\item[{const std\+::string \&}]{name,  }\item[{T \&}]{t,  }\item[{const bool}]{fatal = {\ttfamily false},  }\item[{\textbf{ format}}]{f = {\ttfamily format\+:\+:autodetect} }\end{DoxyParamCaption})}



Saves a model to file, guessing the filetype from the extension, or, optionally, saving the specified format. 

If automatic extension detection is used and the filetype cannot be determined, and error will be given.

The supported types of files are the same as what is supported by the \doxyref{boost\+::serialization}{p.}{namespaceboost_1_1serialization} library\+:


\begin{DoxyItemize}
\item text, denoted by .txt
\item xml, denoted by .xml
\item binary, denoted by .bin
\end{DoxyItemize}

The format parameter can take any of the values in the \textquotesingle{}format\textquotesingle{} enum\+: \textquotesingle{}format\+::autodetect\textquotesingle{}, \textquotesingle{}format\+::text\textquotesingle{}, \textquotesingle{}format\+::xml\textquotesingle{}, and \textquotesingle{}format\+::binary\textquotesingle{}. The autodetect functionality operates on the file extension (so, \char`\"{}file.\+txt\char`\"{} would be autodetected as text).

The name parameter should be specified to indicate the name of the structure to be saved. If \doxyref{Load()}{p.}{namespacemlpack_1_1data_a19805d6585ac8b0be7c4e4b7f081977c} is later called on the generated file, the name used to load should be the same as the name used for this call to \doxyref{Save()}{p.}{namespacemlpack_1_1data_a16bc794b14db0ab126595b19a32a5bc0}.

If the parameter \textquotesingle{}fatal\textquotesingle{} is set to true, then an exception will be thrown in the event of a save failure. Otherwise, the method will return false and the relevant error information will be printed to \doxyref{Log\+::\+Warn}{p.}{classmlpack_1_1Log_af8dd463e0db2840410fe6b1165429d5b}. \mbox{\label{namespacemlpack_1_1data_a255acca42390d66faaed4521eb502de8}} 
\index{mlpack\+::data@{mlpack\+::data}!Save@{Save}}
\index{Save@{Save}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Save()\hspace{0.1cm}{\footnotesize\ttfamily [3/4]}}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Save (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{filename,  }\item[{arma\+::\+Mat$<$ eT $>$ \&}]{matrix,  }\item[{\textbf{ Image\+Info} \&}]{info,  }\item[{const bool}]{fatal = {\ttfamily false} }\end{DoxyParamCaption})}



Save the image file from the given matrix. 


\begin{DoxyParams}{Parameters}
{\em filename} & Name of the image file. \\
\hline
{\em matrix} & Matrix to save the image from. \\
\hline
{\em info} & An object of \doxyref{Image\+Info}{p.}{classmlpack_1_1data_1_1ImageInfo} class. \\
\hline
{\em fatal} & If an error should be reported as fatal (default false). \\
\hline
{\em transpose} & If true, transpose the matrix after loading. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Boolean value indicating success or failure of load. 
\end{DoxyReturn}
\mbox{\label{namespacemlpack_1_1data_a9402b433306b2735be417a07d8397d9c}} 
\index{mlpack\+::data@{mlpack\+::data}!Save@{Save}}
\index{Save@{Save}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Save()\hspace{0.1cm}{\footnotesize\ttfamily [4/4]}}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Save (\begin{DoxyParamCaption}\item[{const std\+::vector$<$ std\+::string $>$ \&}]{files,  }\item[{arma\+::\+Mat$<$ eT $>$ \&}]{matrix,  }\item[{\textbf{ Image\+Info} \&}]{info,  }\item[{const bool}]{fatal = {\ttfamily false} }\end{DoxyParamCaption})}



Save the image file from the given matrix. 


\begin{DoxyParams}{Parameters}
{\em files} & A vector consisting of filenames. \\
\hline
{\em matrix} & Matrix to save the image from. \\
\hline
{\em info} & An object of \doxyref{Image\+Info}{p.}{classmlpack_1_1data_1_1ImageInfo} class. \\
\hline
{\em fatal} & If an error should be reported as fatal (default false). \\
\hline
{\em transpose} & If true, transpose the matrix after loading. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Boolean value indicating success or failure of load. 
\end{DoxyReturn}
\mbox{\label{namespacemlpack_1_1data_a5053734839d456ce3bfe20b16a467d0c}} 
\index{mlpack\+::data@{mlpack\+::data}!Save\+Image@{Save\+Image}}
\index{Save\+Image@{Save\+Image}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Save\+Image()}
{\footnotesize\ttfamily bool mlpack\+::data\+::\+Save\+Image (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{filename,  }\item[{arma\+::\+Mat$<$ unsigned char $>$ \&}]{image,  }\item[{\textbf{ Image\+Info} \&}]{info,  }\item[{const bool}]{fatal = {\ttfamily false} }\end{DoxyParamCaption})}



Helper function to save files. 

Implementation in save\+\_\+image.\+cpp. \mbox{\label{namespacemlpack_1_1data_a900bb36af4ef0fff3351bb3adb09b8c5}} 
\index{mlpack\+::data@{mlpack\+::data}!Split@{Split}}
\index{Split@{Split}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Split()\hspace{0.1cm}{\footnotesize\ttfamily [1/4]}}
{\footnotesize\ttfamily void mlpack\+::data\+::\+Split (\begin{DoxyParamCaption}\item[{const arma\+::\+Mat$<$ T $>$ \&}]{input,  }\item[{const arma\+::\+Row$<$ U $>$ \&}]{input\+Label,  }\item[{arma\+::\+Mat$<$ T $>$ \&}]{train\+Data,  }\item[{arma\+::\+Mat$<$ T $>$ \&}]{test\+Data,  }\item[{arma\+::\+Row$<$ U $>$ \&}]{train\+Label,  }\item[{arma\+::\+Row$<$ U $>$ \&}]{test\+Label,  }\item[{const double}]{test\+Ratio }\end{DoxyParamCaption})}



Given an input dataset and labels, split into a training set and test set. 

Example usage below. This overload places the split dataset into the four output parameters given (train\+Data, test\+Data, train\+Label, and test\+Label).


\begin{DoxyCode}
arma::mat input = loadData();
arma::Row<size\_t> label = loadLabel();
arma::mat trainData;
arma::mat testData;
arma::Row<size\_t> trainLabel;
arma::Row<size\_t> testLabel;
math::RandomSeed(100); \textcolor{comment}{// Set the seed if you like.}

\textcolor{comment}{// Split the dataset into a training and test set, with 30% of the data being}
\textcolor{comment}{// held out for the test set.}
Split(input, label, trainData,
               testData, trainLabel, testLabel, 0.3);
\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em input} & Input dataset to split. \\
\hline
{\em label} & Input labels to split. \\
\hline
{\em train\+Data} & Matrix to store training data into. \\
\hline
{\em test\+Data} & Matrix to store test data into. \\
\hline
{\em train\+Label} & Vector to store training labels into. \\
\hline
{\em test\+Label} & Vector to store test labels into. \\
\hline
{\em test\+Ratio} & Percentage of dataset to use for test set (between 0 and 1). \\
\hline
\end{DoxyParams}


Definition at line 49 of file split\+\_\+data.\+hpp.



Referenced by Split().

\mbox{\label{namespacemlpack_1_1data_a2045f699140a37ef0c6f0b3ef816c854}} 
\index{mlpack\+::data@{mlpack\+::data}!Split@{Split}}
\index{Split@{Split}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Split()\hspace{0.1cm}{\footnotesize\ttfamily [2/4]}}
{\footnotesize\ttfamily void mlpack\+::data\+::\+Split (\begin{DoxyParamCaption}\item[{const arma\+::\+Mat$<$ T $>$ \&}]{input,  }\item[{arma\+::\+Mat$<$ T $>$ \&}]{train\+Data,  }\item[{arma\+::\+Mat$<$ T $>$ \&}]{test\+Data,  }\item[{const double}]{test\+Ratio }\end{DoxyParamCaption})}



Given an input dataset, split into a training set and test set. 

Example usage below. This overload places the split dataset into the two output parameters given (train\+Data, test\+Data).


\begin{DoxyCode}
arma::mat input = loadData();
arma::mat trainData;
arma::mat testData;
math::RandomSeed(100); \textcolor{comment}{// Set the seed if you like.}

\textcolor{comment}{// Split the dataset into a training and test set, with 30% of the data being}
\textcolor{comment}{// held out for the test set.}
Split(input, trainData, testData, 0.3);
\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em input} & Input dataset to split. \\
\hline
{\em train\+Data} & Matrix to store training data into. \\
\hline
{\em test\+Data} & Matrix to store test data into. \\
\hline
{\em test\+Ratio} & Percentage of dataset to use for test set (between 0 and 1). \\
\hline
\end{DoxyParams}


Definition at line 103 of file split\+\_\+data.\+hpp.

\mbox{\label{namespacemlpack_1_1data_a813771e519dd63fd2f2b886d976826ce}} 
\index{mlpack\+::data@{mlpack\+::data}!Split@{Split}}
\index{Split@{Split}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Split()\hspace{0.1cm}{\footnotesize\ttfamily [3/4]}}
{\footnotesize\ttfamily std\+::tuple$<$arma\+::\+Mat$<$T$>$, arma\+::\+Mat$<$T$>$, arma\+::\+Row$<$U$>$, arma\+::\+Row$<$U$>$ $>$ mlpack\+::data\+::\+Split (\begin{DoxyParamCaption}\item[{const arma\+::\+Mat$<$ T $>$ \&}]{input,  }\item[{const arma\+::\+Row$<$ U $>$ \&}]{input\+Label,  }\item[{const double}]{test\+Ratio }\end{DoxyParamCaption})}



Given an input dataset and labels, split into a training set and test set. 

Example usage below. This overload returns the split dataset as a std\+::tuple with four elements\+: an arma\+::\+Mat$<$\+T$>$ containing the training data, an arma\+::\+Mat$<$\+T$>$ containing the test data, an arma\+::\+Row$<$\+U$>$ containing the training labels, and an arma\+::\+Row$<$\+U$>$ containing the test labels.


\begin{DoxyCode}
arma::mat input = loadData();
arma::Row<size\_t> label = loadLabel();
\textcolor{keyword}{auto} splitResult = Split(input, label, 0.2);
\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em input} & Input dataset to split. \\
\hline
{\em label} & Input labels to split. \\
\hline
{\em test\+Ratio} & Percentage of dataset to use for test set (between 0 and 1). \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
std\+::tuple containing train\+Data (arma\+::\+Mat$<$\+T$>$), test\+Data (arma\+::\+Mat$<$\+T$>$), train\+Label (arma\+::\+Row$<$\+U$>$), and test\+Label (arma\+::\+Row$<$\+U$>$). 
\end{DoxyReturn}


Definition at line 148 of file split\+\_\+data.\+hpp.



References Split().

\mbox{\label{namespacemlpack_1_1data_a80fb8838c66ff6351af3bbb33ee6ebe1}} 
\index{mlpack\+::data@{mlpack\+::data}!Split@{Split}}
\index{Split@{Split}!mlpack\+::data@{mlpack\+::data}}
\subsubsection{Split()\hspace{0.1cm}{\footnotesize\ttfamily [4/4]}}
{\footnotesize\ttfamily std\+::tuple$<$arma\+::\+Mat$<$T$>$, arma\+::\+Mat$<$T$>$ $>$ mlpack\+::data\+::\+Split (\begin{DoxyParamCaption}\item[{const arma\+::\+Mat$<$ T $>$ \&}]{input,  }\item[{const double}]{test\+Ratio }\end{DoxyParamCaption})}



Given an input dataset, split into a training set and test set. 

Example usage below. This overload returns the split dataset as a std\+::tuple with two elements\+: an arma\+::\+Mat$<$\+T$>$ containing the training data and an arma\+::\+Mat$<$\+T$>$ containing the test data.


\begin{DoxyCode}
arma::mat input = loadData();
\textcolor{keyword}{auto} splitResult = Split(input, 0.2);
\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em input} & Input dataset to split. \\
\hline
{\em test\+Ratio} & Percentage of dataset to use for test set (between 0 and 1). \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
std\+::tuple containing train\+Data (arma\+::\+Mat$<$\+T$>$) and test\+Data (arma\+::\+Mat$<$\+T$>$). 
\end{DoxyReturn}


Definition at line 184 of file split\+\_\+data.\+hpp.



References Split().

