revert sse_gain

This commit is contained in:
Abhimanyu Dayal
2024-07-15 19:10:54 +05:30
parent 3e932b7c01
commit 389bb88db3
@@ -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 <mlpack/prereqs.hpp>
@@ -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<bool UseWeights, typename MatType, typename WeightVecType>
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);
}