src/mlpack/tests/cv_test.cpp
BOOST_AUTO_TEST_CASE(KFoldCVMSETest)
{
  // Defining dataset with two sets of responses for the same two data points.
  arma::mat data("0 1  0 1");
  arma::rowvec responses("0 1  1 3");

  // 2-fold cross-validation, no shuffling.
  KFoldCV<LinearRegression, MSE> cv(2, data, responses, false);

  // In each of two validation tests the MSE value should be the same.
  double expectedMSE =
      double((1 - 0) * (1 - 0) + (3 - 1) * (3 - 1)) / 2 * 2 / 2;

  BOOST_REQUIRE_CLOSE(cv.Evaluate(), expectedMSE, 1e-5);

  // Assert we can access a trained model without the exception of
  // uninitialization.
  cv.Model();
}
/**
 * Test k-fold cross-validation with the MSE metric.
 */
Test k-fold cross-validation with the MSE metric.
Test k - fold cross - validation with the MSE metric .
BOOST_AUTO_TEST_CASE(KFoldCVMSETest)
{
  arma::mat data("0 1  0 1");
  arma::rowvec responses("0 1  1 3");
  KFoldCV<LinearRegression, MSE> cv(2, data, responses, false);
  double expectedMSE =
      double((1 - 0) * (1 - 0) + (3 - 1) * (3 - 1)) / 2 * 2 / 2;
  BOOST_REQUIRE_CLOSE(cv.Evaluate(), expectedMSE, 1e-5);
  cv.Model();
}
BOOST_AUTO_TEST_CASE ( KFoldCVMSETest ) { arma :: mat data ( " " ) ; arma :: rowvec responses ( " " ) ; KFoldCV < LinearRegression , MSE > cv ( 2 , data , responses , false ) ; double expectedMSE = double ( ( 1 - 0 ) * ( 1 - 0 ) + ( 3 - 1 ) * ( 3 - 1 ) ) / 2 * 2 / 2 ; BOOST_REQUIRE_CLOSE ( cv . Evaluate ( ) , expectedMSE , 1e-5 ) ; cv . Model ( ) ; }
Test k-fold cross-validation with the MSE metric.
Test k - fold cross - validation with the MSE metric .
// Defining dataset with two sets of responses for the same two data points. // 2-fold cross-validation, no shuffling. // In each of two validation tests the MSE value should be the same. // Assert we can access a trained model without the exception of // uninitialization.