\section{Simple\+CV$<$ M\+L\+Algorithm, Metric, Mat\+Type, Predictions\+Type, Weights\+Type $>$ Class Template Reference}
\label{classmlpack_1_1cv_1_1SimpleCV}\index{Simple\+C\+V$<$ M\+L\+Algorithm, Metric, Mat\+Type, Predictions\+Type, Weights\+Type $>$@{Simple\+C\+V$<$ M\+L\+Algorithm, Metric, Mat\+Type, Predictions\+Type, Weights\+Type $>$}}


\doxyref{Simple\+CV}{p.}{classmlpack_1_1cv_1_1SimpleCV} splits data into two sets -\/ training and validation sets -\/ and then runs training on the training set and evaluates performance on the validation set.  


\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$typename Mat\+In\+Type , typename Predictions\+In\+Type $>$ }\\\textbf{ Simple\+CV} (const double validation\+Size, Mat\+In\+Type \&\&xs, Predictions\+In\+Type \&\&ys)
\begin{DoxyCompactList}\small\item\em This constructor can be used for regression algorithms and for binary classification algorithms. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Mat\+In\+Type , typename Predictions\+In\+Type $>$ }\\\textbf{ Simple\+CV} (const double validation\+Size, Mat\+In\+Type \&\&xs, Predictions\+In\+Type \&\&ys, const size\+\_\+t num\+Classes)
\begin{DoxyCompactList}\small\item\em This constructor can be used for multiclass classification algorithms. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Mat\+In\+Type , typename Predictions\+In\+Type $>$ }\\\textbf{ Simple\+CV} (const double validation\+Size, Mat\+In\+Type \&\&xs, const \textbf{ data\+::\+Dataset\+Info} \&dataset\+Info, Predictions\+In\+Type \&\&ys, const size\+\_\+t num\+Classes)
\begin{DoxyCompactList}\small\item\em This constructor can be used for multiclass classification algorithms that can take a \doxyref{data\+::\+Dataset\+Info}{p.}{namespacemlpack_1_1data_aa243ad7e4d29363b858bbc92b732921d} parameter. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Mat\+In\+Type , typename Predictions\+In\+Type , typename Weights\+In\+Type $>$ }\\\textbf{ Simple\+CV} (const double validation\+Size, Mat\+In\+Type \&\&xs, Predictions\+In\+Type \&\&ys, Weights\+In\+Type \&\&weights)
\begin{DoxyCompactList}\small\item\em This constructor can be used for regression and binary classification algorithms that support weighted learning. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Mat\+In\+Type , typename Predictions\+In\+Type , typename Weights\+In\+Type $>$ }\\\textbf{ Simple\+CV} (const double validation\+Size, Mat\+In\+Type \&\&xs, Predictions\+In\+Type \&\&ys, const size\+\_\+t num\+Classes, Weights\+In\+Type \&\&weights)
\begin{DoxyCompactList}\small\item\em This constructor can be used for multiclass classification algorithms that support weighted learning. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Mat\+In\+Type , typename Predictions\+In\+Type , typename Weights\+In\+Type $>$ }\\\textbf{ Simple\+CV} (const double validation\+Size, Mat\+In\+Type \&\&xs, const \textbf{ data\+::\+Dataset\+Info} \&dataset\+Info, Predictions\+In\+Type \&\&ys, const size\+\_\+t num\+Classes, Weights\+In\+Type \&\&weights)
\begin{DoxyCompactList}\small\item\em This constructor can be used for multiclass classification algorithms that can take a \doxyref{data\+::\+Dataset\+Info}{p.}{namespacemlpack_1_1data_aa243ad7e4d29363b858bbc92b732921d} parameter and support weighted learning. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename... M\+L\+Algorithm\+Args$>$ }\\double \textbf{ Evaluate} (const M\+L\+Algorithm\+Args \&... args)
\begin{DoxyCompactList}\small\item\em Train on the training set and assess performance on the validation set by using the class Metric. \end{DoxyCompactList}\item 
M\+L\+Algorithm \& \textbf{ Model} ()
\begin{DoxyCompactList}\small\item\em Access and modify the last trained model. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$typename M\+L\+Algorithm, typename Metric, typename Mat\+Type = arma\+::mat, typename Predictions\+Type = typename Meta\+Info\+Extractor$<$\+M\+L\+Algorithm, Mat\+Type$>$\+::\+Predictions\+Type, typename Weights\+Type = typename Meta\+Info\+Extractor$<$\+M\+L\+Algorithm, Mat\+Type,                 Predictions\+Type$>$\+::\+Weights\+Type$>$\newline
class mlpack\+::cv\+::\+Simple\+C\+V$<$ M\+L\+Algorithm, Metric, Mat\+Type, Predictions\+Type, Weights\+Type $>$}

