mlpack
Functions
decision_tree_regressor_test.cpp File Reference
#include <mlpack/core.hpp>
#include <mlpack/methods/decision_tree/decision_tree_regressor.hpp>
#include <mlpack/methods/decision_tree/mad_gain.hpp>
#include <mlpack/methods/decision_tree/mse_gain.hpp>
#include <mlpack/methods/decision_tree/random_dimension_select.hpp>
#include <mlpack/methods/decision_tree/multiple_random_dimension_select.hpp>
#include <mlpack/core/math/random.hpp>
#include "catch.hpp"
#include "serialization.hpp"
#include "mock_categorical_data.hpp"
#include "test_function_tools.hpp"
Include dependency graph for decision_tree_regressor_test.cpp:

Functions

void CreateMultiSplitData (arma::mat &d, arma::rowvec &r, const size_t count, arma::rowvec &values)
 Creates dataset with 5 groups with all the points in same group have exactly same responses.
 
 TEST_CASE ("MSEGainPerfectTest", "[DecisionTreeRegressorTest]")
 Make sure the MSE gain is zero when the responses are perfect.
 
 TEST_CASE ("MSEGainEmptyTest", "[DecisionTreeRegressorTest]")
 The MSE gain of an empty vector is 0.
 
 TEST_CASE ("MSEGainHandCalculation", "[DecisionTreeRegressorTest]")
 Making sure that MSE gain is evaluated correctly by doing calculation by hand.
 
 TEST_CASE ("MADGainPerfectTest", "[DecisionTreeRegressorTest]")
 Make sure the MAD gain is zero when the responses are perfect.
 
 TEST_CASE ("MADGainNormalTest", "[DecisionTreeRegressorTest")
 Make sure that when mean of responses is zero, MAD_gain = mean of absolute values of the distribution.
 
 TEST_CASE ("MADGainEmptyTest", "[DecisionTreeRegressorTest]")
 The MAD gain of an empty vector is 0.
 
 TEST_CASE ("MADGainHandCalculation", "[DecisionTreeRegressorTest]")
 Making sure that MAD gain is evaluated correctly by doing calculation by hand.
 
 TEST_CASE ("AllCategoricalSplitSimpleSplitTest_", "[DecisionTreeRegressorTest]")
 Check that AllCategoricalSplit will split when the split is obviously better.
 
 TEST_CASE ("AllCategoricalSplitMinSamplesTest_", "[DecisionTreeRegressorTest]")
 Make sure that AllCategoricalSplit respects the minimum number of samples required to split.
 
 TEST_CASE ("AllCategoricalSplitNoGainTest_", "[DecisionTreeRegressorTest]")
 Check that no split is made when it doesn't get us anything.
 
 TEST_CASE ("BestBinaryNumericSplitSimpleSplitTest_", "[DecisionTreeRegressorTest]")
 Check that the BestBinaryNumericSplit will split on an obviously splittable dimension.
 
 TEST_CASE ("BestBinaryNumericSplitMinSamplesTest_", "[DecisionTreeRegressorTest]")
 Check that the BestBinaryNumericSplit won't split if not enough points are given.
 
 TEST_CASE ("BestBinaryNumericSplitNoGainTest_", "[DecisionTreeRegressorTest]")
 Check that the BestBinaryNumericSplit doesn't split a dimension that gives no gain.
 
 TEST_CASE ("RandomBinaryNumericSplitAlwaysSplit_", "[DecisionTreeRegressorTest]")
 Check that the RandomBinaryNumericSplit always splits when splitIfBetterGain is false.
 
 TEST_CASE ("RandomBinaryNumericSplitMinSamplesTest_", "[DecisionTreeRegressorTest]")
 Check that the RandomBinaryNumericSplit won't split if not enough points are given.
 
 TEST_CASE ("RandomBinaryNumericSplitNoGainTest_", "[DecisionTreeRegressorTest]")
 Check that the RandomBinaryNumericSplit doesn't split a dimension that gives no gain when splitIfBetterGain is true.
 
 TEST_CASE ("BasicConstructionTest_", "[DecisionTreeRegressorTest]")
 A basic construction of the decision tree—ensure that we can create the tree and that it split at least once.
 
 TEST_CASE ("BasicConstructionTestWithWeight_", "[DecisionTreeRegressorTest]")
 Construct a tree with weighted responses.
 
 TEST_CASE ("PerfectTrainingSet_", "[DecisionTreeRegressorTest]")
 Construct the decision tree on numeric data only and see that we can fit it exactly and achieve perfect performance on the training set.
 
 TEST_CASE ("PerfectTrainingSetWithWeight_", "[DecisionTreeRegressorTest]")
 Construct the decision tree with weighted responses.
 
 TEST_CASE ("MultiSplitTest1", "[DecisionTreeRegressorTest]")
 Test that the tree is able to perfectly fit all the obvious splits present in the data. More...
 
 TEST_CASE ("MultiSplitTest2", "[DecisionTreeRegressorTest]")
 Test that the tree is able to perfectly fit all the obvious splits present in the data. More...
 
 TEST_CASE ("MultiSplitTest3", "[DecisionTreeRegressorTest]")
 Test that the tree is able to perfectly fit all the obvious splits present in the data. More...
 
 TEST_CASE ("NumericalBuildTest", "[DecisionTreeRegressorTest]")
 Test that the tree builds correctly on unweighted numerical dataset.
 
 TEST_CASE ("NumericalBuildTestWithWeights", "[DecisionTreeRegressorTest]")
 Test that the tree builds correctly on weighted numerical dataset.
 
 TEST_CASE ("CategoricalBuildTest_", "[DecisionTreeRegressorTest]")
 Test that we can build a decision tree on a simple categorical dataset.
 
 TEST_CASE ("CategoricalBuildTestWithWeight_", "[DecisionTreeRegressorTest]")
 Test that we can build a decision tree with weights on a simple categorical dataset.
 
 TEST_CASE ("CategoricalWeightedBuildTest_", "[DecisionTreeRegressorTest]")
 Test that we can build a decision tree on a simple categorical dataset using weights, with low-weight noise added.
 
 TEST_CASE ("CategoricalMADGainWeightedBuildTest", "[DecisionTreeRegressorTest]")
 Test that we can build a decision tree using MAD gain on a simple categorical dataset using weights, with low-weight noise added.
 
 TEST_CASE ("SimpleGeneralizationTest_", "[DecisionTreeRegressorTest]")
 Test that the decision tree generalizes reasonably.
 
 TEST_CASE ("SimpleGeneralizationFMatTest_", "[DecisionTreeRegressorTest]")
 Test that the decision tree generalizes reasonably when built on float data.
 
 TEST_CASE ("WeightedDecisionTreeTest_", "[DecisionTreeRegressorTest]")
 Test that we can build a decision tree using weighted data (where the low-weighted data is random noise), and that the tree still builds correctly enough to get good results.
 
 TEST_CASE ("WeightedDecisionTreeMADGainTest", "[DecisionTreeRegressorTest]")
 Test that we can build a decision tree using weighted data (where the low-weighted data is random noise) with MAD gain, and that the tree still builds correctly enough to get good results.
 

