Change names of functions

This commit is contained in:
Rishabh Garg
2021-07-12 10:36:33 +05:30
parent 16f5fc1a22
commit 451fa167ea
2 changed files with 15 additions and 18 deletions
@@ -390,9 +390,9 @@ double BestBinaryNumericSplit<MSEGain>::SplitIfBetter(
bestFoundGain *= data.n_elem;
}
// Precomputing various statistics to efficiently compute gain values for
// all possible splits.
fitnessFunction.CalculateStatistics<UseWeights>(sortedResponses,
// Initialize and precompute various statistics to efficiently compute gain
// values for all possible splits.
fitnessFunction.BinaryScanInitialize<UseWeights>(sortedResponses,
sortedWeights, minimum);
// Loop through all possible split points, choosing the best one.
@@ -404,8 +404,8 @@ double BestBinaryNumericSplit<MSEGain>::SplitIfBetter(
rightChildWeight -= sortedWeights[index - 1];
}
// Update statistics for the current index.
fitnessFunction.UpdateStatistics<UseWeights>(sortedResponses,
// Steps through the current index and updates the cached data.
fitnessFunction.BinaryStep<UseWeights>(sortedResponses,
sortedWeights, index - 1);
// Make sure that the value has changed.
@@ -413,9 +413,9 @@ double BestBinaryNumericSplit<MSEGain>::SplitIfBetter(
continue;
// Calculate the gain for the left and right child.
auto value = fitnessFunction.Evaluate();
const double leftGain = std::get<0>(value);
const double rightGain = std::get<1>(value);
auto binaryGains = fitnessFunction.BinaryGains();
const double leftGain = std::get<0>(binaryGains);
const double rightGain = std::get<1>(binaryGains);
double gain;
if (UseWeights)
+7 -10
View File
@@ -106,7 +106,7 @@ class MSEGain
* {\dfrac{\sum\limits_{j=1}^n X_j}{n}}^2
* @f}
*/
std::tuple<double, double> Evaluate()
std::tuple<double, double> BinaryGains()
{
double mseLeft = leftSumSquares / leftSize - leftMean * leftMean;
double mseRight = (totalSumSquares - leftSumSquares) / rightSize
@@ -124,9 +124,9 @@ class MSEGain
* @param minimum The minimum number of elements in a leaf.
*/
template<bool UseWeights, typename ResponsesType, typename WeightVecType>
void CalculateStatistics(const ResponsesType& responses,
const WeightVecType& weights,
const size_t minimum)
void BinaryScanInitialize(const ResponsesType& responses,
const WeightVecType& weights,
const size_t minimum)
{
typedef typename ResponsesType::elem_type RType;
typedef typename WeightVecType::elem_type WType;
@@ -141,9 +141,6 @@ class MSEGain
if (UseWeights)
{
// Do I need to document that the % symbol does the elementwise multiplication?
// It might be misleading to general developers who might confuse it with modulo
// operator.
totalSumSquares = arma::accu(weights % arma::square(responses));
for (size_t i = 0; i < minimum - 1; ++i)
{
@@ -206,9 +203,9 @@ class MSEGain
* @param index The current index.
*/
template<bool UseWeights, typename ResponsesType, typename WeightVecType>
void UpdateStatistics(const ResponsesType& responses,
const WeightVecType& weights,
const size_t index)
void BinaryStep(const ResponsesType& responses,
const WeightVecType& weights,
const size_t index)
{
typedef typename ResponsesType::elem_type RType;
typedef typename WeightVecType::elem_type WType;