\doxyref{Simple\+CV}{p.}{classmlpack_1_1cv_1_1SimpleCV} splits data into two sets -\/ training and validation sets -\/ and then runs training on the training set and evaluates performance on the validation set. 

To construct a \doxyref{Simple\+CV}{p.}{classmlpack_1_1cv_1_1SimpleCV} object you need to pass the validation\+Size parameter and arguments that specify data. For example, Softmax\+Regression can be validated in the following way.


\begin{DoxyCode}
\textcolor{comment}{// 100-point 5-dimensional random dataset.}
arma::mat data = arma::randu<arma::mat>(5, 100);
\textcolor{comment}{// Random labels in the [0, 4] interval.}
arma::Row<size\_t> labels =
    arma::randi<arma::Row<size\_t>>(100, arma::distr\_param(0, 4));
\textcolor{keywordtype}{size\_t} numClasses = 5;

\textcolor{keywordtype}{double} validationSize = 0.2;
SimpleCV<SoftmaxRegression<>, Accuracy> cv(validationSize, data, labels,
    numClasses);

\textcolor{keywordtype}{double} lambda = 0.1;
\textcolor{keywordtype}{double} softmaxAccuracy = cv.Evaluate(lambda);
\end{DoxyCode}


In the example above, 80\% of the passed dataset will be used for training, and remaining 20\% will be used for calculating the accuracy metric.


\begin{DoxyTemplParams}{Template Parameters}
{\em M\+L\+Algorithm} & A machine learning algorithm. \\
\hline
{\em Metric} & A metric to assess the quality of a trained model. \\
\hline
{\em Mat\+Type} & The type of data. \\
\hline
{\em Predictions\+Type} & The type of predictions (should be passed when the predictions type is a template parameter in Train methods of the given M\+L\+Algorithm; arma\+::\+Row$<$size\+\_\+t$>$ will be used otherwise). \\
\hline
{\em Weights\+Type} & The type of weights (should be passed when weighted learning is supported, and the weights type is a template parameter in Train methods of the given M\+L\+Algorithm; arma\+::vec will be used otherwise). \\
\hline
\end{DoxyTemplParams}


Definition at line 68 of file simple\+\_\+cv.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1cv_1_1SimpleCV_a2ff628c0b64ff1484a174a44986a8f8d}} 
\index{mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}!Simple\+CV@{Simple\+CV}}
\index{Simple\+CV@{Simple\+CV}!mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}}
\subsubsection{Simple\+C\+V()\hspace{0.1cm}{\footnotesize\ttfamily [1/6]}}
{\footnotesize\ttfamily \textbf{ Simple\+CV} (\begin{DoxyParamCaption}\item[{const double}]{validation\+Size,  }\item[{Mat\+In\+Type \&\&}]{xs,  }\item[{Predictions\+In\+Type \&\&}]{ys }\end{DoxyParamCaption})}



This constructor can be used for regression algorithms and for binary classification algorithms. 


\begin{DoxyParams}{Parameters}
{\em validation\+Size} & A proportion (between 0 and 1) of data used as a validation set. \\
\hline
{\em xs} & Data points to cross-\/validate on. \\
\hline
{\em ys} & Predictions (labels for classification algorithms and responses for regression algorithms) for each data point.\\
\hline
\end{DoxyParams}

\begin{DoxyTemplParams}{Template Parameters}
{\em Mat\+In\+Type} & A type that can be converted to Mat\+Type. \\
\hline
{\em Predictions\+In\+Type} & A type that can be converted to Predictions\+Type. \\
\hline
\end{DoxyTemplParams}
\mbox{\label{classmlpack_1_1cv_1_1SimpleCV_a3b523a0befc766716c2f83ae4de0c409}} 
\index{mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}!Simple\+CV@{Simple\+CV}}
\index{Simple\+CV@{Simple\+CV}!mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}}
\subsubsection{Simple\+C\+V()\hspace{0.1cm}{\footnotesize\ttfamily [2/6]}}
{\footnotesize\ttfamily \textbf{ Simple\+CV} (\begin{DoxyParamCaption}\item[{const double}]{validation\+Size,  }\item[{Mat\+In\+Type \&\&}]{xs,  }\item[{Predictions\+In\+Type \&\&}]{ys,  }\item[{const size\+\_\+t}]{num\+Classes }\end{DoxyParamCaption})}



This constructor can be used for multiclass classification algorithms. 


