src/mlpack/tests/cv_test.cpp
BOOST_AUTO_TEST_CASE(MSETest)
{
  // Making two points that define the linear function f(x) = x - 1
  arma::mat trainingData("0 1");
  arma::rowvec trainingResponses("-1 0");

  LinearRegression lr(trainingData, trainingResponses);

  // Making three responses that differ from the correct ones by 0, 1, and 2
  // respectively
  arma::mat data("2 3 4");
  arma::rowvec responses("1 3 5");

  double expectedMSE = (0 * 0 + 1 * 1 + 2 * 2) / 3.0;

  BOOST_REQUIRE_CLOSE(MSE::Evaluate(lr, data, responses), expectedMSE, 1e-5);
}
/**
 * Test the mean squared error.
 */
Test the mean squared error.
Test the mean squared error .
BOOST_AUTO_TEST_CASE(MSETest)
{
  arma::mat trainingData("0 1");
  arma::rowvec trainingResponses("-1 0");
  LinearRegression lr(trainingData, trainingResponses);
  arma::mat data("2 3 4");
  arma::rowvec responses("1 3 5");
  double expectedMSE = (0 * 0 + 1 * 1 + 2 * 2) / 3.0;
  BOOST_REQUIRE_CLOSE(MSE::Evaluate(lr, data, responses), expectedMSE, 1e-5);
}
BOOST_AUTO_TEST_CASE ( MSETest ) { arma :: mat trainingData ( " " ) ; arma :: rowvec trainingResponses ( " " ) ; LinearRegression lr ( trainingData , trainingResponses ) ; arma :: mat data ( " " ) ; arma :: rowvec responses ( " " ) ; double expectedMSE = ( 0 * 0 + 1 * 1 + 2 * 2 ) / 3.0 ; BOOST_REQUIRE_CLOSE ( MSE :: Evaluate ( lr , data , responses ) , expectedMSE , 1e-5 ) ; }
Test the mean squared error.
Test the mean squared error .
// Making two points that define the linear function f(x) = x - 1 // Making three responses that differ from the correct ones by 0, 1, and 2 // respectively