mlpack
confusion_matrix_impl.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_CORE_DATA_CONFUSION_MATRIX_IMPL_HPP
14 #define MLPACK_CORE_DATA_CONFUSION_MATRIX_IMPL_HPP
15 
16 // In case it hasn't been included yet.
17 #include "confusion_matrix.hpp"
18 
19 namespace mlpack {
20 namespace data {
21 
49 template<typename eT>
50 void ConfusionMatrix(const arma::Row<size_t> predictors,
51  const arma::Row<size_t> responses,
52  arma::Mat<eT>& output,
53  const size_t numClasses)
54 {
55  // Loop over the actual labels and predicted labels and add the count.
56  output = arma::zeros<arma::Mat<eT> >(numClasses, numClasses);
57  for (size_t i = 0; i < predictors.n_elem; ++i)
58  {
59  output.at(predictors[i], responses[i])++;
60  }
61 }
62 
63 } // namespace data
64 } // namespace mlpack
65 
66 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
void ConfusionMatrix(const arma::Row< size_t > predictors, const arma::Row< size_t > responses, arma::Mat< eT > &output, const size_t numClasses)
A confusion matrix is a summary of prediction results on a classification problem.
Definition: confusion_matrix_impl.hpp:50