mlpack
Public Member Functions | Static Public Member Functions | List of all members
mlpack::tree::MSEGain Class Reference

The MSE (Mean squared error) gain, is a measure of set purity based on the variance of response values present in the node. More...

#include <mse_gain.hpp>

Public Member Functions

std::tuple< double, double > BinaryGains ()
 Calculates the mean squared error gain for the left and right children for the current index. More...
 
template<bool UseWeights, typename ResponsesType , typename WeightVecType >
void BinaryScanInitialize (const ResponsesType &responses, const WeightVecType &weights, const size_t minimum)
 Caches the prefix sum of squares to efficiently compute gain value for each split. More...
 
template<bool UseWeights, typename ResponsesType , typename WeightVecType >
void BinaryStep (const ResponsesType &responses, const WeightVecType &weights, const size_t index)
 Updates the statistics for the given index. More...
 

Static Public Member Functions

template<bool UseWeights, typename VecType , typename WeightVecType >
static double Evaluate (const VecType &values, const WeightVecType &weights, const size_t begin, const size_t end)
 Evaluate the mean squared error gain of values from begin to end index. More...
 
template<bool UseWeights, typename VecType , typename WeightVecType >
static double Evaluate (const VecType &values, const WeightVecType &weights)
 Evaluate the MSE gain on the complete vector. More...
 

Detailed Description

The MSE (Mean squared error) gain, is a measure of set purity based on the variance of response values present in the node.

This is same thing as negation of variance of dependent variable in the node as we will try to maximize this quantity to maximize gain (and thus reduce variance of a set).

Member Function Documentation

◆ BinaryGains()

std::tuple<double, double> mlpack::tree::MSEGain::BinaryGains ( )
inline

Calculates the mean squared error gain for the left and right children for the current index.

X = array of values of size n.

\begin{eqnarray*} MSE = \sum\limits_{i=1}^n {X_i}^2 - {\dfrac{\sum\limits_{j=1}^n X_j}{n}}^2 \end{eqnarray*}

◆ BinaryScanInitialize()

template<bool UseWeights, typename ResponsesType , typename WeightVecType >
void mlpack::tree::MSEGain::BinaryScanInitialize ( const ResponsesType &  responses,
const WeightVecType &  weights,
const size_t  minimum 
)
inline

Caches the prefix sum of squares to efficiently compute gain value for each split.

It also computes the initial mean for left and right child.

Parameters
responsesThe set of responses on which statistics are computed.
weightsThe set of weights associated to each response.
minimumThe minimum number of elements in a leaf.

◆ BinaryStep()

template<bool UseWeights, typename ResponsesType , typename WeightVecType >
void mlpack::tree::MSEGain::BinaryStep ( const ResponsesType &  responses,
const WeightVecType &  weights,
const size_t  index 
)
inline

Updates the statistics for the given index.

Parameters
responsesThe set of responses on which statistics are computed.
weightsThe set of weights associated to each response.
indexThe current index.

◆ Evaluate() [1/2]

template<bool UseWeights, typename VecType , typename WeightVecType >
static double mlpack::tree::MSEGain::Evaluate ( const VecType &  values,
const WeightVecType &  weights,
const size_t  begin,
const size_t  end 
)
inlinestatic

Evaluate the mean squared error gain of values from begin to end index.

Note that gain can be slightly greater than 0 due to floating-point representation issues. Thus if you are checking for perfect fit, be sure to use 'gain >= 0.0' and not 'gain == 0.0'. The values vector should always be of type arma::Row<double> or arma::rowvec.

Parameters
valuesSet of values to evaluate MAD gain on.
weightsWeights associated to each value.
beginStart index.
endEnd index.

◆ Evaluate() [2/2]

template<bool UseWeights, typename VecType , typename WeightVecType >
static double mlpack::tree::MSEGain::Evaluate ( const VecType &  values,
const WeightVecType &  weights 
)
inlinestatic

Evaluate the MSE gain on the complete vector.

Parameters
valuesSet of values to evaluate MSE gain on.
weightsWeights associated to each value.

The documentation for this class was generated from the following file: