From d0ecbf5f85ca75a25b1ea828beab6ec329611bb6 Mon Sep 17 00:00:00 2001 From: Rishabh Garg <56191449+RishabhGarg108@users.noreply.github.com> Date: Sat, 10 Jul 2021 07:49:22 +0530 Subject: [PATCH] Add BinaryGains() to SFINAE check --- .../methods/decision_tree/best_binary_numeric_split.hpp | 8 +++++++- .../decision_tree/best_binary_numeric_split_impl.hpp | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mlpack/methods/decision_tree/best_binary_numeric_split.hpp b/src/mlpack/methods/decision_tree/best_binary_numeric_split.hpp index 657df344d9..3f5cd27e65 100644 --- a/src/mlpack/methods/decision_tree/best_binary_numeric_split.hpp +++ b/src/mlpack/methods/decision_tree/best_binary_numeric_split.hpp @@ -29,6 +29,10 @@ HAS_MEM_FUNC(BinaryScanInitialize, HasBinaryScanInitialize); // we can use with SFINAE to catch when a type has a BinaryStep(...) function. HAS_MEM_FUNC(BinaryStep, HasBinaryStep); +// This gives us a HasBinaryGains type (where U is a function pointer) +// we can use with SFINAE to catch when a type has a BinaryGains(...) function. +HAS_MEM_FUNC(BinaryGains, HasBinaryGains); + /** * The BestBinaryNumericSplit is a splitting function for decision trees that * will exhaustively search a numeric dimension for the best binary split. @@ -134,7 +138,9 @@ class BestBinaryNumericSplit HasBinaryScanInitialize::value && HasBinaryStep::value, + (const ResponsesType&, const WeightVecType&, const size_t)>::value && + HasBinaryGains(FitnessFunction::*)()>::value, double>::type SplitIfBetter( const double bestGain, diff --git a/src/mlpack/methods/decision_tree/best_binary_numeric_split_impl.hpp b/src/mlpack/methods/decision_tree/best_binary_numeric_split_impl.hpp index 1913fc0868..3d0ebdc078 100644 --- a/src/mlpack/methods/decision_tree/best_binary_numeric_split_impl.hpp +++ b/src/mlpack/methods/decision_tree/best_binary_numeric_split_impl.hpp @@ -327,7 +327,9 @@ typename std::enable_if< HasBinaryScanInitialize::value && HasBinaryStep::value, + (const ResponsesType&, const WeightVecType&, const size_t)>::value && + HasBinaryGains(FitnessFunction::*)()>::value, double>::type BestBinaryNumericSplit::SplitIfBetter( const double bestGain,