diff --git a/src/mlpack/methods/decision_tree/mse_gain.hpp b/src/mlpack/methods/decision_tree/mse_gain.hpp index 5cc8876625..8f46a9bf11 100644 --- a/src/mlpack/methods/decision_tree/mse_gain.hpp +++ b/src/mlpack/methods/decision_tree/mse_gain.hpp @@ -41,10 +41,10 @@ class MSEGain * @param end End index. */ template - double Evaluate(const VecType& values, - const WeightVecType& weights, - const size_t begin, - const size_t end) + static double Evaluate(const VecType& values, + const WeightVecType& weights, + const size_t begin, + const size_t end) { double mse = 0.0; @@ -85,8 +85,8 @@ class MSEGain * @param weights Weights associated to each value. */ template - double Evaluate(const VecType& values, - const WeightVecType& weights) + static double Evaluate(const VecType& values, + const WeightVecType& weights) { // Corner case: if there are no elements, the impurity is zero. if (values.n_elem == 0) diff --git a/src/mlpack/tests/decision_tree_regressor_test.cpp b/src/mlpack/tests/decision_tree_regressor_test.cpp index ce32f90ed8..df810b0f36 100644 --- a/src/mlpack/tests/decision_tree_regressor_test.cpp +++ b/src/mlpack/tests/decision_tree_regressor_test.cpp @@ -77,8 +77,8 @@ TEST_CASE("MSEGainPerfectTest", "[DecisionTreeRegressorTest]") arma::rowvec responses; responses.ones(10); - MSEGain f; - REQUIRE(f.Evaluate(responses, weights) == Approx(0.0).margin(1e-5)); + REQUIRE(MSEGain::Evaluate(responses, weights) == + Approx(0.0).margin(1e-5)); } /** @@ -89,9 +89,10 @@ TEST_CASE("MSEGainEmptyTest", "[DecisionTreeRegressorTest]") arma::rowvec weights = arma::ones(10); arma::rowvec responses; - MSEGain f; - REQUIRE(f.Evaluate(responses, weights) == Approx(0.0).margin(1e-5)); - REQUIRE(f.Evaluate(responses, weights) == Approx(0.0).margin(1e-5)); + REQUIRE(MSEGain::Evaluate(responses, weights) == + Approx(0.0).margin(1e-5)); + REQUIRE(MSEGain::Evaluate(responses, weights) == + Approx(0.0).margin(1e-5)); } /** @@ -107,9 +108,9 @@ TEST_CASE("MSEGainHandCalculation", "[DecisionTreeRegressorTest]") const double gain = -27.08999; const double weightedGain = -27.53960; - MSEGain f; - REQUIRE(f.Evaluate(responses, weights) == Approx(gain).margin(1e-5)); - REQUIRE(f.Evaluate(responses, weights) == + REQUIRE(MSEGain::Evaluate(responses, weights) == + Approx(gain).margin(1e-5)); + REQUIRE(MSEGain::Evaluate(responses, weights) == Approx(weightedGain).margin(1e-5)); } @@ -123,7 +124,7 @@ TEST_CASE("MADGainPerfectTest", "[DecisionTreeRegressorTest]") responses.ones(10); REQUIRE(MADGain::Evaluate(responses, weights) == - Approx(0.0).margin(1e-5)); + Approx(0.0).margin(1e-5)); } /** @@ -156,9 +157,9 @@ TEST_CASE("MADGainEmptyTest", "[DecisionTreeRegressorTest]") arma::rowvec responses; REQUIRE(MADGain::Evaluate(responses, weights) == - Approx(0.0).margin(1e-5)); + Approx(0.0).margin(1e-5)); REQUIRE(MADGain::Evaluate(responses, weights) == - Approx(0.0).margin(1e-5)); + Approx(0.0).margin(1e-5)); } /** @@ -175,7 +176,7 @@ TEST_CASE("MADGainHandCalculation", "[DecisionTreeRegressorTest]") const double weightedGain = -3.8592; REQUIRE(MADGain::Evaluate(responses, weights) == - Approx(gain).margin(1e-5)); + Approx(gain).margin(1e-5)); REQUIRE(MADGain::Evaluate(responses, weights) == Approx(weightedGain).margin(1e-5)); }