src/mlpack/tests/main_tests/decision_tree_test.cpp
BOOST_AUTO_TEST_CASE(DecisionTreeCategoricalOutputDimensionTest)
{
  arma::mat inputData;
  DatasetInfo info;
  if (!data::Load("braziltourism.arff", inputData, info))
    BOOST_FAIL("Cannot load train dataset braziltourism.arff!");

  arma::Row<size_t> labels;
  if (!data::Load("braziltourism_labels.txt", labels))
    BOOST_FAIL("Cannot load labels for braziltourism_labels.txt");

  // Initialize an all-ones weight matrix.
  arma::mat weights(1, labels.n_cols, arma::fill::ones);

  arma::mat testData;
  if (!data::Load("braziltourism_test.arff", testData, info))
    BOOST_FAIL("Cannot load test dataset braziltourism_test.arff!");

  size_t testSize = testData.n_cols;

  // Input training data.
  SetInputParam("training", std::make_tuple(info, inputData));
  SetInputParam("labels", std::move(labels));
  SetInputParam("weights", std::move(weights));

  // Input test data.
  SetInputParam("test", std::make_tuple(info, testData));

  mlpackMain();

  // Check that number of output points are equal to number of input points.
  BOOST_REQUIRE_EQUAL(CLI::GetParam<arma::Row<size_t>>("predictions").n_cols,
      testSize);
  BOOST_REQUIRE_EQUAL(CLI::GetParam<arma::mat>("probabilities").n_cols,
      testSize);

  // Check number of output rows equals number of classes in case of
  // probabilities and 1 for predictions.
  BOOST_REQUIRE_EQUAL(
      CLI::GetParam<arma::Row<size_t>>("predictions").n_rows, 1);
  BOOST_REQUIRE_EQUAL(CLI::GetParam<arma::mat>("probabilities").n_rows, 6);
}
/**
 * Check that number of output points and number
 * of input points are equal for categorical dataset.
 */
Check that number of output points and number
of input points are equal for categorical dataset.
Check that number of output points and number of input points are equal for categorical dataset .
BOOST_AUTO_TEST_CASE(DecisionTreeCategoricalOutputDimensionTest)
{
  arma::mat inputData;
  DatasetInfo info;
  if (!data::Load("braziltourism.arff", inputData, info))
    BOOST_FAIL("Cannot load train dataset braziltourism.arff!");
  arma::Row<size_t> labels;
  if (!data::Load("braziltourism_labels.txt", labels))
    BOOST_FAIL("Cannot load labels for braziltourism_labels.txt");
  arma::mat weights(1, labels.n_cols, arma::fill::ones);
  arma::mat testData;
  if (!data::Load("braziltourism_test.arff", testData, info))
    BOOST_FAIL("Cannot load test dataset braziltourism_test.arff!");
  size_t testSize = testData.n_cols;
  SetInputParam("training", std::make_tuple(info, inputData));
  SetInputParam("labels", std::move(labels));
  SetInputParam("weights", std::move(weights));
  SetInputParam("test", std::make_tuple(info, testData));
  mlpackMain();
  BOOST_REQUIRE_EQUAL(CLI::GetParam<arma::Row<size_t>>("predictions").n_cols,
      testSize);
  BOOST_REQUIRE_EQUAL(CLI::GetParam<arma::mat>("probabilities").n_cols,
      testSize);
  BOOST_REQUIRE_EQUAL(
      CLI::GetParam<arma::Row<size_t>>("predictions").n_rows, 1);
  BOOST_REQUIRE_EQUAL(CLI::GetParam<arma::mat>("probabilities").n_rows, 6);
}
BOOST_AUTO_TEST_CASE ( DecisionTreeCategoricalOutputDimensionTest ) { arma :: mat inputData ; DatasetInfo info ; if ( ! data :: Load ( " " , inputData , info ) ) BOOST_FAIL ( " " ) ; arma :: Row < size_t > labels ; if ( ! data :: Load ( " " , labels ) ) BOOST_FAIL ( " " ) ; arma :: mat weights ( 1 , labels . n_cols , arma :: fill :: ones ) ; arma :: mat testData ; if ( ! data :: Load ( " " , testData , info ) ) BOOST_FAIL ( " " ) ; size_t testSize = testData . n_cols ; SetInputParam ( " " , std :: make_tuple ( info , inputData ) ) ; SetInputParam ( " " , std :: move ( labels ) ) ; SetInputParam ( " " , std :: move ( weights ) ) ; SetInputParam ( " " , std :: make_tuple ( info , testData ) ) ; mlpackMain ( ) ; BOOST_REQUIRE_EQUAL ( CLI :: GetParam < arma :: Row < size_t > > ( " " ) . n_cols , testSize ) ; BOOST_REQUIRE_EQUAL ( CLI :: GetParam < arma :: mat > ( " " ) . n_cols , testSize ) ; BOOST_REQUIRE_EQUAL ( CLI :: GetParam < arma :: Row < size_t > > ( " " ) . n_rows , 1 ) ; BOOST_REQUIRE_EQUAL ( CLI :: GetParam < arma :: mat > ( " " ) . n_rows , 6 ) ; }
Check that number of output points and number
 of input points are equal for categorical dataset.
Check that number of output points and number of input points are equal for categorical dataset .
// Initialize an all-ones weight matrix. // Input training data. // Input test data. // Check that number of output points are equal to number of input points. // Check number of output rows equals number of classes in case of // probabilities and 1 for predictions.