src/mlpack/tests/cv_test.cpp
BOOST_AUTO_TEST_CASE(KFoldCVWithDTTestUnevenBinsWeighted)
{
  arma::mat data;
  arma::Row<size_t> labels;
  data::DatasetInfo datasetInfo;
  MockCategoricalData(data, labels, datasetInfo);
  arma::rowvec weights(data.n_cols, arma::fill::randu);

  size_t numClasses = 5;
  size_t minimumLeafSize = 5;

  KFoldCV<DecisionTree<InformationGain>, Accuracy> cv(7, data, datasetInfo,
      labels, numClasses, weights);
  cv.Evaluate(minimumLeafSize);
  double accuracy = Accuracy::Evaluate(cv.Model(), data, labels);

  // This is a very loose tolerance, but we expect about the same as we would
  // from an individual decision tree training.
  BOOST_REQUIRE_GT(accuracy, 0.7);
}
/**
 * Test k-fold cross-validation with decision trees constructed in multiple
 * ways, but with larger k such that the number of points in each
 * cross-validation bin is not even (the last is smaller) and weights.
 */
Test k-fold cross-validation with decision trees constructed in multiple
ways, but with larger k such that the number of points in each
cross-validation bin is not even (the last is smaller) and weights.
Test k - fold cross - validation with decision trees constructed in multiple ways but with larger k such that the number of points in each cross - validation bin is not even ( the last is smaller ) and weights .
BOOST_AUTO_TEST_CASE(KFoldCVWithDTTestUnevenBinsWeighted)
{
  arma::mat data;
  arma::Row<size_t> labels;
  data::DatasetInfo datasetInfo;
  MockCategoricalData(data, labels, datasetInfo);
  arma::rowvec weights(data.n_cols, arma::fill::randu);
  size_t numClasses = 5;
  size_t minimumLeafSize = 5;
  KFoldCV<DecisionTree<InformationGain>, Accuracy> cv(7, data, datasetInfo,
      labels, numClasses, weights);
  cv.Evaluate(minimumLeafSize);
  double accuracy = Accuracy::Evaluate(cv.Model(), data, labels);
  BOOST_REQUIRE_GT(accuracy, 0.7);
}
BOOST_AUTO_TEST_CASE ( KFoldCVWithDTTestUnevenBinsWeighted ) { arma :: mat data ; arma :: Row < size_t > labels ; data :: DatasetInfo datasetInfo ; MockCategoricalData ( data , labels , datasetInfo ) ; arma :: rowvec weights ( data . n_cols , arma :: fill :: randu ) ; size_t numClasses = 5 ; size_t minimumLeafSize = 5 ; KFoldCV < DecisionTree < InformationGain > , Accuracy > cv ( 7 , data , datasetInfo , labels , numClasses , weights ) ; cv . Evaluate ( minimumLeafSize ) ; double accuracy = Accuracy :: Evaluate ( cv . Model ( ) , data , labels ) ; BOOST_REQUIRE_GT ( accuracy , 0.7 ) ; }
Test k-fold cross-validation with decision trees constructed in multiple
 ways, but with larger k such that the number of points in each
 cross-validation bin is not even (the last is smaller) and weights.
Test k - fold cross - validation with decision trees constructed in multiple ways but with larger k such that the number of points in each cross - validation bin is not even ( the last is smaller ) and weights .
// This is a very loose tolerance, but we expect about the same as we would // from an individual decision tree training.