src/mlpack/tests/main_tests/decision_tree_test.cpp
BOOST_AUTO_TEST_CASE(DecisionRegularisationTest)
{
  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);

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

  SetInputParam("minimum_gain_split", 1e-7);

  // Input test data.
  SetInputParam("test", std::make_tuple(info, inputData));
  arma::Row<size_t> pred;
  mlpackMain();
  pred = std::move(CLI::GetParam<arma::Row<size_t>>("predictions"));

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

  SetInputParam("minimum_gain_split", 0.01);

  // Input test data.
  SetInputParam("test", std::move(std::make_tuple(info, inputData)));
  arma::Row<size_t> predRegularised;
  mlpackMain();
  predRegularised = std::move(CLI::GetParam<arma::Row<size_t>>("predictions"));

  size_t count = 0;
  // This part of code is dupliacte with no weighted one.
  for (size_t i = 0; i < 1000; ++i)
  {
    if (pred[i] != predRegularised[i])
      count++;
  }

  BOOST_REQUIRE_GT(count, 0);
}
/**
 * Make sure minimum gain split produces regularised tree.
 */
Make sure minimum gain split produces regularised tree.
Make sure minimum gain split produces regularised tree .
BOOST_AUTO_TEST_CASE(DecisionRegularisationTest)
{
  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);
  SetInputParam("training", std::make_tuple(info, inputData));
  SetInputParam("labels", labels);
  SetInputParam("weights", weights);
  SetInputParam("minimum_gain_split", 1e-7);
  SetInputParam("test", std::make_tuple(info, inputData));
  arma::Row<size_t> pred;
  mlpackMain();
  pred = std::move(CLI::GetParam<arma::Row<size_t>>("predictions"));
  SetInputParam("training", std::make_tuple(info, inputData));
  SetInputParam("labels", std::move(labels));
  SetInputParam("weights", std::move(weights));
  SetInputParam("minimum_gain_split", 0.01);
  SetInputParam("test", std::move(std::make_tuple(info, inputData)));
  arma::Row<size_t> predRegularised;
  mlpackMain();
  predRegularised = std::move(CLI::GetParam<arma::Row<size_t>>("predictions"));
  size_t count = 0;
  for (size_t i = 0; i < 1000; ++i)
  {
    if (pred[i] != predRegularised[i])
      count++;
  }
  BOOST_REQUIRE_GT(count, 0);
}
BOOST_AUTO_TEST_CASE ( DecisionRegularisationTest ) { 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 ) ; SetInputParam ( " " , std :: make_tuple ( info , inputData ) ) ; SetInputParam ( " " , labels ) ; SetInputParam ( " " , weights ) ; SetInputParam ( " " , 1e-7 ) ; SetInputParam ( " " , std :: make_tuple ( info , inputData ) ) ; arma :: Row < size_t > pred ; mlpackMain ( ) ; pred = std :: move ( CLI :: GetParam < arma :: Row < size_t > > ( " " ) ) ; SetInputParam ( " " , std :: make_tuple ( info , inputData ) ) ; SetInputParam ( " " , std :: move ( labels ) ) ; SetInputParam ( " " , std :: move ( weights ) ) ; SetInputParam ( " " , 0.01 ) ; SetInputParam ( " " , std :: move ( std :: make_tuple ( info , inputData ) ) ) ; arma :: Row < size_t > predRegularised ; mlpackMain ( ) ; predRegularised = std :: move ( CLI :: GetParam < arma :: Row < size_t > > ( " " ) ) ; size_t count = 0 ; for ( size_t i = 0 ; i < 1000 ; ++ i ) { if ( pred [ i ] != predRegularised [ i ] ) count ++ ; } BOOST_REQUIRE_GT ( count , 0 ) ; }
Make sure minimum gain split produces regularised tree.
Make sure minimum gain split produces regularised tree .
// Initialize an all-ones weight matrix. // Input training data. // Input test data. // Input training data. // Input test data. // This part of code is dupliacte with no weighted one.