src/mlpack/tests/main_tests/logistic_regression_test.cpp
BOOST_AUTO_TEST_CASE(LRResponsesRepresentationTest)
{
  arma::mat trainX1({{1.0, 2.0, 3.0}, {1.0, 4.0, 9.0}, {0, 1, 1}});
  arma::mat testX({{4.0, 5.0}, {1.0, 6.0}});

  SetInputParam("training", std::move(trainX1));
  SetInputParam("test", testX);

  // The first solution.
  mlpackMain();

  // Get the output.
  const arma::Row<size_t> testY1 =
      std::move(CLI::GetParam<arma::Row<size_t>>("output"));

  // Reset the settings.
  bindings::tests::CleanMemory();
  CLI::ClearSettings();
  CLI::RestoreSettings(testName);

  // Now train by providing labels as extra parameter.
  arma::mat trainX2({{1.0, 2.0, 3.0}, {1.0, 4.0, 9.0}});
  arma::Row<size_t> trainY2({0, 1, 1});

  SetInputParam("training", std::move(trainX2));
  SetInputParam("labels", std::move(trainY2));
  SetInputParam("test", std::move(testX));

  // The second solution.
  mlpackMain();

  // get the output
  const arma::Row<size_t> &testY2 =
      CLI::GetParam<arma::Row<size_t>>("output");

  // Both solutions should be equal.
  BOOST_REQUIRE_EQUAL_COLLECTIONS(testY1.begin(), testY1.end(),
                                  testY2.begin(), testY2.end());
}
/**
 * Checking two options of specifying responses (extra row in train matrix and
 * extra parameter) and ensuring that predictions are the same.
 */
Checking two options of specifying responses (extra row in train matrix and
extra parameter) and ensuring that predictions are the same.
Checking two options of specifying responses ( extra row in train matrix and extra parameter ) and ensuring that predictions are the same .
BOOST_AUTO_TEST_CASE(LRResponsesRepresentationTest)
{
  arma::mat trainX1({{1.0, 2.0, 3.0}, {1.0, 4.0, 9.0}, {0, 1, 1}});
  arma::mat testX({{4.0, 5.0}, {1.0, 6.0}});
  SetInputParam("training", std::move(trainX1));
  SetInputParam("test", testX);
  mlpackMain();
  const arma::Row<size_t> testY1 =
      std::move(CLI::GetParam<arma::Row<size_t>>("output"));
  bindings::tests::CleanMemory();
  CLI::ClearSettings();
  CLI::RestoreSettings(testName);
  arma::mat trainX2({{1.0, 2.0, 3.0}, {1.0, 4.0, 9.0}});
  arma::Row<size_t> trainY2({0, 1, 1});
  SetInputParam("training", std::move(trainX2));
  SetInputParam("labels", std::move(trainY2));
  SetInputParam("test", std::move(testX));
  mlpackMain();
  const arma::Row<size_t> &testY2 =
      CLI::GetParam<arma::Row<size_t>>("output");
  BOOST_REQUIRE_EQUAL_COLLECTIONS(testY1.begin(), testY1.end(),
                                  testY2.begin(), testY2.end());
}
BOOST_AUTO_TEST_CASE ( LRResponsesRepresentationTest ) { arma :: mat trainX1 ( { { 1.0 , 2.0 , 3.0 } , { 1.0 , 4.0 , 9.0 } , { 0 , 1 , 1 } } ) ; arma :: mat testX ( { { 4.0 , 5.0 } , { 1.0 , 6.0 } } ) ; SetInputParam ( " " , std :: move ( trainX1 ) ) ; SetInputParam ( " " , testX ) ; mlpackMain ( ) ; const arma :: Row < size_t > testY1 = std :: move ( CLI :: GetParam < arma :: Row < size_t > > ( " " ) ) ; bindings :: tests :: CleanMemory ( ) ; CLI :: ClearSettings ( ) ; CLI :: RestoreSettings ( testName ) ; arma :: mat trainX2 ( { { 1.0 , 2.0 , 3.0 } , { 1.0 , 4.0 , 9.0 } } ) ; arma :: Row < size_t > trainY2 ( { 0 , 1 , 1 } ) ; SetInputParam ( " " , std :: move ( trainX2 ) ) ; SetInputParam ( " " , std :: move ( trainY2 ) ) ; SetInputParam ( " " , std :: move ( testX ) ) ; mlpackMain ( ) ; const arma :: Row < size_t > & testY2 = CLI :: GetParam < arma :: Row < size_t > > ( " " ) ; BOOST_REQUIRE_EQUAL_COLLECTIONS ( testY1 . begin ( ) , testY1 . end ( ) , testY2 . begin ( ) , testY2 . end ( ) ) ; }
Checking two options of specifying responses (extra row in train matrix and
 extra parameter) and ensuring that predictions are the same.
Checking two options of specifying responses ( extra row in train matrix and extra parameter ) and ensuring that predictions are the same .
// The first solution. // Get the output. // Reset the settings. // Now train by providing labels as extra parameter. // The second solution. // get the output // Both solutions should be equal.