\begin{DoxyParams}{Parameters}
{\em validation\+Size} & A proportion (between 0 and 1) of data used as a validation set. \\
\hline
{\em xs} & Data points to cross-\/validate on. \\
\hline
{\em ys} & Labels for each data point. \\
\hline
{\em num\+Classes} & Number of classes in the dataset.\\
\hline
\end{DoxyParams}

\begin{DoxyTemplParams}{Template Parameters}
{\em Mat\+In\+Type} & A type that can be converted to Mat\+Type. \\
\hline
{\em Predictions\+In\+Type} & A type that can be converted to Predictions\+Type. \\
\hline
\end{DoxyTemplParams}
\mbox{\label{classmlpack_1_1cv_1_1SimpleCV_a00fb12da682539521fa19f63b6975673}} 
\index{mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}!Simple\+CV@{Simple\+CV}}
\index{Simple\+CV@{Simple\+CV}!mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}}
\subsubsection{Simple\+C\+V()\hspace{0.1cm}{\footnotesize\ttfamily [3/6]}}
{\footnotesize\ttfamily \textbf{ Simple\+CV} (\begin{DoxyParamCaption}\item[{const double}]{validation\+Size,  }\item[{Mat\+In\+Type \&\&}]{xs,  }\item[{const \textbf{ data\+::\+Dataset\+Info} \&}]{dataset\+Info,  }\item[{Predictions\+In\+Type \&\&}]{ys,  }\item[{const size\+\_\+t}]{num\+Classes }\end{DoxyParamCaption})}



This constructor can be used for multiclass classification algorithms that can take a \doxyref{data\+::\+Dataset\+Info}{p.}{namespacemlpack_1_1data_aa243ad7e4d29363b858bbc92b732921d} parameter. 


\begin{DoxyParams}{Parameters}
{\em validation\+Size} & A proportion (between 0 and 1) of data used as a validation set. \\
\hline
{\em xs} & Data points to cross-\/validate on. \\
\hline
{\em dataset\+Info} & Type information for each dimension of the dataset. \\
\hline
{\em ys} & Labels for each data point. \\
\hline
{\em num\+Classes} & Number of classes in the dataset.\\
\hline
\end{DoxyParams}

\begin{DoxyTemplParams}{Template Parameters}
{\em Mat\+In\+Type} & A type that can be converted to Mat\+Type. \\
\hline
{\em Predictions\+In\+Type} & A type that can be converted to Predictions\+Type. \\
\hline
\end{DoxyTemplParams}
\mbox{\label{classmlpack_1_1cv_1_1SimpleCV_aad1230ac63f39932129ec309f127e66d}} 
\index{mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}!Simple\+CV@{Simple\+CV}}
\index{Simple\+CV@{Simple\+CV}!mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}}
\subsubsection{Simple\+C\+V()\hspace{0.1cm}{\footnotesize\ttfamily [4/6]}}
{\footnotesize\ttfamily \textbf{ Simple\+CV} (\begin{DoxyParamCaption}\item[{const double}]{validation\+Size,  }\item[{Mat\+In\+Type \&\&}]{xs,  }\item[{Predictions\+In\+Type \&\&}]{ys,  }\item[{Weights\+In\+Type \&\&}]{weights }\end{DoxyParamCaption})}



This constructor can be used for regression and binary classification algorithms that support weighted learning. 


\begin{DoxyParams}{Parameters}
{\em validation\+Size} & A proportion (between 0 and 1) of data used as a validation set. \\
\hline
{\em xs} & Data points to cross-\/validate on. \\
\hline
{\em ys} & Predictions (labels for classification algorithms and responses for regression algorithms) for each data point. \\
\hline
{\em weights} & Observation weights (for boosting).\\
\hline
\end{DoxyParams}

\begin{DoxyTemplParams}{Template Parameters}
{\em Mat\+In\+Type} & A type that can be converted to Mat\+Type. \\
\hline
{\em Predictions\+In\+Type} & A type that can be converted to Predictions\+Type. \\
\hline
{\em Weights\+In\+Type} & A type that can be converted to Weights\+Type. \\
\hline
\end{DoxyTemplParams}
\mbox{\label{classmlpack_1_1cv_1_1SimpleCV_a9cafb1e9fbdf9ba67c5da36c2e358d47}} 
\index{mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}!Simple\+CV@{Simple\+CV}}
\index{Simple\+CV@{Simple\+CV}!mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}}
\subsubsection{Simple\+C\+V()\hspace{0.1cm}{\footnotesize\ttfamily [5/6]}}
{\footnotesize\ttfamily \textbf{ Simple\+CV} (\begin{DoxyParamCaption}\item[{const double}]{validation\+Size,  }\item[{Mat\+In\+Type \&\&}]{xs,  }\item[{Predictions\+In\+Type \&\&}]{ys,  }\item[{const size\+\_\+t}]{num\+Classes,  }\item[{Weights\+In\+Type \&\&}]{weights }\end{DoxyParamCaption})}



