12 #ifndef MLPACK_CORE_CV_METRICS_ACCURACY_IMPL_HPP 13 #define MLPACK_CORE_CV_METRICS_ACCURACY_IMPL_HPP 18 template<
typename MLAlgorithm,
typename DataType>
21 const arma::Row<size_t>& labels)
23 util::CheckSameSizes(data, labels,
"Accuracy::Evaluate()");
25 arma::Row<size_t> predictedLabels;
26 model.Classify(data, predictedLabels);
27 size_t amountOfCorrectPredictions = arma::sum(predictedLabels == labels);
29 return (
double) amountOfCorrectPredictions / labels.n_elem;
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
static double Evaluate(MLAlgorithm &model, const DataType &data, const arma::Row< size_t > &labels)
Run classification and calculate accuracy.
Definition: accuracy_impl.hpp:19