From 3d8e9edebf71585ef3c8e52cc6a0ddcb91c61420 Mon Sep 17 00:00:00 2001 From: AdarshSantoria Date: Sun, 1 Oct 2023 12:33:15 +0530 Subject: [PATCH] fix random_forest_test --- src/mlpack/tests/random_forest_test.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mlpack/tests/random_forest_test.cpp b/src/mlpack/tests/random_forest_test.cpp index 92b6eb1291..3b76caf52f 100644 --- a/src/mlpack/tests/random_forest_test.cpp +++ b/src/mlpack/tests/random_forest_test.cpp @@ -172,7 +172,7 @@ TEST_CASE("WeightedNumericLearningTest", "[RandomForestTest]") noiseLabels[i] = RandInt(3); // Random label. // Concatenate data matrices. - arma::mat data = arma::join_rows(dataset, noise); + arma::mat fullData = arma::join_rows(dataset, noise); arma::Row fullLabels = arma::join_rows(labels, noiseLabels); // Now set weights. @@ -183,8 +183,8 @@ TEST_CASE("WeightedNumericLearningTest", "[RandomForestTest]") weights[i] = Random(0.0, 0.01); // Low weights for false points. // Train decision tree and random forest. - RandomForest<> rf(dataset, labels, 3, weights, 20, 1); - DecisionTree<> dt(dataset, labels, 3, weights, 5); + RandomForest<> rf(fullData, fullLabels, 3, weights, 20, 1); + DecisionTree<> dt(fullData, fullLabels, 3, weights, 5); // Get performance statistics on test data. arma::mat testDataset; @@ -396,7 +396,7 @@ TEST_CASE("RandomForestNumericTrainReturnEntropy", "[RandomForestTest]") noiseLabels[i] = RandInt(3); // Random label. // Concatenate data matrices. - arma::mat data = arma::join_rows(dataset, noise); + arma::mat fullData = arma::join_rows(dataset, noise); arma::Row fullLabels = arma::join_rows(labels, noiseLabels); // Now set weights. @@ -408,13 +408,13 @@ TEST_CASE("RandomForestNumericTrainReturnEntropy", "[RandomForestTest]") // Test random forest on unweighted numeric dataset. RandomForest rf; - double entropy = rf.Train(dataset, labels, 3, 10, 1); + double entropy = rf.Train(fullData, fullLabels, 3, 10, 1); REQUIRE(std::isfinite(entropy) == true); // Test random forest on weighted numeric dataset. RandomForest wrf; - entropy = wrf.Train(dataset, labels, 3, weights, 10, 1); + entropy = wrf.Train(fullData, fullLabels, 3, weights, 10, 1); REQUIRE(std::isfinite(entropy) == true); } @@ -577,7 +577,7 @@ TEST_CASE("ExtraTreesAccuracyTest", "[RandomForestTest]") noiseLabels[i] = RandInt(3); // Random label. // Concatenate data matrices. - arma::mat data = arma::join_rows(dataset, noise); + arma::mat fullData = arma::join_rows(dataset, noise); arma::Row fullLabels = arma::join_rows(labels, noiseLabels); // Now set weights. @@ -588,7 +588,7 @@ TEST_CASE("ExtraTreesAccuracyTest", "[RandomForestTest]") weights[i] = Random(0.0, 0.01); // Low weights for false points. // Train extra tree. - ExtraTrees<> et(data, fullLabels, 3, weights, 20, 1); + ExtraTrees<> et(fullData, fullLabels, 3, weights, 20, 1); // Get performance statistics on test data. arma::mat testDataset;