diff --git a/src/mlpack/methods/decision_tree/fitness_functions/sse_gain.hpp b/src/mlpack/methods/xgboost/loss_functions/sse_loss.hpp similarity index 81% rename from src/mlpack/methods/decision_tree/fitness_functions/sse_gain.hpp rename to src/mlpack/methods/xgboost/loss_functions/sse_loss.hpp index b369128aaa..1029fa06af 100644 --- a/src/mlpack/methods/decision_tree/fitness_functions/sse_gain.hpp +++ b/src/mlpack/methods/xgboost/loss_functions/sse_loss.hpp @@ -1,8 +1,8 @@ /** - * @file methods/decision_tree/gain_functions/sse_gain.hpp + * @file methods/xgboost/loss_functions/sse_loss.hpp * @author Rishabh Garg * - * The sum of squared error loss class, which is a loss function for gradient + * The sum of squared error loss class, which is a loss funtion for gradient * xgboost based decision trees. * * mlpack is free software; you may redistribute it and/or modify it under the @@ -10,8 +10,8 @@ * 3-clause BSD license along with mlpack. If not, see * http://www.opensource.org/licenses/BSD-3-Clause for more information. */ -#ifndef MLPACK_METHODS_DECISION_TREE_SSE_GAIN_HPP -#define MLPACK_METHODS_DECISION_TREE_SSE_GAIN_HPP +#ifndef MLPACK_METHODS_XGBOOST_LOSS_FUNCTIONS_SSE_LOSS_HPP +#define MLPACK_METHODS_XGBOOST_LOSS_FUNCTIONS_SSE_LOSS_HPP #include @@ -25,13 +25,13 @@ namespace mlpack { * * Loss = 1 / 2 * (Observed - Predicted)^2 */ -class SSEGain +class SSELoss { public: // Default constructor---No regularization. - SSEGain() : alpha(0), lambda(0) { /* Nothing to do. */} + SSELoss() : alpha(0), lambda(0) { /* Nothing to do. */} - SSEGain(const double alpha, const double lambda): + SSELoss(const double alpha, const double lambda): alpha(alpha), lambda(lambda) { // Nothing to do. @@ -66,15 +66,8 @@ class SSEGain * @param begin The begin index to calculate gain. * @param end The end index to calculate gain. */ - template - double Evaluate(const MatType& input, - const WeightVecType& /* weights */, - const size_t begin, - const size_t end) + double Evaluate(const size_t begin, const size_t end) { - gradients = (input.row(1) - input.row(0)).t(); - hessians = arma::vec(input.n_cols, arma::fill::ones); - return std::pow(ApplyL1(accu(gradients.subvec(begin, end))), 2) / (accu(hessians.subvec(begin, end)) + lambda); }