|
template<typename MatInType , typename PredictionsInType > |
| SimpleCV (const double validationSize, MatInType &&xs, PredictionsInType &&ys) |
| This constructor can be used for regression algorithms and for binary classification algorithms. More...
|
|
template<typename MatInType , typename PredictionsInType > |
| SimpleCV (const double validationSize, MatInType &&xs, PredictionsInType &&ys, const size_t numClasses) |
| This constructor can be used for multiclass classification algorithms. More...
|
|
template<typename MatInType , typename PredictionsInType > |
| SimpleCV (const double validationSize, MatInType &&xs, const data::DatasetInfo &datasetInfo, PredictionsInType &&ys, const size_t numClasses) |
| This constructor can be used for multiclass classification algorithms that can take a data::DatasetInfo parameter. More...
|
|
template<typename MatInType , typename PredictionsInType , typename WeightsInType > |
| SimpleCV (const double validationSize, MatInType &&xs, PredictionsInType &&ys, WeightsInType &&weights) |
| This constructor can be used for regression and binary classification algorithms that support weighted learning. More...
|
|
template<typename MatInType , typename PredictionsInType , typename WeightsInType > |
| SimpleCV (const double validationSize, MatInType &&xs, PredictionsInType &&ys, const size_t numClasses, WeightsInType &&weights) |
| This constructor can be used for multiclass classification algorithms that support weighted learning. More...
|
|
template<typename MatInType , typename PredictionsInType , typename WeightsInType > |
| SimpleCV (const double validationSize, MatInType &&xs, const data::DatasetInfo &datasetInfo, PredictionsInType &&ys, const size_t numClasses, WeightsInType &&weights) |
| This constructor can be used for multiclass classification algorithms that can take a data::DatasetInfo parameter and support weighted learning. More...
|
|
template<typename... MLAlgorithmArgs> |
double | Evaluate (const MLAlgorithmArgs &... args) |
| Train on the training set and assess performance on the validation set by using the class Metric. More...
|
|
MLAlgorithm & | Model () |
| Access and modify the last trained model.
|
|
template<typename MIT , typename PIT > |
| SimpleCV (const double validationSize, MIT &&xs, PIT &&ys) |
|
template<typename MIT , typename PIT > |
| SimpleCV (const double validationSize, MIT &&xs, PIT &&ys, const size_t numClasses) |
|
template<typename MIT , typename PIT > |
| SimpleCV (const double validationSize, MIT &&xs, const data::DatasetInfo &datasetInfo, PIT &&ys, const size_t numClasses) |
|
template<typename MIT , typename PIT , typename WIT > |
| SimpleCV (const double validationSize, MIT &&xs, PIT &&ys, WIT &&weights) |
|
template<typename MIT , typename PIT , typename WIT > |
| SimpleCV (const double validationSize, MIT &&xs, PIT &&ys, const size_t numClasses, WIT &&weights) |
|
template<typename MIT , typename PIT , typename WIT > |
| SimpleCV (const double validationSize, MIT &&xs, const data::DatasetInfo &datasetInfo, PIT &&ys, const size_t numClasses, WIT &&weights) |
|
template<typename MIT , typename PIT > |
| SimpleCV (Base &&base, const double validationSize, MIT &&xs, PIT &&ys) |
|
template<typename MIT , typename PIT , typename WIT > |
| SimpleCV (Base &&base, const double validationSize, MIT &&xs, PIT &&ys, WIT &&weights) |
|
template<typename MLAlgorithm, typename Metric, typename MatType = arma::mat, typename PredictionsType = typename MetaInfoExtractor<MLAlgorithm, MatType>::PredictionsType, typename WeightsType = typename MetaInfoExtractor<MLAlgorithm, MatType, PredictionsType>::WeightsType>
class mlpack::cv::SimpleCV< MLAlgorithm, Metric, MatType, PredictionsType, WeightsType >
SimpleCV 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 SimpleCV object you need to pass the validationSize parameter and arguments that specify data. For example, SoftmaxRegression can be validated in the following way.
arma::mat data = arma::randu<arma::mat>(5, 100);
arma::Row<size_t> labels =
arma::randi<arma::Row<size_t>>(100, arma::distr_param(0, 4));
size_t numClasses = 5;
double validationSize = 0.2;
SimpleCV<SoftmaxRegression<>, Accuracy> cv(validationSize, data, labels,
numClasses);
double lambda = 0.1;
double softmaxAccuracy = cv.Evaluate(lambda);
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.
- Template Parameters
-
MLAlgorithm | A machine learning algorithm. |
Metric | A metric to assess the quality of a trained model. |
MatType | The type of data. |
PredictionsType | The type of predictions (should be passed when the predictions type is a template parameter in Train methods of the given MLAlgorithm; arma::Row<size_t> will be used otherwise). |
WeightsType | 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 MLAlgorithm; arma::vec will be used otherwise). |