Detailed Description

Author
Rishabh Garg

Tests for the DecisionTreeRegressor class and related classes.

mlpack is free software; you may redistribute it and/or modify it under the terms of the 3-clause BSD license. You should have received a copy of the 3-clause BSD license along with mlpack. If not, see http://www.opensource.org/licenses/BSD-3-Clause for more information.

Function Documentation

◆ TEST_CASE() [1/3]

TEST_CASE ( "MultiSplitTest1"  ,
""  [DecisionTreeRegressorTest] 
)

Test that the tree is able to perfectly fit all the obvious splits present in the data.

| | 2 | xxxxxx | | 1 | xxxxxx xxxxxx | | 0 |xxxxxx xxxxxx |___________________________________

◆ TEST_CASE() [2/3]

TEST_CASE ( "MultiSplitTest2"  ,
""  [DecisionTreeRegressorTest] 
)

Test that the tree is able to perfectly fit all the obvious splits present in the data.

Same test as above, but with less data.

◆ TEST_CASE() [3/3]

TEST_CASE ( "MultiSplitTest3"  ,
""  [DecisionTreeRegressorTest] 
)

Test that the tree is able to perfectly fit all the obvious splits present in the data.

| 20 | xxxxxx | | 15 | xxxxxx | | 10 | xxxxxx | | 5 | xxxxxx | | 0 |xxxxxx |________________________________________