13 #ifndef MLPACK_METHODS_XGBOOST_LOSS_FUNCTIONS_SSE_LOSS_HPP 14 #define MLPACK_METHODS_XGBOOST_LOSS_FUNCTIONS_SSE_LOSS_HPP 35 SSELoss(
const double alpha,
const double lambda):
36 alpha(alpha), lambda(lambda)
44 template<
typename VecType>
48 if (values.n_elem == 0)
51 return arma::accu(values) / (
typename VecType::elem_type) values.n_elem;
57 template<
typename MatType,
typename WeightVecType>
59 const WeightVecType& )
61 return -ApplyL1(arma::accu(gradients)) / (arma::accu(hessians) + lambda);
70 double Evaluate(
const size_t begin,
const size_t end)
72 return std::pow(ApplyL1(arma::accu(gradients.subvec(begin, end))), 2) /
73 (arma::accu(hessians.subvec(begin, end)) + lambda);
86 template<
bool UseWeights,
typename MatType,
typename WeightVecType>
87 double Evaluate(
const MatType& input,
const WeightVecType& )
90 gradients = (input.row(1) - input.row(0)).t();
91 hessians = arma::vec(input.n_cols, arma::fill::ones);
93 return std::pow(ApplyL1(arma::accu(gradients)), 2) /
94 (arma::accu(hessians) + lambda);
107 double ApplyL1(
const double sumGradients)
109 if (sumGradients > alpha)
111 return sumGradients - alpha;
113 else if (sumGradients < - alpha)
115 return sumGradients + alpha;
VecType::elem_type InitialPrediction(const VecType &values)
Returns the initial predition for gradient boosting.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double Evaluate(const MatType &input, const WeightVecType &)
Calculates the gain of the node before splitting.
double OutputLeafValue(const MatType &, const WeightVecType &)
Returns the output value for the leaf in the tree.
The SSE (Sum of Squared Errors) loss is a loss function to measure the quality of prediction of respo...
SSELoss(const double alpha, const double lambda)
double Evaluate(const size_t begin, const size_t end)
Calculates the gain from begin to end.