This constructor can be used for multiclass classification algorithms that support weighted learning. 


\begin{DoxyParams}{Parameters}
{\em validation\+Size} & A proportion (between 0 and 1) of data used as a validation set. \\
\hline
{\em xs} & Data points to cross-\/validate on. \\
\hline
{\em ys} & Labels for each data point. \\
\hline
{\em num\+Classes} & Number of classes in the dataset. \\
\hline
{\em weights} & Observation weights (for boosting).\\
\hline
\end{DoxyParams}

\begin{DoxyTemplParams}{Template Parameters}
{\em Mat\+In\+Type} & A type that can be converted to Mat\+Type. \\
\hline
{\em Predictions\+In\+Type} & A type that can be converted to Predictions\+Type. \\
\hline
{\em Weights\+In\+Type} & A type that can be converted to Weights\+Type. \\
\hline
\end{DoxyTemplParams}
\mbox{\label{classmlpack_1_1cv_1_1SimpleCV_a3e1040fd79834f43f1d9450102727d3a}} 
\index{mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}!Simple\+CV@{Simple\+CV}}
\index{Simple\+CV@{Simple\+CV}!mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}}
\subsubsection{Simple\+C\+V()\hspace{0.1cm}{\footnotesize\ttfamily [6/6]}}
{\footnotesize\ttfamily \textbf{ Simple\+CV} (\begin{DoxyParamCaption}\item[{const double}]{validation\+Size,  }\item[{Mat\+In\+Type \&\&}]{xs,  }\item[{const \textbf{ data\+::\+Dataset\+Info} \&}]{dataset\+Info,  }\item[{Predictions\+In\+Type \&\&}]{ys,  }\item[{const size\+\_\+t}]{num\+Classes,  }\item[{Weights\+In\+Type \&\&}]{weights }\end{DoxyParamCaption})}



This constructor can be used for multiclass classification algorithms that can take a \doxyref{data\+::\+Dataset\+Info}{p.}{namespacemlpack_1_1data_aa243ad7e4d29363b858bbc92b732921d} parameter and support weighted learning. 


\begin{DoxyParams}{Parameters}
{\em validation\+Size} & A proportion (between 0 and 1) of data used as a validation set. \\
\hline
{\em xs} & Data points to cross-\/validate on. \\
\hline
{\em dataset\+Info} & Type information for each dimension of the dataset. \\
\hline
{\em ys} & Labels for each data point. \\
\hline
{\em num\+Classes} & Number of classes in the dataset. \\
\hline
{\em weights} & Observation weights (for boosting).\\
\hline
\end{DoxyParams}

\begin{DoxyTemplParams}{Template Parameters}
{\em Mat\+In\+Type} & A type that can be converted to Mat\+Type. \\
\hline
{\em Predictions\+In\+Type} & A type that can be converted to Predictions\+Type. \\
\hline
{\em Weights\+In\+Type} & A type that can be converted to Weights\+Type. \\
\hline
\end{DoxyTemplParams}


\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1cv_1_1SimpleCV_a007c5bdf4563b1afe12053585052e67f}} 
\index{mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}!Evaluate@{Evaluate}}
\index{Evaluate@{Evaluate}!mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}}
\subsubsection{Evaluate()}
{\footnotesize\ttfamily double Evaluate (\begin{DoxyParamCaption}\item[{const M\+L\+Algorithm\+Args \&...}]{args }\end{DoxyParamCaption})}



Train on the training set and assess performance on the validation set by using the class Metric. 


\begin{DoxyParams}{Parameters}
{\em args} & Arguments for the given M\+L\+Algorithm taken by its constructor (in addition to the passed ones in the \doxyref{Simple\+CV}{p.}{classmlpack_1_1cv_1_1SimpleCV} constructor). \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1cv_1_1SimpleCV_ab89814a92c5627562bbc60fb788f978a}} 
\index{mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}!Model@{Model}}
\index{Model@{Model}!mlpack\+::cv\+::\+Simple\+CV@{mlpack\+::cv\+::\+Simple\+CV}}
\subsubsection{Model()}
{\footnotesize\ttfamily M\+L\+Algorithm\& Model (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Access and modify the last trained model. 



The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
/var/www/mlpack.\+ratml.\+org/mlpack.\+org/\+\_\+src/mlpack-\/git/src/mlpack/core/cv/\textbf{ simple\+\_\+cv.\+hpp}\end{DoxyCompactItemize}
