From 4338515f55c5b50a2bca380ca7897913de5a1b04 Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Wed, 9 Aug 2023 00:32:55 +0200 Subject: [PATCH 01/20] Rename arguments, class members, etc. that refer to conditions. --- .../mlrl/common/model/body_conjunctive.hpp | 242 +++++++++--------- .../mlrl/common/model/body_conjunctive.cpp | 237 ++++++++--------- .../src/mlrl/common/model/condition_list.cpp | 32 +-- .../common/mlrl/common/cython/rule_model.pxd | 58 ++--- .../common/mlrl/common/cython/rule_model.pyx | 220 +++++++++------- .../mlrl/testbed/model_characteristics.py | 110 ++++---- .../testbed/mlrl/testbed/models.py | 11 +- 7 files changed, 472 insertions(+), 438 deletions(-) diff --git a/cpp/subprojects/common/include/mlrl/common/model/body_conjunctive.hpp b/cpp/subprojects/common/include/mlrl/common/model/body_conjunctive.hpp index a19a13e768..29b5546172 100644 --- a/cpp/subprojects/common/include/mlrl/common/model/body_conjunctive.hpp +++ b/cpp/subprojects/common/include/mlrl/common/model/body_conjunctive.hpp @@ -12,39 +12,39 @@ class MLRLCOMMON_API ConjunctiveBody final : public IBody { private: - const uint32 numLeq_; + const uint32 numNumericalLeq_; - uint32* leqFeatureIndices_; + uint32* numericalLeqFeatureIndices_; - float32* leqThresholds_; + float32* numericalLeqThresholds_; - const uint32 numGr_; + const uint32 numNumericalGr_; - uint32* grFeatureIndices_; + uint32* numericalGrFeatureIndices_; - float32* grThresholds_; + float32* numericalGrThresholds_; - const uint32 numEq_; + const uint32 numNominalEq_; - uint32* eqFeatureIndices_; + uint32* nominalEqFeatureIndices_; - float32* eqThresholds_; + float32* nominalEqThresholds_; - const uint32 numNeq_; + const uint32 numNominalNeq_; - uint32* neqFeatureIndices_; + uint32* nominalNeqFeatureIndices_; - float32* neqThresholds_; + float32* nominalNeqThresholds_; public: /** - * @param numLeq The number of conditions that use the <= operator - * @param numGr The number of conditions that use the > operator - * @param numEq The number of conditions that use the == operator - * @param numNeq The number of conditions that use the != operator + * @param numNumericalLeq The number of numerical conditions that use the <= operator + * @param numNumericalGr The number of numerical conditions that use the > operator + * @param numNominalEq The number of nominal conditions that use the == operator + * @param numNominalNeq The number of nominal conditions that use the != operator */ - ConjunctiveBody(uint32 numLeq, uint32 numGr, uint32 numEq, uint32 numNeq); + ConjunctiveBody(uint32 numNumericalLeq, uint32 numNumericalGr, uint32 numNominalEq, uint32 numNominalNeq); ~ConjunctiveBody() override; @@ -72,288 +72,288 @@ class MLRLCOMMON_API ConjunctiveBody final : public IBody { typedef const uint32* index_const_iterator; /** - * Returns the number of conditions that use the <= operator. + * Returns the number of numerical conditions that use the <= operator. * * @return The number of conditions */ - uint32 getNumLeq() const; + uint32 getNumNumericalLeq() const; /** - * Returns a `threshold_iterator` to the beginning of the thresholds that correspond to conditions that use the - * <= operator. + * Returns a `threshold_iterator` to the beginning of the thresholds that correspond to numerical conditions + * that use the <= operator. * * @return A `threshold_iterator` to the beginning */ - threshold_iterator leq_thresholds_begin(); + threshold_iterator numerical_leq_thresholds_begin(); /** - * Returns a `threshold_iterator` to the end of the thresholds that correspond to conditions that use the <= - * operator. + * Returns a `threshold_iterator` to the end of the thresholds that correspond to numerical conditions that use + * the <= operator. * * @return A `threshold_iterator` to the end */ - threshold_iterator leq_thresholds_end(); + threshold_iterator numerical_leq_thresholds_end(); /** - * Returns a `threshold_const_iterator` to the beginning of the thresholds that correspond to conditions that - * use the <= operator. + * Returns a `threshold_const_iterator` to the beginning of the thresholds that correspond to numerical + * conditions that use the <= operator. * * @return A `threshold_const_iterator` to the beginning */ - threshold_const_iterator leq_thresholds_cbegin() const; + threshold_const_iterator numerical_leq_thresholds_cbegin() const; /** - * Returns a `threshold_const_iterator` to the end of the thresholds that correspond to conditions that use the - * <= operator. + * Returns a `threshold_const_iterator` to the end of the thresholds that correspond to numerical conditions + * that use the <= operator. * * @return A `threshold_const_iterator` to the end */ - threshold_const_iterator leq_thresholds_cend() const; + threshold_const_iterator numerical_leq_thresholds_cend() const; /** - * Returns an `index_iterator` to the beginning of the feature indices that correspond to conditions that use - * the <= operator. + * Returns an `index_iterator` to the beginning of the feature indices that correspond to numerical conditions + * that use the <= operator. * * @return An `index_iterator` to the beginning */ - index_iterator leq_indices_begin(); + index_iterator numerical_leq_indices_begin(); /** - * Returns an `index_iterator` to the end of the feature indices that correspond to conditions that use the <= - * operator. + * Returns an `index_iterator` to the end of the feature indices that correspond to numerical conditions that + * use the <= operator. * * @return An `index_iterator` to the end */ - index_iterator leq_indices_end(); + index_iterator numerical_leq_indices_end(); /** - * Returns an `index_const_iterator` to the beginning of the feature indices that correspond to conditions that - * use the <= operator. + * Returns an `index_const_iterator` to the beginning of the feature indices that correspond to numerical + * conditions that use the <= operator. * * @return An `index_const_iterator` to the beginning */ - index_const_iterator leq_indices_cbegin() const; + index_const_iterator numerical_leq_indices_cbegin() const; /** - * Returns an `index_const_iterator` to the end of the feature indices that correspond to conditions that use - * the <= operator. + * Returns an `index_const_iterator` to the end of the feature indices that correspond to numerical conditions + * that use the <= operator. * * @return An `index_const_iterator` to the end */ - index_const_iterator leq_indices_cend() const; + index_const_iterator numerical_leq_indices_cend() const; /** - * Returns the number of conditions that use the > operator. + * Returns the number of numerical conditions that use the > operator. * * @return The number of conditions */ - uint32 getNumGr() const; + uint32 getNumNumericalGr() const; /** - * Returns a `threshold_iterator` to the beginning of the thresholds that correspond to conditions that use the - * > operator. + * Returns a `threshold_iterator` to the beginning of the thresholds that correspond to numerical conditions + * that use the > operator. * * @return A `threshold_iterator` to the beginning */ - threshold_iterator gr_thresholds_begin(); + threshold_iterator numerical_gr_thresholds_begin(); /** - * Returns a `threshold_iterator` to the end of the thresholds that correspond to conditions that use the > - * operator. + * Returns a `threshold_iterator` to the end of the thresholds that correspond to numerical conditions that use + * the > operator. * * @return A `threshold_iterator` to the end */ - threshold_iterator gr_thresholds_end(); + threshold_iterator numerical_gr_thresholds_end(); /** - * Returns a `threshold_const_iterator` to the beginning of the thresholds that correspond to conditions that - * use the > operator. + * Returns a `threshold_const_iterator` to the beginning of the thresholds that correspond to numerical + * conditions that use the > operator. * * @return A `threshold_const_iterator` to the beginning */ - threshold_const_iterator gr_thresholds_cbegin() const; + threshold_const_iterator numerical_gr_thresholds_cbegin() const; /** - * Returns a `threshold_const_iterator` to the end of the thresholds that correspond to conditions that use the - * > operator. + * Returns a `threshold_const_iterator` to the end of the thresholds that correspond to numerical conditions + * that use the > operator. * * @return A `threshold_const_iterator` to the end */ - threshold_const_iterator gr_thresholds_cend() const; + threshold_const_iterator numerical_gr_thresholds_cend() const; /** - * Returns an `index_iterator` to the beginning of the feature indices that correspond to conditions that use - * the > operator. + * Returns an `index_iterator` to the beginning of the feature indices that correspond to numerical conditions + * that use the > operator. * * @return An `index_iterator` to the beginning */ - index_iterator gr_indices_begin(); + index_iterator numerical_gr_indices_begin(); /** - * Returns an `index_iterator` to the end of the feature indices that correspond to conditions that use the > - * operator. + * Returns an `index_iterator` to the end of the feature indices that correspond to numerical conditions that + * use the > operator. * * @return An `index_iterator` to the end */ - index_iterator gr_indices_end(); + index_iterator numerical_gr_indices_end(); /** - * Returns an `index_const_iterator` to the beginning of the feature indices that correspond to conditions that - * use the > operator. + * Returns an `index_const_iterator` to the beginning of the feature indices that correspond to numerical + * conditions that use the > operator. * * @return An `index_const_iterator` to the beginning */ - index_const_iterator gr_indices_cbegin() const; + index_const_iterator numerical_gr_indices_cbegin() const; /** - * Returns an `index_const_iterator` to the end of the feature indices that correspond to conditions that use - * the > operator. + * Returns an `index_const_iterator` to the end of the feature indices that correspond to numerical conditions + * that use the > operator. * * @return An `index_const_iterator` to the end */ - index_const_iterator gr_indices_cend() const; + index_const_iterator numerical_gr_indices_cend() const; /** - * Returns the number of conditions that use the == operator. + * Returns the number of nominal conditions that use the == operator. * * @return The number of conditions */ - uint32 getNumEq() const; + uint32 getNumNominalEq() const; /** - * Returns a `threshold_iterator` to the beginning of the thresholds that correspond to conditions that use the - * == operator. + * Returns a `threshold_iterator` to the beginning of the thresholds that correspond to nominal conditions that + * use the == operator. * * @return A `threshold_iterator` to the beginning */ - threshold_iterator eq_thresholds_begin(); + threshold_iterator nominal_eq_thresholds_begin(); /** - * Returns a `threshold_iterator` to the end of the thresholds that correspond to conditions that use the == - * operator. + * Returns a `threshold_iterator` to the end of the thresholds that correspond to nominal conditions that use + * the == operator. * * @return A `threshold_iterator` to the end */ - threshold_iterator eq_thresholds_end(); + threshold_iterator nominal_eq_thresholds_end(); /** - * Returns a `threshold_const_iterator` to the beginning of the thresholds that correspond to conditions that - * use the == operator. + * Returns a `threshold_const_iterator` to the beginning of the thresholds that correspond to nominal conditions + * that use the == operator. * * @return A `threshold_const_iterator` to the beginning */ - threshold_const_iterator eq_thresholds_cbegin() const; + threshold_const_iterator nominal_eq_thresholds_cbegin() const; /** - * Returns a `threshold_const_iterator` to the end of the thresholds that correspond to conditions that use the - * == operator. + * Returns a `threshold_const_iterator` to the end of the thresholds that correspond to nominal conditions that + * use the == operator. * * @return A `threshold_const_iterator` to the end */ - threshold_const_iterator eq_thresholds_cend() const; + threshold_const_iterator nominal_eq_thresholds_cend() const; /** - * Returns an `index_iterator` to the beginning of the feature indices that correspond to conditions that use - * the == operator. + * Returns an `index_iterator` to the beginning of the feature indices that correspond to nominal conditions + * that use the == operator. * * @return An `index_iterator` to the beginning */ - index_iterator eq_indices_begin(); + index_iterator nominal_eq_indices_begin(); /** - * Returns an `index_iterator` to the end of the feature indices that correspond to conditions that use the == - * operator. + * Returns an `index_iterator` to the end of the feature indices that correspond to nominal conditions that use + * the == operator. * * @return An `index_iterator` to the end */ - index_iterator eq_indices_end(); + index_iterator nominal_eq_indices_end(); /** - * Returns an `index_const_iterator` to the beginning of the feature indices that correspond to conditions that - * use the == operator. + * Returns an `index_const_iterator` to the beginning of the feature indices that correspond to nominal + * conditions that use the == operator. * * @return An `index_const_iterator` to the beginning */ - index_const_iterator eq_indices_cbegin() const; + index_const_iterator nominal_eq_indices_cbegin() const; /** - * Returns an `index_const_iterator` to the end of the feature indices that correspond to conditions that use - * the == operator. + * Returns an `index_const_iterator` to the end of the feature indices that correspond to nominal conditions + * that use the == operator. * * @return An `index_const_iterator` to the end */ - index_const_iterator eq_indices_cend() const; + index_const_iterator nominal_eq_indices_cend() const; /** - * Returns the number of conditions that use the != operator. + * Returns the number of nominal conditions that use the != operator. * * @return The number of conditions */ - uint32 getNumNeq() const; + uint32 getNumNominalNeq() const; /** - * Returns a `threshold_iterator` to the beginning of the thresholds that correspond to conditions that use the - * != operator. + * Returns a `threshold_iterator` to the beginning of the thresholds that correspond to nominal conditions that + * use the != operator. * * @return A `threshold_iterator` to the beginning */ - threshold_iterator neq_thresholds_begin(); + threshold_iterator nominal_neq_thresholds_begin(); /** - * Returns a `threshold_iterator` to the end of the thresholds that correspond to conditions that use the != - * operator. + * Returns a `threshold_iterator` to the end of the thresholds that correspond to nominal conditions that use + * the != operator. * * @return A `threshold_iterator` to the end */ - threshold_iterator neq_thresholds_end(); + threshold_iterator nominal_neq_thresholds_end(); /** - * Returns a `threshold_const_iterator` to the beginning of the thresholds that correspond to conditions that - * use the != operator. + * Returns a `threshold_const_iterator` to the beginning of the thresholds that correspond to nominal conditions + * that use the != operator. * * @return A `threshold_const_iterator` to the beginning */ - threshold_const_iterator neq_thresholds_cbegin() const; + threshold_const_iterator nominal_neq_thresholds_cbegin() const; /** - * Returns a `threshold_const_iterator` to the end of the thresholds that correspond to conditions that use the - * != operator. + * Returns a `threshold_const_iterator` to the end of the thresholds that correspond to nominal conditions that + * use the != operator. * * @return A `threshold_const_iterator` to the end */ - threshold_const_iterator neq_thresholds_cend() const; + threshold_const_iterator nominal_neq_thresholds_cend() const; /** - * Returns an `index_iterator` to the beginning of the feature indices that correspond to conditions that use - * the != operator. + * Returns an `index_iterator` to the beginning of the feature indices that correspond to nominal conditions + * that use the != operator. * * @return An `index_iterator` to the beginning */ - index_iterator neq_indices_begin(); + index_iterator nominal_neq_indices_begin(); /** - * Returns an `index_iterator` to the end of the feature indices that correspond to conditions that use the != - * operator. + * Returns an `index_iterator` to the end of the feature indices that correspond to nominal conditions that use + * the != operator. * * @return An `index_iterator` to the end */ - index_iterator neq_indices_end(); + index_iterator nominal_neq_indices_end(); /** - * Returns an `index_const_iterator` to the beginning of the feature indices that correspond to conditions that - * use the != operator. + * Returns an `index_const_iterator` to the beginning of the feature indices that correspond to nominal + * conditions that use the != operator. * * @return An `index_const_iterator` to the beginning */ - index_const_iterator neq_indices_cbegin() const; + index_const_iterator nominal_neq_indices_cbegin() const; /** - * Returns an `index_const_iterator` to the end of the feature indices that correspond to conditions that use - * the != operator. + * Returns an `index_const_iterator` to the end of the feature indices that correspond to nominal conditions + * that use the != operator. * * @return An `index_const_iterator` to the end */ - index_const_iterator neq_indices_cend() const; + index_const_iterator nominal_neq_indices_cend() const; /** * @see `IBody::covers` diff --git a/cpp/subprojects/common/src/mlrl/common/model/body_conjunctive.cpp b/cpp/subprojects/common/src/mlrl/common/model/body_conjunctive.cpp index 6ff6a223ab..4ccab580ec 100644 --- a/cpp/subprojects/common/src/mlrl/common/model/body_conjunctive.cpp +++ b/cpp/subprojects/common/src/mlrl/common/model/body_conjunctive.cpp @@ -1,202 +1,205 @@ #include "mlrl/common/model/body_conjunctive.hpp" -ConjunctiveBody::ConjunctiveBody(uint32 numLeq, uint32 numGr, uint32 numEq, uint32 numNeq) - : numLeq_(numLeq), leqFeatureIndices_(new uint32[numLeq_]), leqThresholds_(new float32[numLeq_]), numGr_(numGr), - grFeatureIndices_(new uint32[numGr_]), grThresholds_(new float32[numGr_]), numEq_(numEq), - eqFeatureIndices_(new uint32[numEq_]), eqThresholds_(new float32[numEq_]), numNeq_(numNeq), - neqFeatureIndices_(new uint32[numNeq_]), neqThresholds_(new float32[numNeq_]) {} +ConjunctiveBody::ConjunctiveBody(uint32 numNumericalLeq, uint32 numNumericalGr, uint32 numNominalEq, + uint32 numNominalNeq) + : numNumericalLeq_(numNumericalLeq), numericalLeqFeatureIndices_(new uint32[numNumericalLeq_]), + numericalLeqThresholds_(new float32[numNumericalLeq_]), numNumericalGr_(numNumericalGr), + numericalGrFeatureIndices_(new uint32[numNumericalGr_]), numericalGrThresholds_(new float32[numNumericalGr_]), + numNominalEq_(numNominalEq), nominalEqFeatureIndices_(new uint32[numNominalEq_]), + nominalEqThresholds_(new float32[numNominalEq_]), numNominalNeq_(numNominalNeq), + nominalNeqFeatureIndices_(new uint32[numNominalNeq_]), nominalNeqThresholds_(new float32[numNominalNeq_]) {} ConjunctiveBody::~ConjunctiveBody() { - delete[] leqFeatureIndices_; - delete[] leqThresholds_; - delete[] grFeatureIndices_; - delete[] grThresholds_; - delete[] eqFeatureIndices_; - delete[] eqThresholds_; - delete[] neqFeatureIndices_; - delete[] neqThresholds_; + delete[] numericalLeqFeatureIndices_; + delete[] numericalLeqThresholds_; + delete[] numericalGrFeatureIndices_; + delete[] numericalGrThresholds_; + delete[] nominalEqFeatureIndices_; + delete[] nominalEqThresholds_; + delete[] nominalNeqFeatureIndices_; + delete[] nominalNeqThresholds_; } -uint32 ConjunctiveBody::getNumLeq() const { - return numLeq_; +uint32 ConjunctiveBody::getNumNumericalLeq() const { + return numNumericalLeq_; } -ConjunctiveBody::threshold_iterator ConjunctiveBody::leq_thresholds_begin() { - return leqThresholds_; +ConjunctiveBody::threshold_iterator ConjunctiveBody::numerical_leq_thresholds_begin() { + return numericalLeqThresholds_; } -ConjunctiveBody::threshold_iterator ConjunctiveBody::leq_thresholds_end() { - return &leqThresholds_[numLeq_]; +ConjunctiveBody::threshold_iterator ConjunctiveBody::numerical_leq_thresholds_end() { + return &numericalLeqThresholds_[numNumericalLeq_]; } -ConjunctiveBody::threshold_const_iterator ConjunctiveBody::leq_thresholds_cbegin() const { - return leqThresholds_; +ConjunctiveBody::threshold_const_iterator ConjunctiveBody::numerical_leq_thresholds_cbegin() const { + return numericalLeqThresholds_; } -ConjunctiveBody::threshold_const_iterator ConjunctiveBody::leq_thresholds_cend() const { - return &leqThresholds_[numLeq_]; +ConjunctiveBody::threshold_const_iterator ConjunctiveBody::numerical_leq_thresholds_cend() const { + return &numericalLeqThresholds_[numNumericalLeq_]; } -ConjunctiveBody::index_iterator ConjunctiveBody::leq_indices_begin() { - return leqFeatureIndices_; +ConjunctiveBody::index_iterator ConjunctiveBody::numerical_leq_indices_begin() { + return numericalLeqFeatureIndices_; } -ConjunctiveBody::index_iterator ConjunctiveBody::leq_indices_end() { - return &leqFeatureIndices_[numLeq_]; +ConjunctiveBody::index_iterator ConjunctiveBody::numerical_leq_indices_end() { + return &numericalLeqFeatureIndices_[numNumericalLeq_]; } -ConjunctiveBody::index_const_iterator ConjunctiveBody::leq_indices_cbegin() const { - return leqFeatureIndices_; +ConjunctiveBody::index_const_iterator ConjunctiveBody::numerical_leq_indices_cbegin() const { + return numericalLeqFeatureIndices_; } -ConjunctiveBody::index_const_iterator ConjunctiveBody::leq_indices_cend() const { - return &leqFeatureIndices_[numLeq_]; +ConjunctiveBody::index_const_iterator ConjunctiveBody::numerical_leq_indices_cend() const { + return &numericalLeqFeatureIndices_[numNumericalLeq_]; } -uint32 ConjunctiveBody::getNumGr() const { - return numGr_; +uint32 ConjunctiveBody::getNumNumericalGr() const { + return numNumericalGr_; } -ConjunctiveBody::threshold_iterator ConjunctiveBody::gr_thresholds_begin() { - return grThresholds_; +ConjunctiveBody::threshold_iterator ConjunctiveBody::numerical_gr_thresholds_begin() { + return numericalGrThresholds_; } -ConjunctiveBody::threshold_iterator ConjunctiveBody::gr_thresholds_end() { - return &grThresholds_[numLeq_]; +ConjunctiveBody::threshold_iterator ConjunctiveBody::numerical_gr_thresholds_end() { + return &numericalGrThresholds_[numNumericalLeq_]; } -ConjunctiveBody::threshold_const_iterator ConjunctiveBody::gr_thresholds_cbegin() const { - return grThresholds_; +ConjunctiveBody::threshold_const_iterator ConjunctiveBody::numerical_gr_thresholds_cbegin() const { + return numericalGrThresholds_; } -ConjunctiveBody::threshold_const_iterator ConjunctiveBody::gr_thresholds_cend() const { - return &grThresholds_[numLeq_]; +ConjunctiveBody::threshold_const_iterator ConjunctiveBody::numerical_gr_thresholds_cend() const { + return &numericalGrThresholds_[numNumericalLeq_]; } -ConjunctiveBody::index_iterator ConjunctiveBody::gr_indices_begin() { - return grFeatureIndices_; +ConjunctiveBody::index_iterator ConjunctiveBody::numerical_gr_indices_begin() { + return numericalGrFeatureIndices_; } -ConjunctiveBody::index_iterator ConjunctiveBody::gr_indices_end() { - return &grFeatureIndices_[numLeq_]; +ConjunctiveBody::index_iterator ConjunctiveBody::numerical_gr_indices_end() { + return &numericalGrFeatureIndices_[numNumericalLeq_]; } -ConjunctiveBody::index_const_iterator ConjunctiveBody::gr_indices_cbegin() const { - return grFeatureIndices_; +ConjunctiveBody::index_const_iterator ConjunctiveBody::numerical_gr_indices_cbegin() const { + return numericalGrFeatureIndices_; } -ConjunctiveBody::index_const_iterator ConjunctiveBody::gr_indices_cend() const { - return &grFeatureIndices_[numLeq_]; +ConjunctiveBody::index_const_iterator ConjunctiveBody::numerical_gr_indices_cend() const { + return &numericalGrFeatureIndices_[numNumericalLeq_]; } -uint32 ConjunctiveBody::getNumEq() const { - return numEq_; +uint32 ConjunctiveBody::getNumNominalEq() const { + return numNominalEq_; } -ConjunctiveBody::threshold_iterator ConjunctiveBody::eq_thresholds_begin() { - return eqThresholds_; +ConjunctiveBody::threshold_iterator ConjunctiveBody::nominal_eq_thresholds_begin() { + return nominalEqThresholds_; } -ConjunctiveBody::threshold_iterator ConjunctiveBody::eq_thresholds_end() { - return &eqThresholds_[numLeq_]; +ConjunctiveBody::threshold_iterator ConjunctiveBody::nominal_eq_thresholds_end() { + return &nominalEqThresholds_[numNominalEq_]; } -ConjunctiveBody::threshold_const_iterator ConjunctiveBody::eq_thresholds_cbegin() const { - return eqThresholds_; +ConjunctiveBody::threshold_const_iterator ConjunctiveBody::nominal_eq_thresholds_cbegin() const { + return nominalEqThresholds_; } -ConjunctiveBody::threshold_const_iterator ConjunctiveBody::eq_thresholds_cend() const { - return &eqThresholds_[numLeq_]; +ConjunctiveBody::threshold_const_iterator ConjunctiveBody::nominal_eq_thresholds_cend() const { + return &nominalEqThresholds_[numNominalEq_]; } -ConjunctiveBody::index_iterator ConjunctiveBody::eq_indices_begin() { - return eqFeatureIndices_; +ConjunctiveBody::index_iterator ConjunctiveBody::nominal_eq_indices_begin() { + return nominalEqFeatureIndices_; } -ConjunctiveBody::index_iterator ConjunctiveBody::eq_indices_end() { - return &eqFeatureIndices_[numLeq_]; +ConjunctiveBody::index_iterator ConjunctiveBody::nominal_eq_indices_end() { + return &nominalEqFeatureIndices_[numNominalEq_]; } -ConjunctiveBody::index_const_iterator ConjunctiveBody::eq_indices_cbegin() const { - return eqFeatureIndices_; +ConjunctiveBody::index_const_iterator ConjunctiveBody::nominal_eq_indices_cbegin() const { + return nominalEqFeatureIndices_; } -ConjunctiveBody::index_const_iterator ConjunctiveBody::eq_indices_cend() const { - return &eqFeatureIndices_[numLeq_]; +ConjunctiveBody::index_const_iterator ConjunctiveBody::nominal_eq_indices_cend() const { + return &nominalEqFeatureIndices_[numNominalEq_]; } -uint32 ConjunctiveBody::getNumNeq() const { - return numNeq_; +uint32 ConjunctiveBody::getNumNominalNeq() const { + return numNominalNeq_; } -ConjunctiveBody::threshold_iterator ConjunctiveBody::neq_thresholds_begin() { - return neqThresholds_; +ConjunctiveBody::threshold_iterator ConjunctiveBody::nominal_neq_thresholds_begin() { + return nominalNeqThresholds_; } -ConjunctiveBody::threshold_iterator ConjunctiveBody::neq_thresholds_end() { - return &neqThresholds_[numLeq_]; +ConjunctiveBody::threshold_iterator ConjunctiveBody::nominal_neq_thresholds_end() { + return &nominalNeqThresholds_[numNominalNeq_]; } -ConjunctiveBody::threshold_const_iterator ConjunctiveBody::neq_thresholds_cbegin() const { - return neqThresholds_; +ConjunctiveBody::threshold_const_iterator ConjunctiveBody::nominal_neq_thresholds_cbegin() const { + return nominalNeqThresholds_; } -ConjunctiveBody::threshold_const_iterator ConjunctiveBody::neq_thresholds_cend() const { - return &neqThresholds_[numLeq_]; +ConjunctiveBody::threshold_const_iterator ConjunctiveBody::nominal_neq_thresholds_cend() const { + return &nominalNeqThresholds_[numNominalNeq_]; } -ConjunctiveBody::index_iterator ConjunctiveBody::neq_indices_begin() { - return neqFeatureIndices_; +ConjunctiveBody::index_iterator ConjunctiveBody::nominal_neq_indices_begin() { + return nominalNeqFeatureIndices_; } -ConjunctiveBody::index_iterator ConjunctiveBody::neq_indices_end() { - return &neqFeatureIndices_[numLeq_]; +ConjunctiveBody::index_iterator ConjunctiveBody::nominal_neq_indices_end() { + return &nominalNeqFeatureIndices_[numNominalNeq_]; } -ConjunctiveBody::index_const_iterator ConjunctiveBody::neq_indices_cbegin() const { - return neqFeatureIndices_; +ConjunctiveBody::index_const_iterator ConjunctiveBody::nominal_neq_indices_cbegin() const { + return nominalNeqFeatureIndices_; } -ConjunctiveBody::index_const_iterator ConjunctiveBody::neq_indices_cend() const { - return &neqFeatureIndices_[numLeq_]; +ConjunctiveBody::index_const_iterator ConjunctiveBody::nominal_neq_indices_cend() const { + return &nominalNeqFeatureIndices_[numNominalNeq_]; } bool ConjunctiveBody::covers(VectorConstView::const_iterator begin, VectorConstView::const_iterator end) const { - // Test conditions using the <= operator... - for (uint32 i = 0; i < numLeq_; i++) { - uint32 featureIndex = leqFeatureIndices_[i]; - float32 threshold = leqThresholds_[i]; + // Test numerical conditions using the <= operator... + for (uint32 i = 0; i < numNumericalLeq_; i++) { + uint32 featureIndex = numericalLeqFeatureIndices_[i]; + float32 threshold = numericalLeqThresholds_[i]; if (begin[featureIndex] > threshold) { return false; } } - // Test conditions using the > operator... - for (uint32 i = 0; i < numGr_; i++) { - uint32 featureIndex = grFeatureIndices_[i]; - float32 threshold = grThresholds_[i]; + // Test numerical conditions using the > operator... + for (uint32 i = 0; i < numNumericalGr_; i++) { + uint32 featureIndex = numericalGrFeatureIndices_[i]; + float32 threshold = numericalGrThresholds_[i]; if (begin[featureIndex] <= threshold) { return false; } } - // Test conditions using the == operator... - for (uint32 i = 0; i < numEq_; i++) { - uint32 featureIndex = eqFeatureIndices_[i]; - float32 threshold = eqThresholds_[i]; + // Test nominal conditions using the == operator... + for (uint32 i = 0; i < numNominalEq_; i++) { + uint32 featureIndex = nominalEqFeatureIndices_[i]; + float32 threshold = nominalEqThresholds_[i]; if (begin[featureIndex] != threshold) { return false; } } - // Test conditions using the != operator... - for (uint32 i = 0; i < numNeq_; i++) { - uint32 featureIndex = neqFeatureIndices_[i]; - float32 threshold = neqThresholds_[i]; + // Test nominal conditions using the != operator... + for (uint32 i = 0; i < numNominalNeq_; i++) { + uint32 featureIndex = nominalNeqFeatureIndices_[i]; + float32 threshold = nominalNeqThresholds_[i]; if (begin[featureIndex] == threshold) { return false; @@ -222,10 +225,10 @@ bool ConjunctiveBody::covers(CsrConstView::index_const_iterator i valueIterator++; } - // Test conditions using the <= operator... - for (uint32 i = 0; i < numLeq_; i++) { - uint32 featureIndex = leqFeatureIndices_[i]; - float32 threshold = leqThresholds_[i]; + // Test numerical conditions using the <= operator... + for (uint32 i = 0; i < numNumericalLeq_; i++) { + uint32 featureIndex = numericalLeqFeatureIndices_[i]; + float32 threshold = numericalLeqThresholds_[i]; float32 featureValue = tmpArray2[featureIndex] == n ? tmpArray1[featureIndex] : 0; if (featureValue > threshold) { @@ -233,10 +236,10 @@ bool ConjunctiveBody::covers(CsrConstView::index_const_iterator i } } - // Test conditions using the > operator... - for (uint32 i = 0; i < numGr_; i++) { - uint32 featureIndex = grFeatureIndices_[i]; - float32 threshold = grThresholds_[i]; + // Test numerical conditions using the > operator... + for (uint32 i = 0; i < numNumericalGr_; i++) { + uint32 featureIndex = numericalGrFeatureIndices_[i]; + float32 threshold = numericalGrThresholds_[i]; float32 featureValue = tmpArray2[featureIndex] == n ? tmpArray1[featureIndex] : 0; if (featureValue <= threshold) { @@ -244,10 +247,10 @@ bool ConjunctiveBody::covers(CsrConstView::index_const_iterator i } } - // Test conditions using the == operator... - for (uint32 i = 0; i < numEq_; i++) { - uint32 featureIndex = eqFeatureIndices_[i]; - float32 threshold = eqThresholds_[i]; + // Test nominal conditions using the == operator... + for (uint32 i = 0; i < numNominalEq_; i++) { + uint32 featureIndex = nominalEqFeatureIndices_[i]; + float32 threshold = nominalEqThresholds_[i]; float32 featureValue = tmpArray2[featureIndex] == n ? tmpArray1[featureIndex] : 0; if (featureValue != threshold) { @@ -255,10 +258,10 @@ bool ConjunctiveBody::covers(CsrConstView::index_const_iterator i } } - // Test conditions using the != operator... - for (uint32 i = 0; i < numNeq_; i++) { - uint32 featureIndex = neqFeatureIndices_[i]; - float32 threshold = neqThresholds_[i]; + // Test nominal conditions using the != operator... + for (uint32 i = 0; i < numNominalNeq_; i++) { + uint32 featureIndex = nominalNeqFeatureIndices_[i]; + float32 threshold = nominalNeqThresholds_[i]; float32 featureValue = tmpArray2[featureIndex] == n ? tmpArray1[featureIndex] : 0; if (featureValue == threshold) { diff --git a/cpp/subprojects/common/src/mlrl/common/model/condition_list.cpp b/cpp/subprojects/common/src/mlrl/common/model/condition_list.cpp index 12d8e44a5e..158cf3d525 100644 --- a/cpp/subprojects/common/src/mlrl/common/model/condition_list.cpp +++ b/cpp/subprojects/common/src/mlrl/common/model/condition_list.cpp @@ -35,10 +35,10 @@ std::unique_ptr ConditionList::createConjunctiveBody() const { std::unique_ptr bodyPtr = std::make_unique(numConditionsPerComparator_[LEQ], numConditionsPerComparator_[GR], numConditionsPerComparator_[EQ], numConditionsPerComparator_[NEQ]); - uint32 leqIndex = 0; - uint32 grIndex = 0; - uint32 eqIndex = 0; - uint32 neqIndex = 0; + uint32 numericalLeqIndex = 0; + uint32 numericalGrIndex = 0; + uint32 nominalEqIndex = 0; + uint32 nominalNeqIndex = 0; for (auto it = vector_.cbegin(); it != vector_.cend(); it++) { const Condition& condition = *it; @@ -47,27 +47,27 @@ std::unique_ptr ConditionList::createConjunctiveBody() const { switch (condition.comparator) { case LEQ: { - bodyPtr->leq_indices_begin()[leqIndex] = featureIndex; - bodyPtr->leq_thresholds_begin()[leqIndex] = threshold; - leqIndex++; + bodyPtr->numerical_leq_indices_begin()[numericalLeqIndex] = featureIndex; + bodyPtr->numerical_leq_thresholds_begin()[numericalLeqIndex] = threshold; + numericalLeqIndex++; break; } case GR: { - bodyPtr->gr_indices_begin()[grIndex] = featureIndex; - bodyPtr->gr_thresholds_begin()[grIndex] = threshold; - grIndex++; + bodyPtr->numerical_gr_indices_begin()[numericalGrIndex] = featureIndex; + bodyPtr->numerical_gr_thresholds_begin()[numericalGrIndex] = threshold; + numericalGrIndex++; break; } case EQ: { - bodyPtr->eq_indices_begin()[eqIndex] = featureIndex; - bodyPtr->eq_thresholds_begin()[eqIndex] = threshold; - eqIndex++; + bodyPtr->nominal_eq_indices_begin()[nominalEqIndex] = featureIndex; + bodyPtr->nominal_eq_thresholds_begin()[nominalEqIndex] = threshold; + nominalEqIndex++; break; } case NEQ: { - bodyPtr->neq_indices_begin()[neqIndex] = featureIndex; - bodyPtr->neq_thresholds_begin()[neqIndex] = threshold; - neqIndex++; + bodyPtr->nominal_neq_indices_begin()[nominalNeqIndex] = featureIndex; + bodyPtr->nominal_neq_thresholds_begin()[nominalNeqIndex] = threshold; + nominalNeqIndex++; break; } default: { diff --git a/python/subprojects/common/mlrl/common/cython/rule_model.pxd b/python/subprojects/common/mlrl/common/cython/rule_model.pxd index ffd32a8402..a27f69b6fd 100644 --- a/python/subprojects/common/mlrl/common/cython/rule_model.pxd +++ b/python/subprojects/common/mlrl/common/cython/rule_model.pxd @@ -33,49 +33,49 @@ cdef extern from "mlrl/common/model/body_conjunctive.hpp" nogil: # Constructors: - ConjunctiveBodyImpl(uint32 numLeq, uint32 numGr, uint32 numEq, uint32 numNeq) + ConjunctiveBodyImpl(uint32 numNumericalLeq, uint32 numNumericalGr, uint32 numNominalEq, uint32 numNominalNeq) # Functions: - uint32 getNumLeq() const + uint32 getNumNumericalLeq() const - threshold_iterator leq_thresholds_begin() + threshold_iterator numerical_leq_thresholds_begin() - threshold_const_iterator leq_thresholds_cbegin() const + threshold_const_iterator numerical_leq_thresholds_cbegin() const - index_iterator leq_indices_begin() + index_iterator numerical_leq_indices_begin() - index_const_iterator leq_indices_cbegin() const + index_const_iterator numerical_leq_indices_cbegin() const - uint32 getNumGr() const + uint32 getNumNumericalGr() const - threshold_iterator gr_thresholds_begin() + threshold_iterator numerical_gr_thresholds_begin() - threshold_const_iterator gr_thresholds_cbegin() const + threshold_const_iterator numerical_gr_thresholds_cbegin() const - index_iterator gr_indices_begin() + index_iterator numerical_gr_indices_begin() - index_const_iterator gr_indices_cbegin() const + index_const_iterator numerical_gr_indices_cbegin() const - uint32 getNumEq() const + uint32 getNumNominalEq() const - threshold_iterator eq_thresholds_begin() + threshold_iterator nominal_eq_thresholds_begin() - threshold_const_iterator eq_thresholds_cbegin() const + threshold_const_iterator nominal_eq_thresholds_cbegin() const - index_iterator eq_indices_begin() + index_iterator nominal_eq_indices_begin() - index_const_iterator eq_indices_cbegin() const + index_const_iterator nominal_eq_indices_cbegin() const - uint32 getNumNeq() const + uint32 getNumNominalNeq() const - threshold_iterator neq_thresholds_begin() + threshold_iterator nominal_neq_thresholds_begin() - threshold_const_iterator neq_thresholds_cbegin() const + threshold_const_iterator nominal_neq_thresholds_cbegin() const - index_iterator neq_indices_begin() + index_iterator nominal_neq_indices_begin() - index_const_iterator neq_indices_cbegin() const + index_const_iterator nominal_neq_indices_cbegin() const cdef extern from "mlrl/common/model/head.hpp" nogil: @@ -240,21 +240,21 @@ cdef class ConjunctiveBody: # Attributes: - cdef readonly npc.ndarray leq_indices + cdef readonly npc.ndarray numerical_leq_indices - cdef readonly npc.ndarray leq_thresholds + cdef readonly npc.ndarray numerical_leq_thresholds - cdef readonly npc.ndarray gr_indices + cdef readonly npc.ndarray numerical_gr_indices - cdef readonly npc.ndarray gr_thresholds + cdef readonly npc.ndarray numerical_gr_thresholds - cdef readonly npc.ndarray eq_indices + cdef readonly npc.ndarray nominal_eq_indices - cdef readonly npc.ndarray eq_thresholds + cdef readonly npc.ndarray nominal_eq_thresholds - cdef readonly npc.ndarray neq_indices + cdef readonly npc.ndarray nominal_neq_indices - cdef readonly npc.ndarray neq_thresholds + cdef readonly npc.ndarray nominal_neq_thresholds cdef class CompleteHead: diff --git a/python/subprojects/common/mlrl/common/cython/rule_model.pyx b/python/subprojects/common/mlrl/common/cython/rule_model.pyx index 6df2cc5ede..937c5c5c5f 100644 --- a/python/subprojects/common/mlrl/common/cython/rule_model.pyx +++ b/python/subprojects/common/mlrl/common/cython/rule_model.pyx @@ -23,43 +23,46 @@ cdef class ConjunctiveBody: A body of a rule that is given as a conjunction of several conditions. """ - def __cinit__(self, const uint32[::1] leq_indices, const float32[::1] leq_thresholds, const uint32[::1] gr_indices, - const float32[::1] gr_thresholds, const uint32[::1] eq_indices, const float32[::1] eq_thresholds, - const uint32[::1] neq_indices, const float32[::1] neq_thresholds): + def __cinit__(self, const uint32[::1] numerical_leq_indices, const float32[::1] numerical_leq_thresholds, + const uint32[::1] numerical_gr_indices, const float32[::1] numerical_gr_thresholds, + const uint32[::1] nominal_eq_indices, const float32[::1] nominal_eq_thresholds, + const uint32[::1] nominal_neq_indices, const float32[::1] nominal_neq_thresholds): """ - :param leq_indices: A contiguous array of type `uint32`, shape `(num_leq_conditions)`, that stores the - feature indices of the conditions that use the <= operator or None, if no such - conditions are available - :param leq_thresholds: A contiguous array of type `float32`, shape `(num_leq_conditions)` that stores the - thresholds of the conditions that use the <= operator or None, if no such conditions are - available - :param gr_indices: A contiguous array of type `uint32`, shape `(num_gr_conditions)`, that stores the - feature indices of the conditions that use the > operator or None, if no such conditions - are available - :param gr_thresholds: A contiguous array of type `float32`, shape `(num_gr_conditions)` that stores the - thresholds of the conditions that use the > operator or None, if no such conditions are - available - :param eq_indices: A contiguous array of type `uint32`, shape `(num_eq_conditions)`, that stores the - feature indices of the conditions that use the == operator or None, if no such - conditions are available - :param eq_thresholds: A contiguous array of type `float32`, shape `(num_eq_conditions)` that stores the - thresholds of the conditions that use the == operator or None, if no such conditions are - available - :param neq_indices: A contiguous array of type `uint32`, shape `(num_neq_conditions)`, that stores the - feature indices of the conditions that use the != operator or None, if no such - conditions are available - :param neq_thresholds: A contiguous array of type `float32`, shape `(num_neq_conditions)` that stores the - thresholds of the conditions that use the != operator or None, if no such conditions are - available + :param numerical_leq_indices: A contiguous array of type `uint32`, shape `(num_numerical_leq_conditions)`, + that stores the feature indices of the numerical conditions that use the <= + operator or None, if no such conditions are available + :param numerical_leq_thresholds: A contiguous array of type `float32`, shape `(num_numerical_leq_conditions)` + that stores the thresholds of the numerical conditions that use the <= + operator or None, if no such conditions are available + :param numerical_gr_indices: A contiguous array of type `uint32`, shape `(num_numerical_gr_conditions)`, + that stores the feature indices of the numerical conditions that use the > + operator or None, if no such conditions are available + :param numerical_gr_thresholds: A contiguous array of type `float32`, shape `(num_numerical_gr_conditions)` + that stores the thresholds of the numerical conditions that use the > + operator or None, if no such conditions are available + :param nominal_eq_indices: A contiguous array of type `uint32`, shape `(num_nominal_eq_conditions)`, + that stores the feature indices of the nominal conditions that use the == + operator or None, if no such conditions are available + :param nominal_eq_thresholds: A contiguous array of type `float32`, shape `(num_nominal_eq_conditions)` + that stores the thresholds of the nominal conditions that use the == + operator or None, if no such conditions are available + :param nominal_neq_indices: A contiguous array of type `uint32`, shape `(num_nominal_neq_conditions)`, + that stores the feature indices of the nominal conditions that use the != + operator or None, if no such conditions are available + :param nominal_neq_thresholds: A contiguous array of type `float32`, shape `(num_nominal_neq_conditions)` + that stores the thresholds of the nominal conditions that use the != + operator or None, if no such conditions are available """ - self.leq_indices = np.asarray(leq_indices) if leq_indices is not None else None - self.leq_thresholds = np.asarray(leq_thresholds) if leq_thresholds is not None else None - self.gr_indices = np.asarray(gr_indices) if gr_indices is not None else None - self.gr_thresholds = np.asarray(gr_thresholds) if gr_thresholds is not None else None - self.eq_indices = np.asarray(eq_indices) if eq_indices is not None else None - self.eq_thresholds = np.asarray(eq_thresholds) if eq_thresholds is not None else None - self.neq_indices = np.asarray(neq_indices) if neq_indices is not None else None - self.neq_thresholds = np.asarray(neq_thresholds) if neq_thresholds is not None else None + self.numerical_leq_indices = np.asarray(numerical_leq_indices) if numerical_leq_indices is not None else None + self.numerical_leq_thresholds = \ + np.asarray(numerical_leq_thresholds) if numerical_leq_thresholds is not None else None + self.numerical_gr_indices = np.asarray(numerical_gr_indices) if numerical_gr_indices is not None else None + self.numerical_gr_thresholds = \ + np.asarray(numerical_gr_thresholds) if numerical_gr_thresholds is not None else None + self.nominal_eq_indices = np.asarray(nominal_eq_indices) if nominal_eq_indices is not None else None + self.nominal_eq_thresholds = np.asarray(nominal_eq_thresholds) if nominal_eq_thresholds is not None else None + self.nominal_neq_indices = np.asarray(nominal_neq_indices) if nominal_neq_indices is not None else None + self.nominal_neq_thresholds = np.asarray(nominal_neq_thresholds) if nominal_neq_thresholds is not None else None cdef class CompleteHead: @@ -200,23 +203,34 @@ cdef class RuleList(RuleModel): self.visitor.visit_empty_body(EmptyBody.__new__(EmptyBody)) cdef __visit_conjunctive_body(self, const ConjunctiveBodyImpl& body): - cdef uint32 num_leq = body.getNumLeq() - cdef const uint32[::1] leq_indices = body.leq_indices_cbegin() if num_leq > 0 else None - cdef const float32[::1] leq_thresholds = \ - body.leq_thresholds_cbegin() if num_leq > 0 else None - cdef uint32 num_gr = body.getNumGr() - cdef const uint32[::1] gr_indices = body.gr_indices_cbegin() if num_gr > 0 else None - cdef const float32[::1] gr_thresholds = body.gr_thresholds_cbegin() if num_gr > 0 else None - cdef uint32 num_eq = body.getNumEq() - cdef const uint32[::1] eq_indices = body.eq_indices_cbegin() if num_eq > 0 else None - cdef const float32[::1] eq_thresholds = body.eq_thresholds_cbegin() if num_eq > 0 else None - cdef uint32 num_neq = body.getNumNeq() - cdef const uint32[::1] neq_indices = body.neq_indices_cbegin() if num_neq > 0 else None - cdef const float32[::1] neq_thresholds = \ - body.neq_thresholds_cbegin() if num_neq > 0 else None - self.visitor.visit_conjunctive_body(ConjunctiveBody.__new__(ConjunctiveBody, leq_indices, leq_thresholds, - gr_indices, gr_thresholds, eq_indices, - eq_thresholds, neq_indices, neq_thresholds)) + cdef uint32 num_numerical_leq = body.getNumNumericalLeq() + cdef const uint32[::1] numerical_leq_indices = \ + body.numerical_leq_indices_cbegin() if num_numerical_leq > 0 else None + cdef const float32[::1] numerical_leq_thresholds = \ + body.numerical_leq_thresholds_cbegin() if num_numerical_leq > 0 else None + + cdef uint32 num_numerical_gr = body.getNumNumericalGr() + cdef const uint32[::1] numerical_gr_indices = \ + body.numerical_gr_indices_cbegin() if num_numerical_gr > 0 else None + cdef const float32[::1] numerical_gr_thresholds = \ + body.numerical_gr_thresholds_cbegin() if num_numerical_gr > 0 else None + + cdef uint32 num_nominal_eq = body.getNumNominalEq() + cdef const uint32[::1] nominal_eq_indices = \ + body.nominal_eq_indices_cbegin() if num_nominal_eq > 0 else None + cdef const float32[::1] nominal_eq_thresholds = \ + body.nominal_eq_thresholds_cbegin() if num_nominal_eq > 0 else None + + cdef uint32 num_nominal_neq = body.getNumNominalNeq() + cdef const uint32[::1] nominal_neq_indices = \ + body.nominal_neq_indices_cbegin() if num_nominal_neq > 0 else None + cdef const float32[::1] nominal_neq_thresholds = \ + body.nominal_neq_thresholds_cbegin() if num_nominal_neq > 0 else None + + self.visitor.visit_conjunctive_body( + ConjunctiveBody.__new__(ConjunctiveBody, numerical_leq_indices, numerical_leq_thresholds, + numerical_gr_indices, numerical_gr_thresholds, nominal_eq_indices, + nominal_eq_thresholds, nominal_neq_indices, nominal_neq_thresholds)) cdef __visit_complete_head(self, const CompleteHeadImpl& head): cdef uint32 num_elements = head.getNumElements() @@ -235,18 +249,28 @@ cdef class RuleList(RuleModel): self.state.append(rule_state) cdef __serialize_conjunctive_body(self, const ConjunctiveBodyImpl& body): - cdef uint32 num_leq = body.getNumLeq() - cdef uint32 num_gr = body.getNumGr() - cdef uint32 num_eq = body.getNumEq() - cdef uint32 num_neq = body.getNumNeq() - cdef object body_state = (np.asarray(body.leq_thresholds_cbegin()) if num_leq > 0 else None, - np.asarray(body.leq_indices_cbegin()) if num_leq > 0 else None, - np.asarray(body.gr_thresholds_cbegin()) if num_gr > 0 else None, - np.asarray(body.gr_indices_cbegin()) if num_gr > 0 else None, - np.asarray(body.eq_thresholds_cbegin()) if num_eq > 0 else None, - np.asarray(body.eq_indices_cbegin()) if num_eq > 0 else None, - np.asarray(body.neq_thresholds_cbegin()) if num_neq > 0 else None, - np.asarray(body.neq_indices_cbegin()) if num_neq > 0 else None) + cdef uint32 num_numerical_leq = body.getNumNumericalLeq() + cdef uint32 num_numerical_gr = body.getNumNumericalGr() + cdef uint32 num_nominal_eq = body.getNumNominalEq() + cdef uint32 num_nominal_neq = body.getNumNominalNeq() + cdef object body_state = ( + np.asarray(body.numerical_leq_thresholds_cbegin()) \ + if num_numerical_leq > 0 else None, + np.asarray(body.numerical_leq_indices_cbegin()) \ + if num_numerical_leq > 0 else None, + np.asarray(body.numerical_gr_thresholds_cbegin()) \ + if num_numerical_gr > 0 else None, + np.asarray(body.numerical_gr_indices_cbegin()) \ + if num_numerical_gr > 0 else None, + np.asarray(body.nominal_eq_thresholds_cbegin()) \ + if num_nominal_eq > 0 else None, + np.asarray(body.nominal_eq_indices_cbegin()) \ + if num_nominal_eq > 0 else None, + np.asarray(body.nominal_neq_thresholds_cbegin()) \ + if num_nominal_neq > 0 else None, + np.asarray(body.nominal_neq_indices_cbegin()) \ + if num_nominal_neq > 0 else None, + ) cdef object rule_state = [body_state, None] self.state.append(rule_state) @@ -272,48 +296,48 @@ cdef class RuleList(RuleModel): return move(body_ptr) cdef unique_ptr[IBody] __deserialize_conjunctive_body(self, object body_state): - cdef const float32[::1] leq_thresholds = body_state[0] - cdef const uint32[::1] leq_indices = body_state[1] - cdef const float32[::1] gr_thresholds = body_state[2] - cdef const uint32[::1] gr_indices = body_state[3] - cdef const float32[::1] eq_thresholds = body_state[4] - cdef const uint32[::1] eq_indices = body_state[5] - cdef const float32[::1] neq_thresholds = body_state[6] - cdef const uint32[::1] neq_indices = body_state[7] - cdef uint32 num_leq = leq_thresholds.shape[0] if leq_thresholds is not None else 0 - cdef uint32 num_gr = gr_thresholds.shape[0] if gr_thresholds is not None else 0 - cdef uint32 num_eq = eq_thresholds.shape[0] if eq_thresholds is not None else 0 - cdef uint32 num_neq = neq_thresholds.shape[0] if neq_thresholds is not None else 0 - cdef unique_ptr[ConjunctiveBodyImpl] body_ptr = make_unique[ConjunctiveBodyImpl](num_leq, num_gr, num_eq, - num_neq) - cdef ConjunctiveBodyImpl.threshold_iterator threshold_iterator = body_ptr.get().leq_thresholds_begin() - cdef ConjunctiveBodyImpl.index_iterator index_iterator = body_ptr.get().leq_indices_begin() + cdef const float32[::1] numerical_leq_thresholds = body_state[0] + cdef const uint32[::1] numerical_leq_indices = body_state[1] + cdef const float32[::1] numerical_gr_thresholds = body_state[2] + cdef const uint32[::1] numerical_gr_indices = body_state[3] + cdef const float32[::1] nominal_eq_thresholds = body_state[4] + cdef const uint32[::1] nominal_eq_indices = body_state[5] + cdef const float32[::1] nominal_neq_thresholds = body_state[6] + cdef const uint32[::1] nominal_neq_indices = body_state[7] + cdef uint32 num_numerical_leq = numerical_leq_thresholds.shape[0] if numerical_leq_thresholds is not None else 0 + cdef uint32 num_numerical_gr = numerical_gr_thresholds.shape[0] if numerical_gr_thresholds is not None else 0 + cdef uint32 num_nominal_eq = nominal_eq_thresholds.shape[0] if nominal_eq_thresholds is not None else 0 + cdef uint32 num_nominal_neq = nominal_neq_thresholds.shape[0] if nominal_neq_thresholds is not None else 0 + cdef unique_ptr[ConjunctiveBodyImpl] body_ptr = make_unique[ConjunctiveBodyImpl]( + num_numerical_leq, num_numerical_gr, num_nominal_eq, num_nominal_neq) + cdef ConjunctiveBodyImpl.threshold_iterator threshold_iterator = body_ptr.get().numerical_leq_thresholds_begin() + cdef ConjunctiveBodyImpl.index_iterator index_iterator = body_ptr.get().numerical_leq_indices_begin() cdef uint32 i - for i in range(num_leq): - threshold_iterator[i] = leq_thresholds[i] - index_iterator[i] = leq_indices[i] + for i in range(num_numerical_leq): + threshold_iterator[i] = numerical_leq_thresholds[i] + index_iterator[i] = numerical_leq_indices[i] - threshold_iterator = body_ptr.get().gr_thresholds_begin() - index_iterator = body_ptr.get().gr_indices_begin() + threshold_iterator = body_ptr.get().numerical_gr_thresholds_begin() + index_iterator = body_ptr.get().numerical_gr_indices_begin() - for i in range(num_gr): - threshold_iterator[i] = gr_thresholds[i] - index_iterator[i] = gr_indices[i] + for i in range(num_numerical_gr): + threshold_iterator[i] = numerical_gr_thresholds[i] + index_iterator[i] = numerical_gr_indices[i] - threshold_iterator = body_ptr.get().eq_thresholds_begin() - index_iterator = body_ptr.get().eq_indices_begin() + threshold_iterator = body_ptr.get().nominal_eq_thresholds_begin() + index_iterator = body_ptr.get().nominal_eq_indices_begin() - for i in range(num_eq): - threshold_iterator[i] = eq_thresholds[i] - index_iterator[i] = eq_indices[i] + for i in range(num_nominal_eq): + threshold_iterator[i] = nominal_eq_thresholds[i] + index_iterator[i] = nominal_eq_indices[i] - threshold_iterator = body_ptr.get().neq_thresholds_begin() - index_iterator = body_ptr.get().neq_indices_begin() + threshold_iterator = body_ptr.get().nominal_neq_thresholds_begin() + index_iterator = body_ptr.get().nominal_neq_indices_begin() - for i in range(num_neq): - threshold_iterator[i] = neq_thresholds[i] - index_iterator[i] = neq_indices[i] + for i in range(num_nominal_neq): + threshold_iterator[i] = nominal_neq_thresholds[i] + index_iterator[i] = nominal_neq_indices[i] return move(body_ptr) diff --git a/python/subprojects/testbed/mlrl/testbed/model_characteristics.py b/python/subprojects/testbed/mlrl/testbed/model_characteristics.py index 1a0de5294a..99653f2ebe 100644 --- a/python/subprojects/testbed/mlrl/testbed/model_characteristics.py +++ b/python/subprojects/testbed/mlrl/testbed/model_characteristics.py @@ -59,20 +59,21 @@ class RuleModelCharacteristics(Formattable, Tabularizable): """ def __init__(self, default_rule_index: int, default_rule_pos_predictions: int, - default_rule_neg_predictions: int, num_leq: np.ndarray, num_gr: np.ndarray, num_eq: np.ndarray, - num_neq: np.ndarray, num_pos_predictions: np.ndarray, num_neg_predictions: np.ndarray): + default_rule_neg_predictions: int, num_numerical_leq: np.ndarray, num_numerical_gr: np.ndarray, + num_nominal_eq: np.ndarray, num_nominal_neq: np.ndarray, num_pos_predictions: np.ndarray, + num_neg_predictions: np.ndarray): """ :param default_rule_index: The index of the default rule or None, if no default rule is used :param default_rule_pos_predictions: The number of positive predictions of the default rule, if any :param default_rule_neg_predictions: The number of negative predictions of the default rule, if any - :param num_leq: A `np.ndarray`, shape `(num_rules)` that stores the number of - conditions that use the <= operator per rule - :param num_gr: A `np.ndarray`, shape `(num_rules)` that stores the number of - conditions that use the > operator per rule - :param num_eq: A `np.ndarray`, shape `(num_rules)` that stores the number of - conditions that use the == operator per rule - :param num_neq: A `np.ndarray`, shape `(num_rules)` that stores the number of - conditions that use the != operator per rule + :param num_numerical_leq: A `np.ndarray`, shape `(num_rules)` that stores the number of + numerical conditions that use the <= operator per rule + :param num_numerical_gr: A `np.ndarray`, shape `(num_rules)` that stores the number of + numerical conditions that use the > operator per rule + :param num_nominal_eq: A `np.ndarray`, shape `(num_rules)` that stores the number of + nominal conditions that use the == operator per rule + :param num_nominal_neq: A `np.ndarray`, shape `(num_rules)` that stores the number of + nominal conditions that use the != operator per rule :param num_pos_predictions: A `np.ndarray`, shape `(num_rules)` that stores the number of positive predictions per rule :param num_neg_predictions: A `np.ndarray`, shape `(num_rules)` that stores the number of @@ -81,10 +82,10 @@ def __init__(self, default_rule_index: int, default_rule_pos_predictions: int, self.default_rule_index = default_rule_index self.default_rule_pos_predictions = default_rule_pos_predictions self.default_rule_neg_predictions = default_rule_neg_predictions - self.num_leq = num_leq - self.num_gr = num_gr - self.num_eq = num_eq - self.num_neq = num_neq + self.num_numerical_leq = num_numerical_leq + self.num_numerical_gr = num_numerical_gr + self.num_nominal_eq = num_nominal_eq + self.num_nominal_neq = num_nominal_neq self.num_pos_predictions = num_pos_predictions self.num_neg_predictions = num_neg_predictions @@ -94,23 +95,23 @@ def format(self, options: Options, **_): See :func:`mlrl.testbed.output_writer.Formattable.format` """ num_predictions = self.num_pos_predictions + self.num_neg_predictions - num_conditions = self.num_leq + self.num_gr + self.num_eq + self.num_neq + num_conditions = self.num_numerical_leq + self.num_numerical_gr + self.num_nominal_eq + self.num_nominal_neq num_total_conditions = np.sum(num_conditions) if num_total_conditions > 0: - frac_leq = np.sum(self.num_leq) / num_total_conditions * 100 - frac_gr = np.sum(self.num_gr) / num_total_conditions * 100 - frac_eq = np.sum(self.num_eq) / num_total_conditions * 100 - frac_neq = np.sum(self.num_neq) / num_total_conditions * 100 + frac_numerical_leq = np.sum(self.num_numerical_leq) / num_total_conditions * 100 + frac_numerical_gr = np.sum(self.num_numerical_gr) / num_total_conditions * 100 + frac_nominal_eq = np.sum(self.num_nominal_eq) / num_total_conditions * 100 + frac_nominal_neq = np.sum(self.num_nominal_neq) / num_total_conditions * 100 num_conditions_mean = np.mean(num_conditions) num_conditions_min = np.min(num_conditions) num_conditions_max = np.max(num_conditions) else: - frac_leq = 0.0 - frac_gr = 0.0 - frac_eq = 0.0 - frac_neq = 0.0 + frac_numerical_leq = 0.0 + frac_numerical_gr = 0.0 + frac_nominal_eq = 0.0 + frac_nominal_neq = 0.0 num_conditions_mean = 0.0 num_conditions_min = 0.0 num_conditions_max = 0.0 @@ -149,10 +150,10 @@ def format(self, options: Options, **_): rows.append([ str(num_rules) + ' local rules', str(num_total_conditions), - format_percentage(frac_leq), - format_percentage(frac_gr), - format_percentage(frac_eq), - format_percentage(frac_neq) + format_percentage(frac_numerical_leq), + format_percentage(frac_numerical_gr), + format_percentage(frac_nominal_eq), + format_percentage(frac_nominal_neq) ]) text = format_table(rows, header=header, alignment=alignment) + '\n\n' @@ -211,34 +212,34 @@ def tabularize(self, options: Options, **_) -> Optional[List[Dict[str, str]]]: if i == default_rule_index: rule_name += ' (Default rule)' - num_leq = 0 - num_gr = 0 - num_eq = 0 - num_neq = 0 + num_numerical_leq = 0 + num_numerical_gr = 0 + num_nominal_eq = 0 + num_nominal_neq = 0 num_pos_predictions = self.default_rule_pos_predictions num_neg_predictions = self.default_rule_neg_predictions else: - num_leq = self.num_leq[j] - num_gr = self.num_gr[j] - num_eq = self.num_eq[j] - num_neq = self.num_neq[j] + num_numerical_leq = self.num_numerical_leq[j] + num_numerical_gr = self.num_numerical_gr[j] + num_nominal_eq = self.num_nominal_eq[j] + num_nominal_neq = self.num_nominal_neq[j] num_pos_predictions = self.num_pos_predictions[j] num_neg_predictions = self.num_neg_predictions[j] j += 1 - num_numerical = num_leq + num_gr - num_nominal = num_eq + num_neq + num_numerical = num_numerical_leq + num_numerical_gr + num_nominal = num_nominal_eq + num_nominal_neq num_conditions = num_numerical + num_nominal num_predictions = num_pos_predictions + num_neg_predictions rows.append({ 'Rule': rule_name, 'conditions': num_conditions, 'numerical conditions': num_numerical, - 'conditions using <= operator': num_leq, - 'conditions using > operator': num_gr, + 'conditions using <= operator': num_numerical_leq, + 'conditions using > operator': num_numerical_gr, 'nominal conditions': num_nominal, - 'conditions using == operator': num_eq, - 'conditions using != operator': num_neq, + 'conditions using == operator': num_nominal_eq, + 'conditions using != operator': num_nominal_neq, 'predictions': num_predictions, 'pos. predictions': num_pos_predictions, 'neg. predictions': num_neg_predictions @@ -252,10 +253,10 @@ class RuleModelCharacteristicsVisitor(RuleModelVisitor): """ def __init__(self): - self.num_leq = [] - self.num_gr = [] - self.num_eq = [] - self.num_neq = [] + self.num_numerical_leq = [] + self.num_numerical_gr = [] + self.num_nominal_eq = [] + self.num_nominal_neq = [] self.num_pos_predictions = [] self.num_neg_predictions = [] self.default_rule_index = None @@ -275,10 +276,13 @@ def visit_conjunctive_body(self, body: ConjunctiveBody): See :func:`mlrl.common.cython.rule_model.RuleModelVisitor.visit_conjunctive_body` """ self.index += 1 - self.num_leq.append(body.leq_indices.shape[0] if body.leq_indices is not None else 0) - self.num_gr.append(body.gr_indices.shape[0] if body.gr_indices is not None else 0) - self.num_eq.append(body.eq_indices.shape[0] if body.eq_indices is not None else 0) - self.num_neq.append(body.neq_indices.shape[0] if body.neq_indices is not None else 0) + self.num_numerical_leq.append( + body.numerical_leq_indices.shape[0] if body.numerical_leq_indices is not None else 0) + self.num_numerical_gr.append( + body.numerical_gr_indices.shape[0] if body.numerical_gr_indices is not None else 0) + self.num_nominal_eq.append(body.nominal_eq_indices.shape[0] if body.nominal_eq_indices is not None else 0) + self.num_nominal_neq.append( + body.nominal_neq_indices.shape[0] if body.nominal_neq_indices is not None else 0) def visit_complete_head(self, head: CompleteHead): """ @@ -323,10 +327,10 @@ def _generate_output_data(self, meta_data: MetaData, x, y, data_split: DataSplit default_rule_index=visitor.default_rule_index, default_rule_pos_predictions=visitor.default_rule_pos_predictions, default_rule_neg_predictions=visitor.default_rule_neg_predictions, - num_leq=np.asarray(visitor.num_leq), - num_gr=np.asarray(visitor.num_gr), - num_eq=np.asarray(visitor.num_eq), - num_neq=np.asarray(visitor.num_neq), + num_numerical_leq=np.asarray(visitor.num_numerical_leq), + num_numerical_gr=np.asarray(visitor.num_numerical_gr), + num_nominal_eq=np.asarray(visitor.num_nominal_eq), + num_nominal_neq=np.asarray(visitor.num_nominal_neq), num_pos_predictions=np.asarray(visitor.num_pos_predictions), num_neg_predictions=np.asarray(visitor.num_neg_predictions)) diff --git a/python/subprojects/testbed/mlrl/testbed/models.py b/python/subprojects/testbed/mlrl/testbed/models.py index 8b97884b62..6491943cfe 100644 --- a/python/subprojects/testbed/mlrl/testbed/models.py +++ b/python/subprojects/testbed/mlrl/testbed/models.py @@ -149,10 +149,13 @@ def visit_conjunctive_body(self, body: ConjunctiveBody): if self.print_bodies: text = self.text text.write('{') - num_conditions = self.__format_conditions(0, body.leq_indices, body.leq_thresholds, '<=') - num_conditions = self.__format_conditions(num_conditions, body.gr_indices, body.gr_thresholds, '>') - num_conditions = self.__format_conditions(num_conditions, body.eq_indices, body.eq_thresholds, '==') - self.__format_conditions(num_conditions, body.neq_indices, body.neq_thresholds, '!=') + num_conditions = self.__format_conditions(0, body.numerical_leq_indices, body.numerical_leq_thresholds, + '<=') + num_conditions = self.__format_conditions(num_conditions, body.numerical_gr_indices, + body.numerical_gr_thresholds, '>') + num_conditions = self.__format_conditions(num_conditions, body.nominal_eq_indices, + body.nominal_eq_thresholds, '==') + self.__format_conditions(num_conditions, body.nominal_neq_indices, body.nominal_neq_thresholds, '!=') text.write('}') def visit_complete_head(self, head: CompleteHead): From 0aded8c9ada58fb825567474d24d38f59c5e09f0 Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Wed, 9 Aug 2023 00:41:35 +0200 Subject: [PATCH 02/20] Rename values of the enum Comparator. --- .../include/mlrl/common/model/condition.hpp | 8 ++--- .../src/mlrl/common/model/condition_list.cpp | 14 ++++---- .../rule_refinement_approximate.cpp | 28 +++++++-------- .../rule_refinement/rule_refinement_exact.cpp | 36 +++++++++---------- .../common/thresholds/thresholds_exact.cpp | 2 +- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/cpp/subprojects/common/include/mlrl/common/model/condition.hpp b/cpp/subprojects/common/include/mlrl/common/model/condition.hpp index 14edb91cac..35a0b2034e 100644 --- a/cpp/subprojects/common/include/mlrl/common/model/condition.hpp +++ b/cpp/subprojects/common/include/mlrl/common/model/condition.hpp @@ -9,10 +9,10 @@ * An enum that specifies all possible types of operators used by a condition of a rule. */ enum Comparator : uint8 { - LEQ = 0, - GR = 1, - EQ = 2, - NEQ = 3 + NUMERICAL_LEQ = 0, + NUMERICAL_GR = 1, + NOMINAL_EQ = 2, + NOMINAL_NEQ = 3 }; /** diff --git a/cpp/subprojects/common/src/mlrl/common/model/condition_list.cpp b/cpp/subprojects/common/src/mlrl/common/model/condition_list.cpp index 158cf3d525..62c2be747c 100644 --- a/cpp/subprojects/common/src/mlrl/common/model/condition_list.cpp +++ b/cpp/subprojects/common/src/mlrl/common/model/condition_list.cpp @@ -32,9 +32,9 @@ void ConditionList::removeLastCondition() { }; std::unique_ptr ConditionList::createConjunctiveBody() const { - std::unique_ptr bodyPtr = - std::make_unique(numConditionsPerComparator_[LEQ], numConditionsPerComparator_[GR], - numConditionsPerComparator_[EQ], numConditionsPerComparator_[NEQ]); + std::unique_ptr bodyPtr = std::make_unique( + numConditionsPerComparator_[NUMERICAL_LEQ], numConditionsPerComparator_[NUMERICAL_GR], + numConditionsPerComparator_[NOMINAL_EQ], numConditionsPerComparator_[NOMINAL_NEQ]); uint32 numericalLeqIndex = 0; uint32 numericalGrIndex = 0; uint32 nominalEqIndex = 0; @@ -46,25 +46,25 @@ std::unique_ptr ConditionList::createConjunctiveBody() const { float32 threshold = condition.threshold; switch (condition.comparator) { - case LEQ: { + case NUMERICAL_LEQ: { bodyPtr->numerical_leq_indices_begin()[numericalLeqIndex] = featureIndex; bodyPtr->numerical_leq_thresholds_begin()[numericalLeqIndex] = threshold; numericalLeqIndex++; break; } - case GR: { + case NUMERICAL_GR: { bodyPtr->numerical_gr_indices_begin()[numericalGrIndex] = featureIndex; bodyPtr->numerical_gr_thresholds_begin()[numericalGrIndex] = threshold; numericalGrIndex++; break; } - case EQ: { + case NOMINAL_EQ: { bodyPtr->nominal_eq_indices_begin()[nominalEqIndex] = featureIndex; bodyPtr->nominal_eq_thresholds_begin()[nominalEqIndex] = threshold; nominalEqIndex++; break; } - case NEQ: { + case NOMINAL_NEQ: { bodyPtr->nominal_neq_indices_begin()[nominalNeqIndex] = featureIndex; bodyPtr->nominal_neq_thresholds_begin()[nominalNeqIndex] = threshold; nominalNeqIndex++; diff --git a/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_approximate.cpp b/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_approximate.cpp index 58aaa16b49..2477cd7e95 100644 --- a/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_approximate.cpp +++ b/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_approximate.cpp @@ -66,7 +66,7 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin refinement.numCovered = numCovered; refinement.covered = true; refinement.threshold = thresholdIterator[r - 1]; - refinement.comparator = nominal ? EQ : LEQ; + refinement.comparator = nominal ? NOMINAL_EQ : NUMERICAL_LEQ; comparator.pushRefinement(refinement, scoreVector); } } @@ -86,7 +86,7 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin refinement.numCovered = coverage; refinement.covered = false; refinement.threshold = thresholdIterator[r - 1]; - refinement.comparator = nominal ? NEQ : GR; + refinement.comparator = nominal ? NOMINAL_NEQ : NUMERICAL_GR; comparator.pushRefinement(refinement, scoreVector); } } @@ -122,7 +122,7 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin refinement.numCovered = numCovered; refinement.covered = true; refinement.threshold = thresholdIterator[sparseBinIndex - 1]; - refinement.comparator = nominal ? EQ : LEQ; + refinement.comparator = nominal ? NOMINAL_EQ : NUMERICAL_LEQ; comparator.pushRefinement(refinement, scoreVector); } } @@ -142,7 +142,7 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin refinement.numCovered = coverage; refinement.covered = false; refinement.threshold = thresholdIterator[sparseBinIndex - 1]; - refinement.comparator = nominal ? NEQ : GR; + refinement.comparator = nominal ? NOMINAL_NEQ : NUMERICAL_GR; comparator.pushRefinement(refinement, scoreVector); } } @@ -194,10 +194,10 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin if (nominal) { refinement.threshold = thresholdIterator[firstR]; - refinement.comparator = EQ; + refinement.comparator = NOMINAL_EQ; } else { refinement.threshold = thresholdIterator[r]; - refinement.comparator = GR; + refinement.comparator = NUMERICAL_GR; } comparator.pushRefinement(refinement, scoreVector); @@ -221,10 +221,10 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin if (nominal) { refinement.threshold = thresholdIterator[firstR]; - refinement.comparator = NEQ; + refinement.comparator = NOMINAL_NEQ; } else { refinement.threshold = thresholdIterator[r]; - refinement.comparator = LEQ; + refinement.comparator = NUMERICAL_LEQ; } comparator.pushRefinement(refinement, scoreVector); @@ -264,10 +264,10 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin if (nominal) { refinement.threshold = thresholdIterator[firstR]; - refinement.comparator = EQ; + refinement.comparator = NOMINAL_EQ; } else { refinement.threshold = thresholdIterator[sparseBinIndex]; - refinement.comparator = GR; + refinement.comparator = NUMERICAL_GR; } comparator.pushRefinement(refinement, scoreVector); @@ -291,10 +291,10 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin if (nominal) { refinement.threshold = thresholdIterator[firstR]; - refinement.comparator = NEQ; + refinement.comparator = NOMINAL_NEQ; } else { refinement.threshold = thresholdIterator[sparseBinIndex]; - refinement.comparator = LEQ; + refinement.comparator = NUMERICAL_LEQ; } comparator.pushRefinement(refinement, scoreVector); @@ -323,7 +323,7 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin refinement.numCovered = coverage; refinement.covered = false; refinement.threshold = thresholdIterator[sparseBinIndex]; - refinement.comparator = NEQ; + refinement.comparator = NOMINAL_NEQ; comparator.pushRefinement(refinement, scoreVector); } } @@ -343,7 +343,7 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin refinement.numCovered = coverage; refinement.covered = true; refinement.threshold = thresholdIterator[sparseBinIndex]; - refinement.comparator = EQ; + refinement.comparator = NOMINAL_EQ; comparator.pushRefinement(refinement, scoreVector); } } diff --git a/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_exact.cpp b/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_exact.cpp index c33403d9f9..c1f6a1aa48 100644 --- a/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_exact.cpp +++ b/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_exact.cpp @@ -116,10 +116,10 @@ static inline void findRefinementInternally( refinement.covered = true; if (nominal) { - refinement.comparator = EQ; + refinement.comparator = NOMINAL_EQ; refinement.threshold = previousThreshold; } else { - refinement.comparator = LEQ; + refinement.comparator = NUMERICAL_LEQ; refinement.threshold = arithmeticMean(previousThreshold, currentThreshold); } @@ -144,10 +144,10 @@ static inline void findRefinementInternally( refinement.covered = false; if (nominal) { - refinement.comparator = NEQ; + refinement.comparator = NOMINAL_NEQ; refinement.threshold = previousThreshold; } else { - refinement.comparator = GR; + refinement.comparator = NUMERICAL_GR; refinement.threshold = arithmeticMean(previousThreshold, currentThreshold); } @@ -190,7 +190,7 @@ static inline void findRefinementInternally( refinement.previous = previousR; refinement.numCovered = numCovered; refinement.covered = true; - refinement.comparator = EQ; + refinement.comparator = NOMINAL_EQ; refinement.threshold = previousThreshold; comparator.pushRefinement(refinement, scoreVector); } @@ -210,7 +210,7 @@ static inline void findRefinementInternally( refinement.previous = previousR; refinement.numCovered = coverage; refinement.covered = false; - refinement.comparator = NEQ; + refinement.comparator = NOMINAL_NEQ; refinement.threshold = previousThreshold; comparator.pushRefinement(refinement, scoreVector); } @@ -272,10 +272,10 @@ static inline void findRefinementInternally( refinement.covered = true; if (nominal) { - refinement.comparator = EQ; + refinement.comparator = NOMINAL_EQ; refinement.threshold = previousThreshold; } else { - refinement.comparator = GR; + refinement.comparator = NUMERICAL_GR; refinement.threshold = arithmeticMean(currentThreshold, previousThreshold); } @@ -300,10 +300,10 @@ static inline void findRefinementInternally( refinement.covered = false; if (nominal) { - refinement.comparator = NEQ; + refinement.comparator = NOMINAL_NEQ; refinement.threshold = previousThreshold; } else { - refinement.comparator = LEQ; + refinement.comparator = NUMERICAL_LEQ; refinement.threshold = arithmeticMean(currentThreshold, previousThreshold); } @@ -347,7 +347,7 @@ static inline void findRefinementInternally( refinement.previous = previousR; refinement.numCovered = numCovered; refinement.covered = true; - refinement.comparator = EQ; + refinement.comparator = NOMINAL_EQ; refinement.threshold = previousThreshold; comparator.pushRefinement(refinement, scoreVector); } @@ -367,7 +367,7 @@ static inline void findRefinementInternally( refinement.previous = previousR; refinement.numCovered = coverage; refinement.covered = false; - refinement.comparator = NEQ; + refinement.comparator = NOMINAL_NEQ; refinement.threshold = previousThreshold; comparator.pushRefinement(refinement, scoreVector); } @@ -406,12 +406,12 @@ static inline void findRefinementInternally( if (nominal) { refinement.end = -1; refinement.previous = -1; - refinement.comparator = NEQ; + refinement.comparator = NOMINAL_NEQ; refinement.threshold = 0.0; } else { refinement.end = lastNegativeR; refinement.previous = previousR; - refinement.comparator = GR; + refinement.comparator = NUMERICAL_GR; refinement.threshold = previousThreshold * 0.5; } @@ -437,13 +437,13 @@ static inline void findRefinementInternally( if (nominal) { refinement.end = -1; refinement.previous = -1; - refinement.comparator = EQ; + refinement.comparator = NOMINAL_EQ; refinement.threshold = 0.0; } else { refinement.end = lastNegativeR; refinement.previous = previousR; refinement.numCovered = (numExamples - numAccumulated); - refinement.comparator = LEQ; + refinement.comparator = NUMERICAL_LEQ; refinement.threshold = previousThreshold * 0.5; } @@ -470,7 +470,7 @@ static inline void findRefinementInternally( refinement.previous = previousRNegative; refinement.numCovered = numAccumulatedNegative; refinement.covered = true; - refinement.comparator = LEQ; + refinement.comparator = NUMERICAL_LEQ; if (numAccumulatedTotal < numExamples) { // If the condition separates an example with feature value < 0 from an (sparse) example with @@ -500,7 +500,7 @@ static inline void findRefinementInternally( refinement.previous = previousRNegative; refinement.numCovered = coverage; refinement.covered = false; - refinement.comparator = GR; + refinement.comparator = NUMERICAL_GR; if (numAccumulatedTotal < numExamples) { // If the condition separates an example with feature value < 0 from an (sparse) example with diff --git a/cpp/subprojects/common/src/mlrl/common/thresholds/thresholds_exact.cpp b/cpp/subprojects/common/src/mlrl/common/thresholds/thresholds_exact.cpp index 8868da6c2b..1ddfde28f2 100644 --- a/cpp/subprojects/common/src/mlrl/common/thresholds/thresholds_exact.cpp +++ b/cpp/subprojects/common/src/mlrl/common/thresholds/thresholds_exact.cpp @@ -107,7 +107,7 @@ static inline void filterCurrentVector(const FeatureVector& vector, FilteredCach statistics.removeCoveredStatistic(index); } - if (conditionComparator == NEQ) { + if (conditionComparator == NOMINAL_NEQ) { // Retain the indices at positions [currentStart, currentEnd), while leaving the corresponding values in // `coverageMask` untouched, such that all previously covered examples in said range are still marked // as covered, while previously uncovered examples are still marked as uncovered... From a069b91c3a84376f1680a29bd5a8984d619dd3a9 Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 15:55:15 +0200 Subject: [PATCH 03/20] The class CompleteHead now uses a DenseVector. --- .../include/mlrl/common/model/head_complete.hpp | 12 ++++-------- .../src/mlrl/common/model/head_complete.cpp | 16 ++++++---------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/cpp/subprojects/common/include/mlrl/common/model/head_complete.hpp b/cpp/subprojects/common/include/mlrl/common/model/head_complete.hpp index adee57778c..60645a255f 100644 --- a/cpp/subprojects/common/include/mlrl/common/model/head_complete.hpp +++ b/cpp/subprojects/common/include/mlrl/common/model/head_complete.hpp @@ -3,7 +3,7 @@ */ #pragma once -#include "mlrl/common/data/types.hpp" +#include "mlrl/common/data/vector_dense.hpp" #include "mlrl/common/model/head.hpp" /** @@ -12,9 +12,7 @@ class MLRLCOMMON_API CompleteHead final : public IHead { private: - const uint32 numElements_; - - float64* scores_; + DenseVector scores_; public: @@ -23,17 +21,15 @@ class MLRLCOMMON_API CompleteHead final : public IHead { */ CompleteHead(uint32 numElements); - ~CompleteHead() override; - /** * An iterator that provides access to the scores the are contained by the head and allows to modify them. */ - typedef float64* score_iterator; + typedef DenseVector::iterator score_iterator; /** * An iterator that provides read-only access to the scores that are contained by the head. */ - typedef const float64* score_const_iterator; + typedef DenseVector::const_iterator score_const_iterator; /** * Returns the number of scores that are contained by the head. diff --git a/cpp/subprojects/common/src/mlrl/common/model/head_complete.cpp b/cpp/subprojects/common/src/mlrl/common/model/head_complete.cpp index e88a0900a6..05060d99db 100644 --- a/cpp/subprojects/common/src/mlrl/common/model/head_complete.cpp +++ b/cpp/subprojects/common/src/mlrl/common/model/head_complete.cpp @@ -1,29 +1,25 @@ #include "mlrl/common/model/head_complete.hpp" -CompleteHead::CompleteHead(uint32 numElements) : numElements_(numElements), scores_(new float64[numElements]) {} - -CompleteHead::~CompleteHead() { - delete[] scores_; -} +CompleteHead::CompleteHead(uint32 numElements) : scores_(DenseVector(numElements)) {} uint32 CompleteHead::getNumElements() const { - return numElements_; + return scores_.getNumElements(); } CompleteHead::score_iterator CompleteHead::scores_begin() { - return scores_; + return scores_.begin(); } CompleteHead::score_iterator CompleteHead::scores_end() { - return &scores_[numElements_]; + return scores_.end(); } CompleteHead::score_const_iterator CompleteHead::scores_cbegin() const { - return scores_; + return scores_.cbegin(); } CompleteHead::score_const_iterator CompleteHead::scores_cend() const { - return &scores_[numElements_]; + return scores_.cend(); } void CompleteHead::visit(CompleteHeadVisitor completeHeadVisitor, PartialHeadVisitor partialHeadVisitor) const { From e4b9b222322c10b8fed7fcb716369fd2cc549c8f Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 15:58:18 +0200 Subject: [PATCH 04/20] Export class SparseArrayVector. --- .../common/include/mlrl/common/data/vector_sparse_array.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_array.hpp b/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_array.hpp index ce0d83ec5b..1c9bccba8f 100644 --- a/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_array.hpp +++ b/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_array.hpp @@ -15,7 +15,7 @@ * @tparam T The type of the data that is stored in the vector */ template -class SparseArrayVector final : public DenseVector> { +class MLRLCOMMON_API SparseArrayVector final : public DenseVector> { private: /** From 0d89a5ea49dab1ad1038ec2427bb2957b3906b72 Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 16:11:49 +0200 Subject: [PATCH 05/20] Do not export class SparseArrayVector. --- .../common/include/mlrl/common/data/vector_sparse_array.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_array.hpp b/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_array.hpp index 1c9bccba8f..ce0d83ec5b 100644 --- a/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_array.hpp +++ b/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_array.hpp @@ -15,7 +15,7 @@ * @tparam T The type of the data that is stored in the vector */ template -class MLRLCOMMON_API SparseArrayVector final : public DenseVector> { +class SparseArrayVector final : public DenseVector> { private: /** From 8015c7ecf788a5dad4de5c27123d6b1807d7481a Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 16:15:36 +0200 Subject: [PATCH 06/20] The class PartialHead now uses DenseVectors. --- .../mlrl/common/model/head_partial.hpp | 18 ++++++------- .../src/mlrl/common/model/head_partial.cpp | 25 ++++++++----------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/cpp/subprojects/common/include/mlrl/common/model/head_partial.hpp b/cpp/subprojects/common/include/mlrl/common/model/head_partial.hpp index 7d104f7904..2856287158 100644 --- a/cpp/subprojects/common/include/mlrl/common/model/head_partial.hpp +++ b/cpp/subprojects/common/include/mlrl/common/model/head_partial.hpp @@ -3,7 +3,7 @@ */ #pragma once -#include "mlrl/common/data/types.hpp" +#include "mlrl/common/data/vector_dense.hpp" #include "mlrl/common/model/head.hpp" /** @@ -12,11 +12,9 @@ class MLRLCOMMON_API PartialHead final : public IHead { private: - const uint32 numElements_; + DenseVector scores_; - float64* scores_; - - uint32* labelIndices_; + DenseVector labelIndices_; public: @@ -25,29 +23,27 @@ class MLRLCOMMON_API PartialHead final : public IHead { */ PartialHead(uint32 numElements); - ~PartialHead() override; - /** * An iterator that provides access to the scores that are contained by the head and allows to modify them. */ - typedef float64* score_iterator; + typedef DenseVector::iterator score_iterator; /** * An iterator that provides read-only access to the scores that are contained by the head. */ - typedef const float64* score_const_iterator; + typedef DenseVector::const_iterator score_const_iterator; /** * An iterator that provides access to the indices, the scores that are contained by the head, correspond to and * allows to modify them. */ - typedef uint32* index_iterator; + typedef DenseVector::iterator index_iterator; /** * An iterator that provides read-only access to the indices, the scores that are contained by the head, * correspond to. */ - typedef const uint32* index_const_iterator; + typedef DenseVector::const_iterator index_const_iterator; /** * Returns the number of scores that are contained by the head. diff --git a/cpp/subprojects/common/src/mlrl/common/model/head_partial.cpp b/cpp/subprojects/common/src/mlrl/common/model/head_partial.cpp index 00e523f1bb..7ff1e9d989 100644 --- a/cpp/subprojects/common/src/mlrl/common/model/head_partial.cpp +++ b/cpp/subprojects/common/src/mlrl/common/model/head_partial.cpp @@ -1,47 +1,42 @@ #include "mlrl/common/model/head_partial.hpp" PartialHead::PartialHead(uint32 numElements) - : numElements_(numElements), scores_(new float64[numElements]), labelIndices_(new uint32[numElements]) {} - -PartialHead::~PartialHead() { - delete[] scores_; - delete[] labelIndices_; -} + : scores_(DenseVector(numElements)), labelIndices_(DenseVector(numElements)) {} uint32 PartialHead::getNumElements() const { - return numElements_; + return scores_.getNumElements(); } PartialHead::score_iterator PartialHead::scores_begin() { - return scores_; + return scores_.begin(); } PartialHead::score_iterator PartialHead::scores_end() { - return &scores_[numElements_]; + return scores_.end(); } PartialHead::score_const_iterator PartialHead::scores_cbegin() const { - return scores_; + return scores_.cbegin(); } PartialHead::score_const_iterator PartialHead::scores_cend() const { - return &scores_[numElements_]; + return scores_.cend(); } PartialHead::index_iterator PartialHead::indices_begin() { - return labelIndices_; + return labelIndices_.begin(); } PartialHead::index_iterator PartialHead::indices_end() { - return &labelIndices_[numElements_]; + return labelIndices_.end(); } PartialHead::index_const_iterator PartialHead::indices_cbegin() const { - return labelIndices_; + return labelIndices_.cbegin(); } PartialHead::index_const_iterator PartialHead::indices_cend() const { - return &labelIndices_[numElements_]; + return labelIndices_.cend(); } void PartialHead::visit(CompleteHeadVisitor completeHeadVisitor, PartialHeadVisitor partialHeadVisitor) const { From 989b4de880be1b2b67cc1e1e5d51b2639a116198 Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 16:49:47 +0200 Subject: [PATCH 07/20] Add class SparseArraysVector. --- .../mlrl/common/data/vector_sparse_arrays.hpp | 107 ++++++++++++++++++ cpp/subprojects/common/meson.build | 1 + .../mlrl/common/data/vector_sparse_arrays.cpp | 55 +++++++++ 3 files changed, 163 insertions(+) create mode 100644 cpp/subprojects/common/include/mlrl/common/data/vector_sparse_arrays.hpp create mode 100644 cpp/subprojects/common/src/mlrl/common/data/vector_sparse_arrays.cpp diff --git a/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_arrays.hpp b/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_arrays.hpp new file mode 100644 index 0000000000..787f9b0a5e --- /dev/null +++ b/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_arrays.hpp @@ -0,0 +1,107 @@ +/* + * @author Michael Rapp (michael.rapp.ml@gmail.com) + */ +#pragma once + +#include "mlrl/common/data/vector_dense.hpp" + +/** + * An one-dimensional sparse vector that stores a fixed number of elements, consisting of an index and a value, in + * C-contiguous arrays. Such a vector is similar to a `SparseArrayVector`, but uses separate arrays for storing the + * indices and values. + * + * @tparam T The type of the data that is stored in the vector + */ +template +class SparseArraysVector final : public IOneDimensionalView { + private: + + DenseVector indices_; + + DenseVector values_; + + public: + + /** + * @param numElements The number of elements in the vector + */ + SparseArraysVector(uint32 numElements); + + /** + * An iterator that provides access to the indices in the vector and allows to modify them. + */ + typedef DenseVector::iterator index_iterator; + + /** + * An iterator that provides read-only access to the indices in the vector. + */ + typedef DenseVector::const_iterator index_const_iterator; + + /** + * An iterator that provides access to the values in the vector and allows to modify them. + */ + typedef typename DenseVector::iterator value_iterator; + + /** + * An iterator that provides read-only access to the values in the vector. + */ + typedef typename DenseVector::const_iterator value_const_iterator; + + /** + * Returns an `index_iterator` to the beginning of the indices in the vector. + * + * @return An `index_iterator` to the beginning + */ + index_iterator indices_begin(); + + /** + * Returns an `index_iterator` to the end of the indices in the vector. + * + * @return An `index_iterator` to the end + */ + index_iterator indices_end(); + + /** + * Returns an `index_const_iterator` to the beginning of the indices in the vector. + * + * @return An `index_const_iterator` to the beginning + */ + index_const_iterator indices_cbegin() const; + + /** + * Returns an `index_const_iterator` to the end of the indices in the vector. + * + * @return An `index_const_iterator` to the end + */ + index_const_iterator indices_cend() const; + + /** + * Returns a `value_iterator` to the beginning of the values in the vector. + * + * @return A `value_iterator` to the beginning + */ + value_iterator values_begin(); + + /** + * Returns a `value_iterator` to the end of the values in the vector. + * + * @return A `value_iterator` to the end + */ + value_iterator values_end(); + + /** + * Returns a `value_const_iterator` to the beginning of the values in the vector. + * + * @return A `value_const_iterator` to the beginning + */ + value_const_iterator values_cbegin() const; + + /** + * Returns a `value_const_iterator` to the end of the values in the vector. + * + * @return A `value_const_iterator` to the end + */ + value_const_iterator values_cend() const; + + uint32 getNumElements() const override; +}; diff --git a/cpp/subprojects/common/meson.build b/cpp/subprojects/common/meson.build index 34d240c7ad..e4e19c0220 100644 --- a/cpp/subprojects/common/meson.build +++ b/cpp/subprojects/common/meson.build @@ -19,6 +19,7 @@ source_files = [ 'src/mlrl/common/data/vector_dok.cpp', 'src/mlrl/common/data/vector_dok_binary.cpp', 'src/mlrl/common/data/vector_sparse_array.cpp', + 'src/mlrl/common/data/vector_sparse_arrays.cpp', 'src/mlrl/common/data/view_c_contiguous.cpp', 'src/mlrl/common/data/view_csc.cpp', 'src/mlrl/common/data/view_csc_binary.cpp', diff --git a/cpp/subprojects/common/src/mlrl/common/data/vector_sparse_arrays.cpp b/cpp/subprojects/common/src/mlrl/common/data/vector_sparse_arrays.cpp new file mode 100644 index 0000000000..c966955837 --- /dev/null +++ b/cpp/subprojects/common/src/mlrl/common/data/vector_sparse_arrays.cpp @@ -0,0 +1,55 @@ +#include "mlrl/common/data/vector_sparse_arrays.hpp" + +template +SparseArraysVector::SparseArraysVector(uint32 numElements) + : indices_(DenseVector(numElements)), values_(DenseVector(numElements)) {} + +template +typename SparseArraysVector::index_iterator SparseArraysVector::indices_begin() { + return indices_.begin(); +} + +template +typename SparseArraysVector::index_iterator SparseArraysVector::indices_end() { + return indices_.end(); +} + +template +typename SparseArraysVector::index_const_iterator SparseArraysVector::indices_cbegin() const { + return indices_.cbegin(); +} + +template +typename SparseArraysVector::index_const_iterator SparseArraysVector::indices_cend() const { + return indices_.cend(); +} + +template +typename SparseArraysVector::value_iterator SparseArraysVector::values_begin() { + return values_.begin(); +} + +template +typename SparseArraysVector::value_iterator SparseArraysVector::values_end() { + return values_.end(); +} + +template +typename SparseArraysVector::value_const_iterator SparseArraysVector::values_cbegin() const { + return values_.cbegin(); +} + +template +typename SparseArraysVector::value_const_iterator SparseArraysVector::values_cend() const { + return values_.cend(); +} + +template +uint32 SparseArraysVector::getNumElements() const { + return indices_.getNumElements(); +} + +template class SparseArraysVector; +template class SparseArraysVector; +template class SparseArraysVector; +template class SparseArraysVector; From 01aac76d4b26b0bffe12abe898f4a442b5975cfb Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 16:54:38 +0200 Subject: [PATCH 08/20] The class PartialHead now uses a SparseArraysVector. --- .../mlrl/common/model/head_partial.hpp | 14 ++++++------- .../src/mlrl/common/model/head_partial.cpp | 21 +++++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/cpp/subprojects/common/include/mlrl/common/model/head_partial.hpp b/cpp/subprojects/common/include/mlrl/common/model/head_partial.hpp index 2856287158..7b6425ccf1 100644 --- a/cpp/subprojects/common/include/mlrl/common/model/head_partial.hpp +++ b/cpp/subprojects/common/include/mlrl/common/model/head_partial.hpp @@ -3,7 +3,7 @@ */ #pragma once -#include "mlrl/common/data/vector_dense.hpp" +#include "mlrl/common/data/vector_sparse_arrays.hpp" #include "mlrl/common/model/head.hpp" /** @@ -12,9 +12,7 @@ class MLRLCOMMON_API PartialHead final : public IHead { private: - DenseVector scores_; - - DenseVector labelIndices_; + SparseArraysVector vector_; public: @@ -26,24 +24,24 @@ class MLRLCOMMON_API PartialHead final : public IHead { /** * An iterator that provides access to the scores that are contained by the head and allows to modify them. */ - typedef DenseVector::iterator score_iterator; + typedef SparseArraysVector::value_iterator score_iterator; /** * An iterator that provides read-only access to the scores that are contained by the head. */ - typedef DenseVector::const_iterator score_const_iterator; + typedef SparseArraysVector::value_const_iterator score_const_iterator; /** * An iterator that provides access to the indices, the scores that are contained by the head, correspond to and * allows to modify them. */ - typedef DenseVector::iterator index_iterator; + typedef SparseArraysVector::index_iterator index_iterator; /** * An iterator that provides read-only access to the indices, the scores that are contained by the head, * correspond to. */ - typedef DenseVector::const_iterator index_const_iterator; + typedef SparseArraysVector::index_const_iterator index_const_iterator; /** * Returns the number of scores that are contained by the head. diff --git a/cpp/subprojects/common/src/mlrl/common/model/head_partial.cpp b/cpp/subprojects/common/src/mlrl/common/model/head_partial.cpp index 7ff1e9d989..5be5452308 100644 --- a/cpp/subprojects/common/src/mlrl/common/model/head_partial.cpp +++ b/cpp/subprojects/common/src/mlrl/common/model/head_partial.cpp @@ -1,42 +1,41 @@ #include "mlrl/common/model/head_partial.hpp" -PartialHead::PartialHead(uint32 numElements) - : scores_(DenseVector(numElements)), labelIndices_(DenseVector(numElements)) {} +PartialHead::PartialHead(uint32 numElements) : vector_(SparseArraysVector(numElements)) {} uint32 PartialHead::getNumElements() const { - return scores_.getNumElements(); + return vector_.getNumElements(); } PartialHead::score_iterator PartialHead::scores_begin() { - return scores_.begin(); + return vector_.values_begin(); } PartialHead::score_iterator PartialHead::scores_end() { - return scores_.end(); + return vector_.values_end(); } PartialHead::score_const_iterator PartialHead::scores_cbegin() const { - return scores_.cbegin(); + return vector_.values_cbegin(); } PartialHead::score_const_iterator PartialHead::scores_cend() const { - return scores_.cend(); + return vector_.values_cend(); } PartialHead::index_iterator PartialHead::indices_begin() { - return labelIndices_.begin(); + return vector_.indices_begin(); } PartialHead::index_iterator PartialHead::indices_end() { - return labelIndices_.end(); + return vector_.indices_end(); } PartialHead::index_const_iterator PartialHead::indices_cbegin() const { - return labelIndices_.cbegin(); + return vector_.indices_cbegin(); } PartialHead::index_const_iterator PartialHead::indices_cend() const { - return labelIndices_.cend(); + return vector_.indices_cend(); } void PartialHead::visit(CompleteHeadVisitor completeHeadVisitor, PartialHeadVisitor partialHeadVisitor) const { From 31a21e9d223b9bcf721a82c4caac9bbeeed1ce26 Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 16:55:43 +0200 Subject: [PATCH 09/20] Rename class member. --- .../include/mlrl/common/model/head_complete.hpp | 2 +- .../common/src/mlrl/common/model/head_complete.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cpp/subprojects/common/include/mlrl/common/model/head_complete.hpp b/cpp/subprojects/common/include/mlrl/common/model/head_complete.hpp index 60645a255f..8ee0802896 100644 --- a/cpp/subprojects/common/include/mlrl/common/model/head_complete.hpp +++ b/cpp/subprojects/common/include/mlrl/common/model/head_complete.hpp @@ -12,7 +12,7 @@ class MLRLCOMMON_API CompleteHead final : public IHead { private: - DenseVector scores_; + DenseVector vector_; public: diff --git a/cpp/subprojects/common/src/mlrl/common/model/head_complete.cpp b/cpp/subprojects/common/src/mlrl/common/model/head_complete.cpp index 05060d99db..801f7d0bf9 100644 --- a/cpp/subprojects/common/src/mlrl/common/model/head_complete.cpp +++ b/cpp/subprojects/common/src/mlrl/common/model/head_complete.cpp @@ -1,25 +1,25 @@ #include "mlrl/common/model/head_complete.hpp" -CompleteHead::CompleteHead(uint32 numElements) : scores_(DenseVector(numElements)) {} +CompleteHead::CompleteHead(uint32 numElements) : vector_(DenseVector(numElements)) {} uint32 CompleteHead::getNumElements() const { - return scores_.getNumElements(); + return vector_.getNumElements(); } CompleteHead::score_iterator CompleteHead::scores_begin() { - return scores_.begin(); + return vector_.begin(); } CompleteHead::score_iterator CompleteHead::scores_end() { - return scores_.end(); + return vector_.end(); } CompleteHead::score_const_iterator CompleteHead::scores_cbegin() const { - return scores_.cbegin(); + return vector_.cbegin(); } CompleteHead::score_const_iterator CompleteHead::scores_cend() const { - return scores_.cend(); + return vector_.cend(); } void CompleteHead::visit(CompleteHeadVisitor completeHeadVisitor, PartialHeadVisitor partialHeadVisitor) const { From 4ecabc4bcfecb19fd98fd05c25f25f7ecf1cf2a3 Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 17:13:18 +0200 Subject: [PATCH 10/20] Export class SparseArraysVector. --- .../common/include/mlrl/common/data/vector_sparse_arrays.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_arrays.hpp b/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_arrays.hpp index 787f9b0a5e..3dd456e2e6 100644 --- a/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_arrays.hpp +++ b/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_arrays.hpp @@ -13,7 +13,7 @@ * @tparam T The type of the data that is stored in the vector */ template -class SparseArraysVector final : public IOneDimensionalView { +class MLRLCOMMON_API SparseArraysVector final : public IOneDimensionalView { private: DenseVector indices_; From 9d72ab3add7a01c3169fa49128a9392b2e1c13c3 Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 17:13:59 +0200 Subject: [PATCH 11/20] Edit comment. --- .../common/include/mlrl/common/data/vector_sparse_array.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_array.hpp b/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_array.hpp index ce0d83ec5b..e06502aaa4 100644 --- a/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_array.hpp +++ b/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_array.hpp @@ -10,7 +10,8 @@ /** * An one-dimensional sparse vector that stores a fixed number of elements, consisting of an index and a value, in a - * C-contiguous array. + * C-contiguous array. Such a vector is similar to a `SparseArraysVector`, but uses a single array for storing the + * indices and values. * * @tparam T The type of the data that is stored in the vector */ From 7eb66d6a3a576c664acc3622d6e255776e46e6ac Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 17:15:03 +0200 Subject: [PATCH 12/20] The class SparseArraysVector is not final anymore. --- .../common/include/mlrl/common/data/vector_sparse_arrays.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_arrays.hpp b/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_arrays.hpp index 3dd456e2e6..464ed11cea 100644 --- a/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_arrays.hpp +++ b/cpp/subprojects/common/include/mlrl/common/data/vector_sparse_arrays.hpp @@ -13,7 +13,7 @@ * @tparam T The type of the data that is stored in the vector */ template -class MLRLCOMMON_API SparseArraysVector final : public IOneDimensionalView { +class MLRLCOMMON_API SparseArraysVector : public IOneDimensionalView { private: DenseVector indices_; @@ -27,6 +27,8 @@ class MLRLCOMMON_API SparseArraysVector final : public IOneDimensionalView { */ SparseArraysVector(uint32 numElements); + virtual ~SparseArraysVector() override {}; + /** * An iterator that provides access to the indices in the vector and allows to modify them. */ From c9f171bd7ccd3741f44ade0d9715072f9979e5bd Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 17:20:03 +0200 Subject: [PATCH 13/20] Add class IConditional. --- .../common/include/mlrl/common/model/body.hpp | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/cpp/subprojects/common/include/mlrl/common/model/body.hpp b/cpp/subprojects/common/include/mlrl/common/model/body.hpp index d966eb0b46..05882bf82a 100644 --- a/cpp/subprojects/common/include/mlrl/common/model/body.hpp +++ b/cpp/subprojects/common/include/mlrl/common/model/body.hpp @@ -14,26 +14,15 @@ class EmptyBody; class ConjunctiveBody; /** - * Defines an interface for all classes that represent the body of a rule. + * Defines an interface for all classes that allow to check whether an example is covered or not. */ -class MLRLCOMMON_API IBody { +class MLRLCOMMON_API IConditional { public: - virtual ~IBody() {}; - - /** - * A visitor function for handling objects of the type `EmptyBody`. - */ - typedef std::function EmptyBodyVisitor; - - /** - * A visitor function for handling objects of the type `ConjunctiveBody`. - */ - typedef std::function ConjunctiveBodyVisitor; + virtual ~IConditional() {}; /** - * Returns whether an individual example, which is stored in a C-contiguous matrix, is covered by the body or - * not. + * Returns whether an individual example, which is stored in a C-contiguous matrix, is covered or not. * * @param begin A `VectorConstView::const_iterator` to the beginning of the example's feature values * @param end A `VectorConstView::const_iterator` to the end of the example's feature values @@ -43,7 +32,7 @@ class MLRLCOMMON_API IBody { VectorConstView::const_iterator end) const = 0; /** - * Returns whether an individual example, which is stored in a CSR sparse matrix, is covered by the body or not. + * Returns whether an individual example, which is stored in a CSR sparse matrix, is covered or not. * * @param indicesBegin An iterator to the beginning of the example's feature values * @param indicesEnd An iterator to the end of the example's feature values @@ -64,6 +53,25 @@ class MLRLCOMMON_API IBody { CsrConstView::value_const_iterator valuesBegin, CsrConstView::value_const_iterator valuesEnd, float32* tmpArray1, uint32* tmpArray2, uint32 n) const = 0; +}; + +/** + * Defines an interface for all classes that represent the body of a rule. + */ +class MLRLCOMMON_API IBody : public IConditional { + public: + + virtual ~IBody() override {}; + + /** + * A visitor function for handling objects of the type `EmptyBody`. + */ + typedef std::function EmptyBodyVisitor; + + /** + * A visitor function for handling objects of the type `ConjunctiveBody`. + */ + typedef std::function ConjunctiveBodyVisitor; /** * Invokes one of the given visitor functions, depending on which one is able to handle this particular type of From 42d0e94c5392c51e1533e8967f78e94b5dcc4852 Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 18:27:17 +0200 Subject: [PATCH 14/20] The class ConjunctiveBody now uses SparseArraysVectors. --- .../mlrl/common/model/body_conjunctive.hpp | 131 ++++++++-- .../mlrl/common/model/body_conjunctive.cpp | 241 +++++++----------- 2 files changed, 208 insertions(+), 164 deletions(-) diff --git a/cpp/subprojects/common/include/mlrl/common/model/body_conjunctive.hpp b/cpp/subprojects/common/include/mlrl/common/model/body_conjunctive.hpp index 29b5546172..d0a713c865 100644 --- a/cpp/subprojects/common/include/mlrl/common/model/body_conjunctive.hpp +++ b/cpp/subprojects/common/include/mlrl/common/model/body_conjunctive.hpp @@ -3,6 +3,7 @@ */ #pragma once +#include "mlrl/common/data/vector_sparse_arrays.hpp" #include "mlrl/common/model/body.hpp" /** @@ -12,29 +13,121 @@ class MLRLCOMMON_API ConjunctiveBody final : public IBody { private: - const uint32 numNumericalLeq_; + /** + * A vector that stores conditions of a specific type. + * + * @tparam Threshold The type of the thresholds used by the conditions + * @tparam Compare The type of the comparator that should be used to compare thresholds to feature values + */ + template + class ConditionVector final : public SparseArraysVector, + public IConditional { + private: + + Compare compare_; + + public: + + /** + * @param numConditions The number of conditions + */ + ConditionVector(uint32 numConditions); - uint32* numericalLeqFeatureIndices_; + /** + * @see `IConditional::covers` + */ + bool covers(VectorConstView::const_iterator begin, + VectorConstView::const_iterator end) const override; - float32* numericalLeqThresholds_; + /** + * @see `IConditional::covers` + */ + bool covers(CsrConstView::index_const_iterator indicesBegin, + CsrConstView::index_const_iterator indicesEnd, + CsrConstView::value_const_iterator valuesBegin, + CsrConstView::value_const_iterator valuesEnd, float32* tmpArray1, + uint32* tmpArray2, uint32 n) const override; + }; - const uint32 numNumericalGr_; + /** + * Allows to compare numerical feature values to threshold using the <= operator. + */ + struct CompareNumericalLeq final { + public: - uint32* numericalGrFeatureIndices_; + /** + * Returns whether a given feature value satisfies a specific threshold or not. + * + * @param featureValue The feature value + * @param threshold The threshold + * @return True, if the feature value satisfies the threshold, false otherwise + */ + inline bool operator()(const float32& featureValue, const float32& threshold) const { + return featureValue <= threshold; + } + }; - float32* numericalGrThresholds_; + /** + * Allows to compare numerical feature values to threshold using the > operator. + */ + struct CompareNumericalGr final { + public: - const uint32 numNominalEq_; + /** + * Returns whether a given feature value satisfies a specific threshold or not. + * + * @param featureValue The feature value + * @param threshold The threshold + * @return True, if the feature value satisfies the threshold, false otherwise + */ + inline bool operator()(const float32& featureValue, const float32& threshold) const { + return featureValue > threshold; + } + }; - uint32* nominalEqFeatureIndices_; + /** + * Allows to compare nominal feature values to threshold using the == operator. + */ + struct CompareNominalEq final { + public: - float32* nominalEqThresholds_; + /** + * Returns whether a given feature value satisfies a specific threshold or not. + * + * @param featureValue The feature value + * @param threshold The threshold + * @return True, if the feature value satisfies the threshold, false otherwise + */ + inline bool operator()(const float32& featureValue, const float32& threshold) const { + return featureValue == threshold; + } + }; - const uint32 numNominalNeq_; + /** + * Allows to compare nominal feature values to threshold using the != operator. + */ + struct CompareNominalNeq final { + public: - uint32* nominalNeqFeatureIndices_; + /** + * Returns whether a given feature value satisfies a specific threshold or not. + * + * @param featureValue The feature value + * @param threshold The threshold + * @return True, if the feature value satisfies the threshold, false otherwise + */ + inline bool operator()(const float32& featureValue, const float32& threshold) const { + return featureValue != threshold; + } + }; + + ConditionVector numericalLeqVector_; - float32* nominalNeqThresholds_; + ConditionVector numericalGrVector_; + + ConditionVector nominalEqVector_; + + ConditionVector nominalNeqVector_; public: @@ -46,30 +139,28 @@ class MLRLCOMMON_API ConjunctiveBody final : public IBody { */ ConjunctiveBody(uint32 numNumericalLeq, uint32 numNumericalGr, uint32 numNominalEq, uint32 numNominalNeq); - ~ConjunctiveBody() override; - /** * An iterator that provides access to the thresholds that are used by the conditions in the body and allows to * modify them. */ - typedef float32* threshold_iterator; + typedef SparseArraysVector::value_iterator threshold_iterator; /** * An iterator that provides read-only access to the thresholds that are used by the conditions in the body. */ - typedef const float32* threshold_const_iterator; + typedef SparseArraysVector::value_const_iterator threshold_const_iterator; /** * An iterator that provides access to the feature indices that correspond to the conditions in the body and * allows to modify them. */ - typedef uint32* index_iterator; + typedef SparseArraysVector::index_iterator index_iterator; /** * An iterator that provides read-only access to the feature indices that correspond to the conditions in the * body. */ - typedef const uint32* index_const_iterator; + typedef SparseArraysVector::index_const_iterator index_const_iterator; /** * Returns the number of numerical conditions that use the <= operator. @@ -356,13 +447,13 @@ class MLRLCOMMON_API ConjunctiveBody final : public IBody { index_const_iterator nominal_neq_indices_cend() const; /** - * @see `IBody::covers` + * @see `IConditional::covers` */ bool covers(VectorConstView::const_iterator begin, VectorConstView::const_iterator end) const override; /** - * @see `IBody::covers` + * @see `IConditional::covers` */ bool covers(CsrConstView::index_const_iterator indicesBegin, CsrConstView::index_const_iterator indicesEnd, diff --git a/cpp/subprojects/common/src/mlrl/common/model/body_conjunctive.cpp b/cpp/subprojects/common/src/mlrl/common/model/body_conjunctive.cpp index 4ccab580ec..a8be84a194 100644 --- a/cpp/subprojects/common/src/mlrl/common/model/body_conjunctive.cpp +++ b/cpp/subprojects/common/src/mlrl/common/model/body_conjunctive.cpp @@ -1,212 +1,207 @@ #include "mlrl/common/model/body_conjunctive.hpp" +template +ConjunctiveBody::ConditionVector::ConditionVector(uint32 numConditions) + : SparseArraysVector(numConditions) {} + +template +bool ConjunctiveBody::ConditionVector::covers( + VectorConstView::const_iterator begin, VectorConstView::const_iterator end) const { + uint32 numConditions = this->getNumElements(); + typename SparseArraysVector::index_const_iterator featureIndexIterator = this->indices_cbegin(); + typename SparseArraysVector::value_const_iterator thresholdIterator = this->values_cbegin(); + + for (uint32 i = 0; i < numConditions; i++) { + uint32 featureIndex = featureIndexIterator[i]; + float32 threshold = thresholdIterator[i]; + float32 featureValue = begin[featureIndex]; + + if (!compare_(featureValue, threshold)) { + return false; + } + } + + return true; +} + +template +bool ConjunctiveBody::ConditionVector::covers( + CsrConstView::index_const_iterator indicesBegin, + CsrConstView::index_const_iterator indicesEnd, + CsrConstView::value_const_iterator valuesBegin, + CsrConstView::value_const_iterator valuesEnd, float32* tmpArray1, uint32* tmpArray2, uint32 n) const { + uint32 numConditions = this->getNumElements(); + typename SparseArraysVector::index_const_iterator featureIndexIterator = this->indices_cbegin(); + typename SparseArraysVector::value_const_iterator thresholdIterator = this->values_cbegin(); + + for (uint32 i = 0; i < numConditions; i++) { + uint32 featureIndex = featureIndexIterator[i]; + float32 threshold = thresholdIterator[i]; + float32 featureValue = tmpArray2[featureIndex] == n ? tmpArray1[featureIndex] : 0; + + if (!compare_(featureValue, threshold)) { + return false; + } + } + + return true; +} + ConjunctiveBody::ConjunctiveBody(uint32 numNumericalLeq, uint32 numNumericalGr, uint32 numNominalEq, uint32 numNominalNeq) - : numNumericalLeq_(numNumericalLeq), numericalLeqFeatureIndices_(new uint32[numNumericalLeq_]), - numericalLeqThresholds_(new float32[numNumericalLeq_]), numNumericalGr_(numNumericalGr), - numericalGrFeatureIndices_(new uint32[numNumericalGr_]), numericalGrThresholds_(new float32[numNumericalGr_]), - numNominalEq_(numNominalEq), nominalEqFeatureIndices_(new uint32[numNominalEq_]), - nominalEqThresholds_(new float32[numNominalEq_]), numNominalNeq_(numNominalNeq), - nominalNeqFeatureIndices_(new uint32[numNominalNeq_]), nominalNeqThresholds_(new float32[numNominalNeq_]) {} - -ConjunctiveBody::~ConjunctiveBody() { - delete[] numericalLeqFeatureIndices_; - delete[] numericalLeqThresholds_; - delete[] numericalGrFeatureIndices_; - delete[] numericalGrThresholds_; - delete[] nominalEqFeatureIndices_; - delete[] nominalEqThresholds_; - delete[] nominalNeqFeatureIndices_; - delete[] nominalNeqThresholds_; -} + : numericalLeqVector_(ConditionVector(numNumericalLeq)), + numericalGrVector_(ConditionVector(numNumericalGr)), + nominalEqVector_(ConditionVector(numNominalEq)), + nominalNeqVector_(ConditionVector(numNominalNeq)) {} uint32 ConjunctiveBody::getNumNumericalLeq() const { - return numNumericalLeq_; + return numericalLeqVector_.getNumElements(); } ConjunctiveBody::threshold_iterator ConjunctiveBody::numerical_leq_thresholds_begin() { - return numericalLeqThresholds_; + return numericalLeqVector_.values_begin(); } ConjunctiveBody::threshold_iterator ConjunctiveBody::numerical_leq_thresholds_end() { - return &numericalLeqThresholds_[numNumericalLeq_]; + return numericalLeqVector_.values_end(); } ConjunctiveBody::threshold_const_iterator ConjunctiveBody::numerical_leq_thresholds_cbegin() const { - return numericalLeqThresholds_; + return numericalLeqVector_.values_cbegin(); } ConjunctiveBody::threshold_const_iterator ConjunctiveBody::numerical_leq_thresholds_cend() const { - return &numericalLeqThresholds_[numNumericalLeq_]; + return numericalLeqVector_.values_cend(); } ConjunctiveBody::index_iterator ConjunctiveBody::numerical_leq_indices_begin() { - return numericalLeqFeatureIndices_; + return numericalLeqVector_.indices_begin(); } ConjunctiveBody::index_iterator ConjunctiveBody::numerical_leq_indices_end() { - return &numericalLeqFeatureIndices_[numNumericalLeq_]; + return numericalLeqVector_.indices_end(); } ConjunctiveBody::index_const_iterator ConjunctiveBody::numerical_leq_indices_cbegin() const { - return numericalLeqFeatureIndices_; + return numericalLeqVector_.indices_cbegin(); } ConjunctiveBody::index_const_iterator ConjunctiveBody::numerical_leq_indices_cend() const { - return &numericalLeqFeatureIndices_[numNumericalLeq_]; + return numericalLeqVector_.indices_cend(); } uint32 ConjunctiveBody::getNumNumericalGr() const { - return numNumericalGr_; + return numericalGrVector_.getNumElements(); } ConjunctiveBody::threshold_iterator ConjunctiveBody::numerical_gr_thresholds_begin() { - return numericalGrThresholds_; + return numericalGrVector_.values_begin(); } ConjunctiveBody::threshold_iterator ConjunctiveBody::numerical_gr_thresholds_end() { - return &numericalGrThresholds_[numNumericalLeq_]; + return numericalGrVector_.values_end(); } ConjunctiveBody::threshold_const_iterator ConjunctiveBody::numerical_gr_thresholds_cbegin() const { - return numericalGrThresholds_; + return numericalGrVector_.values_cbegin(); } ConjunctiveBody::threshold_const_iterator ConjunctiveBody::numerical_gr_thresholds_cend() const { - return &numericalGrThresholds_[numNumericalLeq_]; + return numericalGrVector_.values_cend(); } ConjunctiveBody::index_iterator ConjunctiveBody::numerical_gr_indices_begin() { - return numericalGrFeatureIndices_; + return numericalGrVector_.indices_begin(); } ConjunctiveBody::index_iterator ConjunctiveBody::numerical_gr_indices_end() { - return &numericalGrFeatureIndices_[numNumericalLeq_]; + return numericalGrVector_.indices_end(); } ConjunctiveBody::index_const_iterator ConjunctiveBody::numerical_gr_indices_cbegin() const { - return numericalGrFeatureIndices_; + return numericalGrVector_.indices_cbegin(); } ConjunctiveBody::index_const_iterator ConjunctiveBody::numerical_gr_indices_cend() const { - return &numericalGrFeatureIndices_[numNumericalLeq_]; + return numericalGrVector_.indices_cend(); } uint32 ConjunctiveBody::getNumNominalEq() const { - return numNominalEq_; + return nominalEqVector_.getNumElements(); } ConjunctiveBody::threshold_iterator ConjunctiveBody::nominal_eq_thresholds_begin() { - return nominalEqThresholds_; + return nominalEqVector_.values_begin(); } ConjunctiveBody::threshold_iterator ConjunctiveBody::nominal_eq_thresholds_end() { - return &nominalEqThresholds_[numNominalEq_]; + return nominalEqVector_.values_end(); } ConjunctiveBody::threshold_const_iterator ConjunctiveBody::nominal_eq_thresholds_cbegin() const { - return nominalEqThresholds_; + return nominalEqVector_.values_cbegin(); } ConjunctiveBody::threshold_const_iterator ConjunctiveBody::nominal_eq_thresholds_cend() const { - return &nominalEqThresholds_[numNominalEq_]; + return nominalEqVector_.values_cend(); } ConjunctiveBody::index_iterator ConjunctiveBody::nominal_eq_indices_begin() { - return nominalEqFeatureIndices_; + return nominalEqVector_.indices_begin(); } ConjunctiveBody::index_iterator ConjunctiveBody::nominal_eq_indices_end() { - return &nominalEqFeatureIndices_[numNominalEq_]; + return nominalEqVector_.indices_end(); } ConjunctiveBody::index_const_iterator ConjunctiveBody::nominal_eq_indices_cbegin() const { - return nominalEqFeatureIndices_; + return nominalEqVector_.indices_cbegin(); } ConjunctiveBody::index_const_iterator ConjunctiveBody::nominal_eq_indices_cend() const { - return &nominalEqFeatureIndices_[numNominalEq_]; + return nominalEqVector_.indices_cend(); } uint32 ConjunctiveBody::getNumNominalNeq() const { - return numNominalNeq_; + return nominalNeqVector_.getNumElements(); } ConjunctiveBody::threshold_iterator ConjunctiveBody::nominal_neq_thresholds_begin() { - return nominalNeqThresholds_; + return nominalNeqVector_.values_begin(); } ConjunctiveBody::threshold_iterator ConjunctiveBody::nominal_neq_thresholds_end() { - return &nominalNeqThresholds_[numNominalNeq_]; + return nominalNeqVector_.values_end(); } ConjunctiveBody::threshold_const_iterator ConjunctiveBody::nominal_neq_thresholds_cbegin() const { - return nominalNeqThresholds_; + return nominalNeqVector_.values_cbegin(); } ConjunctiveBody::threshold_const_iterator ConjunctiveBody::nominal_neq_thresholds_cend() const { - return &nominalNeqThresholds_[numNominalNeq_]; + return nominalNeqVector_.values_cend(); } ConjunctiveBody::index_iterator ConjunctiveBody::nominal_neq_indices_begin() { - return nominalNeqFeatureIndices_; + return nominalNeqVector_.indices_begin(); } ConjunctiveBody::index_iterator ConjunctiveBody::nominal_neq_indices_end() { - return &nominalNeqFeatureIndices_[numNominalNeq_]; + return nominalNeqVector_.indices_end(); } ConjunctiveBody::index_const_iterator ConjunctiveBody::nominal_neq_indices_cbegin() const { - return nominalNeqFeatureIndices_; + return nominalNeqVector_.indices_cbegin(); } ConjunctiveBody::index_const_iterator ConjunctiveBody::nominal_neq_indices_cend() const { - return &nominalNeqFeatureIndices_[numNominalNeq_]; + return nominalNeqVector_.indices_cend(); } bool ConjunctiveBody::covers(VectorConstView::const_iterator begin, VectorConstView::const_iterator end) const { - // Test numerical conditions using the <= operator... - for (uint32 i = 0; i < numNumericalLeq_; i++) { - uint32 featureIndex = numericalLeqFeatureIndices_[i]; - float32 threshold = numericalLeqThresholds_[i]; - - if (begin[featureIndex] > threshold) { - return false; - } - } - - // Test numerical conditions using the > operator... - for (uint32 i = 0; i < numNumericalGr_; i++) { - uint32 featureIndex = numericalGrFeatureIndices_[i]; - float32 threshold = numericalGrThresholds_[i]; - - if (begin[featureIndex] <= threshold) { - return false; - } - } - - // Test nominal conditions using the == operator... - for (uint32 i = 0; i < numNominalEq_; i++) { - uint32 featureIndex = nominalEqFeatureIndices_[i]; - float32 threshold = nominalEqThresholds_[i]; - - if (begin[featureIndex] != threshold) { - return false; - } - } - - // Test nominal conditions using the != operator... - for (uint32 i = 0; i < numNominalNeq_; i++) { - uint32 featureIndex = nominalNeqFeatureIndices_[i]; - float32 threshold = nominalNeqThresholds_[i]; - - if (begin[featureIndex] == threshold) { - return false; - } - } - - return true; + return numericalLeqVector_.covers(begin, end) && numericalGrVector_.covers(begin, end) + && nominalEqVector_.covers(begin, end) && nominalNeqVector_.covers(begin, end); } bool ConjunctiveBody::covers(CsrConstView::index_const_iterator indicesBegin, @@ -215,61 +210,19 @@ bool ConjunctiveBody::covers(CsrConstView::index_const_iterator i CsrConstView::value_const_iterator valuesEnd, float32* tmpArray1, uint32* tmpArray2, uint32 n) const { // Copy non-zero feature values to the temporary arrays... - auto valueIterator = valuesBegin; + uint32 numNonZeroFeatureValues = valuesEnd - valuesBegin; - for (auto indexIterator = indicesBegin; indexIterator != indicesEnd; indexIterator++) { - uint32 featureIndex = *indexIterator; - float32 featureValue = *valueIterator; + for (uint32 i = 0; i < numNonZeroFeatureValues; i++) { + uint32 featureIndex = indicesBegin[i]; + float32 featureValue = valuesBegin[i]; tmpArray1[featureIndex] = featureValue; tmpArray2[featureIndex] = n; - valueIterator++; - } - - // Test numerical conditions using the <= operator... - for (uint32 i = 0; i < numNumericalLeq_; i++) { - uint32 featureIndex = numericalLeqFeatureIndices_[i]; - float32 threshold = numericalLeqThresholds_[i]; - float32 featureValue = tmpArray2[featureIndex] == n ? tmpArray1[featureIndex] : 0; - - if (featureValue > threshold) { - return false; - } - } - - // Test numerical conditions using the > operator... - for (uint32 i = 0; i < numNumericalGr_; i++) { - uint32 featureIndex = numericalGrFeatureIndices_[i]; - float32 threshold = numericalGrThresholds_[i]; - float32 featureValue = tmpArray2[featureIndex] == n ? tmpArray1[featureIndex] : 0; - - if (featureValue <= threshold) { - return false; - } - } - - // Test nominal conditions using the == operator... - for (uint32 i = 0; i < numNominalEq_; i++) { - uint32 featureIndex = nominalEqFeatureIndices_[i]; - float32 threshold = nominalEqThresholds_[i]; - float32 featureValue = tmpArray2[featureIndex] == n ? tmpArray1[featureIndex] : 0; - - if (featureValue != threshold) { - return false; - } - } - - // Test nominal conditions using the != operator... - for (uint32 i = 0; i < numNominalNeq_; i++) { - uint32 featureIndex = nominalNeqFeatureIndices_[i]; - float32 threshold = nominalNeqThresholds_[i]; - float32 featureValue = tmpArray2[featureIndex] == n ? tmpArray1[featureIndex] : 0; - - if (featureValue == threshold) { - return false; - } } - return true; + return numericalLeqVector_.covers(indicesBegin, indicesEnd, valuesBegin, valuesEnd, tmpArray1, tmpArray2, n) + && numericalGrVector_.covers(indicesBegin, indicesEnd, valuesBegin, valuesEnd, tmpArray1, tmpArray2, n) + && nominalEqVector_.covers(indicesBegin, indicesEnd, valuesBegin, valuesEnd, tmpArray1, tmpArray2, n) + && nominalNeqVector_.covers(indicesBegin, indicesEnd, valuesBegin, valuesEnd, tmpArray1, tmpArray2, n); } void ConjunctiveBody::visit(EmptyBodyVisitor emptyBodyVisitor, ConjunctiveBodyVisitor conjunctiveBodyVisitor) const { From 0e10c4d79284c87f0bf92b1899ae7419356ac17a Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 19:18:52 +0200 Subject: [PATCH 15/20] The class ConjunctiveBody now stores ordinal conditions separately. --- .../mlrl/common/model/body_conjunctive.hpp | 187 +++++++++++++++++- .../include/mlrl/common/model/condition.hpp | 6 +- .../mlrl/common/model/condition_list.hpp | 2 +- .../mlrl/common/model/body_conjunctive.cpp | 81 +++++++- .../src/mlrl/common/model/condition_list.cpp | 20 +- .../common/mlrl/common/cython/rule_model.pxd | 28 +++ .../common/mlrl/common/cython/rule_model.pyx | 78 +++++++- 7 files changed, 386 insertions(+), 16 deletions(-) diff --git a/cpp/subprojects/common/include/mlrl/common/model/body_conjunctive.hpp b/cpp/subprojects/common/include/mlrl/common/model/body_conjunctive.hpp index d0a713c865..5ce3924a96 100644 --- a/cpp/subprojects/common/include/mlrl/common/model/body_conjunctive.hpp +++ b/cpp/subprojects/common/include/mlrl/common/model/body_conjunctive.hpp @@ -85,6 +85,42 @@ class MLRLCOMMON_API ConjunctiveBody final : public IBody { } }; + /** + * Allows to compare ordinal feature values to threshold using the <= operator. + */ + struct CompareOrdinalLeq final { + public: + + /** + * Returns whether a given feature value satisfies a specific threshold or not. + * + * @param featureValue The feature value + * @param threshold The threshold + * @return True, if the feature value satisfies the threshold, false otherwise + */ + inline bool operator()(const float32& featureValue, const float32& threshold) const { + return featureValue <= threshold; + } + }; + + /** + * Allows to compare ordinal feature values to threshold using the > operator. + */ + struct CompareOrdinalGr final { + public: + + /** + * Returns whether a given feature value satisfies a specific threshold or not. + * + * @param featureValue The feature value + * @param threshold The threshold + * @return True, if the feature value satisfies the threshold, false otherwise + */ + inline bool operator()(const float32& featureValue, const float32& threshold) const { + return featureValue > threshold; + } + }; + /** * Allows to compare nominal feature values to threshold using the == operator. */ @@ -125,6 +161,10 @@ class MLRLCOMMON_API ConjunctiveBody final : public IBody { ConditionVector numericalGrVector_; + ConditionVector ordinalLeqVector_; + + ConditionVector ordinalGrVector_; + ConditionVector nominalEqVector_; ConditionVector nominalNeqVector_; @@ -134,10 +174,13 @@ class MLRLCOMMON_API ConjunctiveBody final : public IBody { /** * @param numNumericalLeq The number of numerical conditions that use the <= operator * @param numNumericalGr The number of numerical conditions that use the > operator + * @param numOrdinalLeq The number of ordinal conditions that use the <= operator + * @param numOrdinalGr The number of ordinal conditions that use the > operator * @param numNominalEq The number of nominal conditions that use the == operator * @param numNominalNeq The number of nominal conditions that use the != operator */ - ConjunctiveBody(uint32 numNumericalLeq, uint32 numNumericalGr, uint32 numNominalEq, uint32 numNominalNeq); + ConjunctiveBody(uint32 numNumericalLeq, uint32 numNumericalGr, uint32 numOrdinalLeq, uint32 numOrdinalGr, + uint32 numNominalEq, uint32 numNominalNeq); /** * An iterator that provides access to the thresholds that are used by the conditions in the body and allows to @@ -304,6 +347,148 @@ class MLRLCOMMON_API ConjunctiveBody final : public IBody { */ index_const_iterator numerical_gr_indices_cend() const; + /** + * Returns the number of ordinal conditions that use the <= operator. + * + * @return The number of conditions + */ + uint32 getNumOrdinalLeq() const; + + /** + * Returns a `threshold_iterator` to the beginning of the thresholds that correspond to ordinal conditions that + * use the <= operator. + * + * @return A `threshold_iterator` to the beginning + */ + threshold_iterator ordinal_leq_thresholds_begin(); + + /** + * Returns a `threshold_iterator` to the end of the thresholds that correspond to ordinal conditions that use + * the <= operator. + * + * @return A `threshold_iterator` to the end + */ + threshold_iterator ordinal_leq_thresholds_end(); + + /** + * Returns a `threshold_const_iterator` to the beginning of the thresholds that correspond to ordinal conditions + * that use the <= operator. + * + * @return A `threshold_const_iterator` to the beginning + */ + threshold_const_iterator ordinal_leq_thresholds_cbegin() const; + + /** + * Returns a `threshold_const_iterator` to the end of the thresholds that correspond to ordinal conditions that + * use the <= operator. + * + * @return A `threshold_const_iterator` to the end + */ + threshold_const_iterator ordinal_leq_thresholds_cend() const; + + /** + * Returns an `index_iterator` to the beginning of the feature indices that correspond to ordinal conditions + * that use the <= operator. + * + * @return An `index_iterator` to the beginning + */ + index_iterator ordinal_leq_indices_begin(); + + /** + * Returns an `index_iterator` to the end of the feature indices that correspond to ordinal conditions that use + * the <= operator. + * + * @return An `index_iterator` to the end + */ + index_iterator ordinal_leq_indices_end(); + + /** + * Returns an `index_const_iterator` to the beginning of the feature indices that correspond to ordinal + * conditions that use the <= operator. + * + * @return An `index_const_iterator` to the beginning + */ + index_const_iterator ordinal_leq_indices_cbegin() const; + + /** + * Returns an `index_const_iterator` to the end of the feature indices that correspond to ordinal conditions + * that use the <= operator. + * + * @return An `index_const_iterator` to the end + */ + index_const_iterator ordinal_leq_indices_cend() const; + + /** + * Returns the number of ordinal conditions that use the > operator. + * + * @return The number of conditions + */ + uint32 getNumOrdinalGr() const; + + /** + * Returns a `threshold_iterator` to the beginning of the thresholds that correspond to ordinal conditions that + * use the > operator. + * + * @return A `threshold_iterator` to the beginning + */ + threshold_iterator ordinal_gr_thresholds_begin(); + + /** + * Returns a `threshold_iterator` to the end of the thresholds that correspond to ordinal conditions that use + * the > operator. + * + * @return A `threshold_iterator` to the end + */ + threshold_iterator ordinal_gr_thresholds_end(); + + /** + * Returns a `threshold_const_iterator` to the beginning of the thresholds that correspond to ordinal conditions + * that use the > operator. + * + * @return A `threshold_const_iterator` to the beginning + */ + threshold_const_iterator ordinal_gr_thresholds_cbegin() const; + + /** + * Returns a `threshold_const_iterator` to the end of the thresholds that correspond to ordinal conditions that + * use the > operator. + * + * @return A `threshold_const_iterator` to the end + */ + threshold_const_iterator ordinal_gr_thresholds_cend() const; + + /** + * Returns an `index_iterator` to the beginning of the feature indices that correspond to ordinal conditions + * that use the > operator. + * + * @return An `index_iterator` to the beginning + */ + index_iterator ordinal_gr_indices_begin(); + + /** + * Returns an `index_iterator` to the end of the feature indices that correspond to ordinal conditions that use + * the > operator. + * + * @return An `index_iterator` to the end + */ + index_iterator ordinal_gr_indices_end(); + + /** + * Returns an `index_const_iterator` to the beginning of the feature indices that correspond to ordinal + * conditions that use the > operator. + * + * @return An `index_const_iterator` to the beginning + */ + index_const_iterator ordinal_gr_indices_cbegin() const; + + /** + * Returns an `index_const_iterator` to the end of the feature indices that correspond to ordinal conditions + * that use the > operator. + * + * @return An `index_const_iterator` to the end + */ + index_const_iterator ordinal_gr_indices_cend() const; + /** * Returns the number of nominal conditions that use the == operator. * diff --git a/cpp/subprojects/common/include/mlrl/common/model/condition.hpp b/cpp/subprojects/common/include/mlrl/common/model/condition.hpp index 35a0b2034e..16a3923c2e 100644 --- a/cpp/subprojects/common/include/mlrl/common/model/condition.hpp +++ b/cpp/subprojects/common/include/mlrl/common/model/condition.hpp @@ -11,8 +11,10 @@ enum Comparator : uint8 { NUMERICAL_LEQ = 0, NUMERICAL_GR = 1, - NOMINAL_EQ = 2, - NOMINAL_NEQ = 3 + ORDINAL_LEQ = 2, + ORDINAL_GR = 3, + NOMINAL_EQ = 4, + NOMINAL_NEQ = 5 }; /** diff --git a/cpp/subprojects/common/include/mlrl/common/model/condition_list.hpp b/cpp/subprojects/common/include/mlrl/common/model/condition_list.hpp index e8ad6dd093..25e62f4b82 100644 --- a/cpp/subprojects/common/include/mlrl/common/model/condition_list.hpp +++ b/cpp/subprojects/common/include/mlrl/common/model/condition_list.hpp @@ -18,7 +18,7 @@ class ConditionList final { std::vector vector_; - std::array numConditionsPerComparator_; + std::array numConditionsPerComparator_; public: diff --git a/cpp/subprojects/common/src/mlrl/common/model/body_conjunctive.cpp b/cpp/subprojects/common/src/mlrl/common/model/body_conjunctive.cpp index a8be84a194..53feab29ed 100644 --- a/cpp/subprojects/common/src/mlrl/common/model/body_conjunctive.cpp +++ b/cpp/subprojects/common/src/mlrl/common/model/body_conjunctive.cpp @@ -47,10 +47,12 @@ bool ConjunctiveBody::ConditionVector::covers( return true; } -ConjunctiveBody::ConjunctiveBody(uint32 numNumericalLeq, uint32 numNumericalGr, uint32 numNominalEq, - uint32 numNominalNeq) +ConjunctiveBody::ConjunctiveBody(uint32 numNumericalLeq, uint32 numNumericalGr, uint32 numOrdinalLeq, + uint32 numOrdinalGr, uint32 numNominalEq, uint32 numNominalNeq) : numericalLeqVector_(ConditionVector(numNumericalLeq)), numericalGrVector_(ConditionVector(numNumericalGr)), + ordinalLeqVector_(ConditionVector(numOrdinalLeq)), + ordinalGrVector_(ConditionVector(numOrdinalGr)), nominalEqVector_(ConditionVector(numNominalEq)), nominalNeqVector_(ConditionVector(numNominalNeq)) {} @@ -126,6 +128,78 @@ ConjunctiveBody::index_const_iterator ConjunctiveBody::numerical_gr_indices_cend return numericalGrVector_.indices_cend(); } +uint32 ConjunctiveBody::getNumOrdinalLeq() const { + return ordinalLeqVector_.getNumElements(); +} + +ConjunctiveBody::threshold_iterator ConjunctiveBody::ordinal_leq_thresholds_begin() { + return ordinalLeqVector_.values_begin(); +} + +ConjunctiveBody::threshold_iterator ConjunctiveBody::ordinal_leq_thresholds_end() { + return ordinalLeqVector_.values_end(); +} + +ConjunctiveBody::threshold_const_iterator ConjunctiveBody::ordinal_leq_thresholds_cbegin() const { + return ordinalLeqVector_.values_cbegin(); +} + +ConjunctiveBody::threshold_const_iterator ConjunctiveBody::ordinal_leq_thresholds_cend() const { + return ordinalLeqVector_.values_cend(); +} + +ConjunctiveBody::index_iterator ConjunctiveBody::ordinal_leq_indices_begin() { + return ordinalLeqVector_.indices_begin(); +} + +ConjunctiveBody::index_iterator ConjunctiveBody::ordinal_leq_indices_end() { + return ordinalLeqVector_.indices_end(); +} + +ConjunctiveBody::index_const_iterator ConjunctiveBody::ordinal_leq_indices_cbegin() const { + return ordinalLeqVector_.indices_cbegin(); +} + +ConjunctiveBody::index_const_iterator ConjunctiveBody::ordinal_leq_indices_cend() const { + return ordinalLeqVector_.indices_cend(); +} + +uint32 ConjunctiveBody::getNumOrdinalGr() const { + return ordinalGrVector_.getNumElements(); +} + +ConjunctiveBody::threshold_iterator ConjunctiveBody::ordinal_gr_thresholds_begin() { + return ordinalGrVector_.values_begin(); +} + +ConjunctiveBody::threshold_iterator ConjunctiveBody::ordinal_gr_thresholds_end() { + return ordinalGrVector_.values_end(); +} + +ConjunctiveBody::threshold_const_iterator ConjunctiveBody::ordinal_gr_thresholds_cbegin() const { + return ordinalGrVector_.values_cbegin(); +} + +ConjunctiveBody::threshold_const_iterator ConjunctiveBody::ordinal_gr_thresholds_cend() const { + return ordinalGrVector_.values_cend(); +} + +ConjunctiveBody::index_iterator ConjunctiveBody::ordinal_gr_indices_begin() { + return ordinalGrVector_.indices_begin(); +} + +ConjunctiveBody::index_iterator ConjunctiveBody::ordinal_gr_indices_end() { + return ordinalGrVector_.indices_end(); +} + +ConjunctiveBody::index_const_iterator ConjunctiveBody::ordinal_gr_indices_cbegin() const { + return ordinalGrVector_.indices_cbegin(); +} + +ConjunctiveBody::index_const_iterator ConjunctiveBody::ordinal_gr_indices_cend() const { + return ordinalGrVector_.indices_cend(); +} + uint32 ConjunctiveBody::getNumNominalEq() const { return nominalEqVector_.getNumElements(); } @@ -201,6 +275,7 @@ ConjunctiveBody::index_const_iterator ConjunctiveBody::nominal_neq_indices_cend( bool ConjunctiveBody::covers(VectorConstView::const_iterator begin, VectorConstView::const_iterator end) const { return numericalLeqVector_.covers(begin, end) && numericalGrVector_.covers(begin, end) + && ordinalLeqVector_.covers(begin, end) && ordinalGrVector_.covers(begin, end) && nominalEqVector_.covers(begin, end) && nominalNeqVector_.covers(begin, end); } @@ -221,6 +296,8 @@ bool ConjunctiveBody::covers(CsrConstView::index_const_iterator i return numericalLeqVector_.covers(indicesBegin, indicesEnd, valuesBegin, valuesEnd, tmpArray1, tmpArray2, n) && numericalGrVector_.covers(indicesBegin, indicesEnd, valuesBegin, valuesEnd, tmpArray1, tmpArray2, n) + && ordinalLeqVector_.covers(indicesBegin, indicesEnd, valuesBegin, valuesEnd, tmpArray1, tmpArray2, n) + && ordinalGrVector_.covers(indicesBegin, indicesEnd, valuesBegin, valuesEnd, tmpArray1, tmpArray2, n) && nominalEqVector_.covers(indicesBegin, indicesEnd, valuesBegin, valuesEnd, tmpArray1, tmpArray2, n) && nominalNeqVector_.covers(indicesBegin, indicesEnd, valuesBegin, valuesEnd, tmpArray1, tmpArray2, n); } diff --git a/cpp/subprojects/common/src/mlrl/common/model/condition_list.cpp b/cpp/subprojects/common/src/mlrl/common/model/condition_list.cpp index 62c2be747c..2d358b5439 100644 --- a/cpp/subprojects/common/src/mlrl/common/model/condition_list.cpp +++ b/cpp/subprojects/common/src/mlrl/common/model/condition_list.cpp @@ -1,12 +1,13 @@ #include "mlrl/common/model/condition_list.hpp" -ConditionList::ConditionList() : numConditionsPerComparator_({0, 0, 0, 0}) {} +ConditionList::ConditionList() : numConditionsPerComparator_({0, 0, 0, 0, 0, 0}) {} ConditionList::ConditionList(const ConditionList& conditionList) : vector_(conditionList.vector_), numConditionsPerComparator_( {conditionList.numConditionsPerComparator_[0], conditionList.numConditionsPerComparator_[1], - conditionList.numConditionsPerComparator_[2], conditionList.numConditionsPerComparator_[3]}) {} + conditionList.numConditionsPerComparator_[2], conditionList.numConditionsPerComparator_[3], + conditionList.numConditionsPerComparator_[4], conditionList.numConditionsPerComparator_[4]}) {} ConditionList::const_iterator ConditionList::cbegin() const { return vector_.cbegin(); @@ -34,9 +35,12 @@ void ConditionList::removeLastCondition() { std::unique_ptr ConditionList::createConjunctiveBody() const { std::unique_ptr bodyPtr = std::make_unique( numConditionsPerComparator_[NUMERICAL_LEQ], numConditionsPerComparator_[NUMERICAL_GR], + numConditionsPerComparator_[ORDINAL_LEQ], numConditionsPerComparator_[ORDINAL_GR], numConditionsPerComparator_[NOMINAL_EQ], numConditionsPerComparator_[NOMINAL_NEQ]); uint32 numericalLeqIndex = 0; uint32 numericalGrIndex = 0; + uint32 ordinalLeqIndex = 0; + uint32 ordinalGrIndex = 0; uint32 nominalEqIndex = 0; uint32 nominalNeqIndex = 0; @@ -58,6 +62,18 @@ std::unique_ptr ConditionList::createConjunctiveBody() const { numericalGrIndex++; break; } + case ORDINAL_LEQ: { + bodyPtr->ordinal_leq_indices_begin()[ordinalLeqIndex] = featureIndex; + bodyPtr->ordinal_leq_thresholds_begin()[ordinalLeqIndex] = threshold; + ordinalLeqIndex++; + break; + } + case ORDINAL_GR: { + bodyPtr->ordinal_gr_indices_begin()[ordinalGrIndex] = featureIndex; + bodyPtr->ordinal_gr_thresholds_begin()[ordinalGrIndex] = threshold; + ordinalGrIndex++; + break; + } case NOMINAL_EQ: { bodyPtr->nominal_eq_indices_begin()[nominalEqIndex] = featureIndex; bodyPtr->nominal_eq_thresholds_begin()[nominalEqIndex] = threshold; diff --git a/python/subprojects/common/mlrl/common/cython/rule_model.pxd b/python/subprojects/common/mlrl/common/cython/rule_model.pxd index a27f69b6fd..9c3fc6f251 100644 --- a/python/subprojects/common/mlrl/common/cython/rule_model.pxd +++ b/python/subprojects/common/mlrl/common/cython/rule_model.pxd @@ -57,6 +57,26 @@ cdef extern from "mlrl/common/model/body_conjunctive.hpp" nogil: index_const_iterator numerical_gr_indices_cbegin() const + uint32 getNumOrdinalLeq() const + + threshold_iterator ordinal_leq_thresholds_begin() + + threshold_const_iterator ordinal_leq_thresholds_cbegin() const + + index_iterator ordinal_leq_indices_begin() + + index_const_iterator ordinal_leq_indices_cbegin() const + + uint32 getNumOrdinalGr() const + + threshold_iterator ordinal_gr_thresholds_begin() + + threshold_const_iterator ordinal_gr_thresholds_cbegin() const + + index_iterator ordinal_gr_indices_begin() + + index_const_iterator ordinal_gr_indices_cbegin() const + uint32 getNumNominalEq() const threshold_iterator nominal_eq_thresholds_begin() @@ -248,6 +268,14 @@ cdef class ConjunctiveBody: cdef readonly npc.ndarray numerical_gr_thresholds + cdef readonly npc.ndarray ordinal_leq_indices + + cdef readonly npc.ndarray ordinal_leq_thresholds + + cdef readonly npc.ndarray ordinal_gr_indices + + cdef readonly npc.ndarray ordinal_gr_thresholds + cdef readonly npc.ndarray nominal_eq_indices cdef readonly npc.ndarray nominal_eq_thresholds diff --git a/python/subprojects/common/mlrl/common/cython/rule_model.pyx b/python/subprojects/common/mlrl/common/cython/rule_model.pyx index 937c5c5c5f..c6526e8f07 100644 --- a/python/subprojects/common/mlrl/common/cython/rule_model.pyx +++ b/python/subprojects/common/mlrl/common/cython/rule_model.pyx @@ -8,7 +8,7 @@ from abc import abstractmethod import numpy as np -SERIALIZATION_VERSION = 3 +SERIALIZATION_VERSION = 4 cdef class EmptyBody: @@ -25,6 +25,8 @@ cdef class ConjunctiveBody: def __cinit__(self, const uint32[::1] numerical_leq_indices, const float32[::1] numerical_leq_thresholds, const uint32[::1] numerical_gr_indices, const float32[::1] numerical_gr_thresholds, + const uint32[::1] ordinal_leq_indices, const float32[::1] ordinal_leq_thresholds, + const uint32[::1] ordinal_gr_indices, const float32[::1] ordinal_gr_thresholds, const uint32[::1] nominal_eq_indices, const float32[::1] nominal_eq_thresholds, const uint32[::1] nominal_neq_indices, const float32[::1] nominal_neq_thresholds): """ @@ -40,6 +42,18 @@ cdef class ConjunctiveBody: :param numerical_gr_thresholds: A contiguous array of type `float32`, shape `(num_numerical_gr_conditions)` that stores the thresholds of the numerical conditions that use the > operator or None, if no such conditions are available + :param ordinal_leq_indices: A contiguous array of type `uint32`, shape `(num_ordinal_leq_conditions)`, + that stores the feature indices of the oridnal conditions that use the <= + operator or None, if no such conditions are available + :param ordinal_leq_thresholds: A contiguous array of type `float32`, shape `(num_ordinal_leq_conditions)` + that stores the thresholds of the ordinal conditions that use the <= + operator or None, if no such conditions are available + :param ordinal_gr_indices: A contiguous array of type `uint32`, shape `(num_ordinal_gr_conditions)`, + that stores the feature indices of the ordinal conditions that use the > + operator or None, if no such conditions are available + :param ordinal_gr_thresholds: A contiguous array of type `float32`, shape `(num_ordinal_gr_conditions)` + that stores the thresholds of the ordinal conditions that use the > operator + or None, if no such conditions are available :param nominal_eq_indices: A contiguous array of type `uint32`, shape `(num_nominal_eq_conditions)`, that stores the feature indices of the nominal conditions that use the == operator or None, if no such conditions are available @@ -59,6 +73,10 @@ cdef class ConjunctiveBody: self.numerical_gr_indices = np.asarray(numerical_gr_indices) if numerical_gr_indices is not None else None self.numerical_gr_thresholds = \ np.asarray(numerical_gr_thresholds) if numerical_gr_thresholds is not None else None + self.ordinal_leq_indices = np.asarray(ordinal_leq_indices) if ordinal_leq_indices is not None else None + self.ordinal_leq_thresholds = np.asarray(ordinal_leq_thresholds) if ordinal_leq_thresholds is not None else None + self.ordinal_gr_indices = np.asarray(ordinal_gr_indices) if ordinal_gr_indices is not None else None + self.ordinal_gr_thresholds = np.asarray(ordinal_gr_thresholds) if ordinal_gr_thresholds is not None else None self.nominal_eq_indices = np.asarray(nominal_eq_indices) if nominal_eq_indices is not None else None self.nominal_eq_thresholds = np.asarray(nominal_eq_thresholds) if nominal_eq_thresholds is not None else None self.nominal_neq_indices = np.asarray(nominal_neq_indices) if nominal_neq_indices is not None else None @@ -215,6 +233,18 @@ cdef class RuleList(RuleModel): cdef const float32[::1] numerical_gr_thresholds = \ body.numerical_gr_thresholds_cbegin() if num_numerical_gr > 0 else None + cdef uint32 num_ordinal_leq = body.getNumOrdinalLeq() + cdef const uint32[::1] ordinal_leq_indices = \ + body.ordinal_leq_indices_cbegin() if num_ordinal_leq > 0 else None + cdef const float32[::1] ordinal_leq_thresholds = \ + body.ordinal_leq_thresholds_cbegin() if num_ordinal_leq > 0 else None + + cdef uint32 num_ordinal_gr = body.getNumOrdinalGr() + cdef const uint32[::1] ordinal_gr_indices = \ + body.ordinal_gr_indices_cbegin() if num_ordinal_gr > 0 else None + cdef const float32[::1] ordinal_gr_thresholds = \ + body.ordinal_gr_thresholds_cbegin() if num_ordinal_gr > 0 else None + cdef uint32 num_nominal_eq = body.getNumNominalEq() cdef const uint32[::1] nominal_eq_indices = \ body.nominal_eq_indices_cbegin() if num_nominal_eq > 0 else None @@ -229,8 +259,10 @@ cdef class RuleList(RuleModel): self.visitor.visit_conjunctive_body( ConjunctiveBody.__new__(ConjunctiveBody, numerical_leq_indices, numerical_leq_thresholds, - numerical_gr_indices, numerical_gr_thresholds, nominal_eq_indices, - nominal_eq_thresholds, nominal_neq_indices, nominal_neq_thresholds)) + numerical_gr_indices, numerical_gr_thresholds, ordinal_leq_indices, + ordinal_leq_thresholds, ordinal_gr_indices, ordinal_gr_thresholds, + nominal_eq_indices, nominal_eq_thresholds, nominal_neq_indices, + nominal_neq_thresholds)) cdef __visit_complete_head(self, const CompleteHeadImpl& head): cdef uint32 num_elements = head.getNumElements() @@ -251,6 +283,8 @@ cdef class RuleList(RuleModel): cdef __serialize_conjunctive_body(self, const ConjunctiveBodyImpl& body): cdef uint32 num_numerical_leq = body.getNumNumericalLeq() cdef uint32 num_numerical_gr = body.getNumNumericalGr() + cdef uint32 num_ordinal_leq = body.getNumOrdinalLeq() + cdef uint32 num_ordinal_gr = body.getNumOrdinalGr() cdef uint32 num_nominal_eq = body.getNumNominalEq() cdef uint32 num_nominal_neq = body.getNumNominalNeq() cdef object body_state = ( @@ -262,6 +296,14 @@ cdef class RuleList(RuleModel): if num_numerical_gr > 0 else None, np.asarray(body.numerical_gr_indices_cbegin()) \ if num_numerical_gr > 0 else None, + np.asarray(body.ordinal_leq_thresholds_cbegin()) \ + if num_ordinal_leq > 0 else None, + np.asarray(body.ordinal_leq_indices_cbegin()) \ + if num_ordinal_leq > 0 else None, + np.asarray(body.ordinal_gr_thresholds_cbegin()) \ + if num_ordinal_gr > 0 else None, + np.asarray(body.ordinal_gr_indices_cbegin()) \ + if num_ordinal_gr > 0 else None, np.asarray(body.nominal_eq_thresholds_cbegin()) \ if num_nominal_eq > 0 else None, np.asarray(body.nominal_eq_indices_cbegin()) \ @@ -300,16 +342,22 @@ cdef class RuleList(RuleModel): cdef const uint32[::1] numerical_leq_indices = body_state[1] cdef const float32[::1] numerical_gr_thresholds = body_state[2] cdef const uint32[::1] numerical_gr_indices = body_state[3] - cdef const float32[::1] nominal_eq_thresholds = body_state[4] - cdef const uint32[::1] nominal_eq_indices = body_state[5] - cdef const float32[::1] nominal_neq_thresholds = body_state[6] - cdef const uint32[::1] nominal_neq_indices = body_state[7] + cdef const float32[::1] ordinal_leq_thresholds = body_state[4] + cdef const uint32[::1] ordinal_leq_indices = body_state[5] + cdef const float32[::1] ordinal_gr_thresholds = body_state[6] + cdef const uint32[::1] ordinal_gr_indices = body_state[7] + cdef const float32[::1] nominal_eq_thresholds = body_state[8] + cdef const uint32[::1] nominal_eq_indices = body_state[9] + cdef const float32[::1] nominal_neq_thresholds = body_state[10] + cdef const uint32[::1] nominal_neq_indices = body_state[11] cdef uint32 num_numerical_leq = numerical_leq_thresholds.shape[0] if numerical_leq_thresholds is not None else 0 cdef uint32 num_numerical_gr = numerical_gr_thresholds.shape[0] if numerical_gr_thresholds is not None else 0 + cdef uint32 num_ordinal_leq = ordinal_leq_thresholds.shape[0] if ordinal_leq_thresholds is not None else 0 + cdef uint32 num_ordinal_gr = ordinal_gr_thresholds.shape[0] if ordinal_gr_thresholds is not None else 0 cdef uint32 num_nominal_eq = nominal_eq_thresholds.shape[0] if nominal_eq_thresholds is not None else 0 cdef uint32 num_nominal_neq = nominal_neq_thresholds.shape[0] if nominal_neq_thresholds is not None else 0 cdef unique_ptr[ConjunctiveBodyImpl] body_ptr = make_unique[ConjunctiveBodyImpl]( - num_numerical_leq, num_numerical_gr, num_nominal_eq, num_nominal_neq) + num_numerical_leq, num_numerical_gr, num_ordinal_leq, num_ordinal_gr, num_nominal_eq, num_nominal_neq) cdef ConjunctiveBodyImpl.threshold_iterator threshold_iterator = body_ptr.get().numerical_leq_thresholds_begin() cdef ConjunctiveBodyImpl.index_iterator index_iterator = body_ptr.get().numerical_leq_indices_begin() cdef uint32 i @@ -325,6 +373,20 @@ cdef class RuleList(RuleModel): threshold_iterator[i] = numerical_gr_thresholds[i] index_iterator[i] = numerical_gr_indices[i] + threshold_iterator = body_ptr.get().ordinal_leq_thresholds_begin() + index_iterator = body_ptr.get().ordinal_leq_indices_begin() + + for i in range(num_ordinal_leq): + threshold_iterator[i] = ordinal_leq_thresholds[i] + index_iterator[i] = ordinal_leq_indices[i] + + threshold_iterator = body_ptr.get().ordinal_gr_thresholds_begin() + index_iterator = body_ptr.get().ordinal_gr_indices_begin() + + for i in range(num_ordinal_gr): + threshold_iterator[i] = ordinal_gr_thresholds[i] + index_iterator[i] = ordinal_gr_indices[i] + threshold_iterator = body_ptr.get().nominal_eq_thresholds_begin() index_iterator = body_ptr.get().nominal_eq_indices_begin() From 7ae02faab4f9827af32e57f85b6da79bec3d411f Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 19:30:27 +0200 Subject: [PATCH 16/20] Consider ordinal conditions for the output of models or model characteristics. --- .../mlrl/testbed/model_characteristics.py | 44 ++++++- .../testbed/mlrl/testbed/models.py | 4 + .../boomer/example-wise-complete-heads.txt | 12 +- ...mplete-heads_equal-width-label-binning.txt | 12 +- .../example-wise-partial-dynamic-heads.txt | 12 +- ...ynamic-heads_equal-width-label-binning.txt | 12 +- .../example-wise-partial-fixed-heads.txt | 12 +- ...-fixed-heads_equal-width-label-binning.txt | 12 +- .../example-wise-single-label-heads.txt | 12 +- .../out/boomer/label-wise-complete-heads.txt | 12 +- ...mplete-heads_equal-width-label-binning.txt | 12 +- .../label-wise-partial-dynamic-heads.txt | 12 +- ...ynamic-heads_equal-width-label-binning.txt | 12 +- .../boomer/label-wise-partial-fixed-heads.txt | 12 +- ...-fixed-heads_equal-width-label-binning.txt | 12 +- .../boomer/label-wise-single-label-heads.txt | 12 +- ...model-characteristics_cross-validation.txt | 120 +++++++++--------- .../model-characteristics_single-fold.txt | 12 +- .../model-characteristics_train-test.txt | 12 +- .../tests/res/out/boomer/no-default-rule.txt | 10 +- .../boomer/parameters_cross-validation.txt | 120 +++++++++--------- .../res/out/boomer/parameters_single-fold.txt | 12 +- .../res/out/boomer/parameters_train-test.txt | 12 +- .../out/boomer/post-pruning_no-holdout.txt | 12 +- .../boomer/post-pruning_random-holdout.txt | 12 +- ...runing_stratified-example-wise-holdout.txt | 12 +- ...-pruning_stratified-label-wise-holdout.txt | 12 +- .../res/out/boomer/pre-pruning_no-holdout.txt | 12 +- .../out/boomer/pre-pruning_random-holdout.txt | 12 +- ...runing_stratified-example-wise-holdout.txt | 12 +- ...-pruning_stratified-label-wise-holdout.txt | 12 +- ...model-characteristics_cross-validation.txt | 120 +++++++++--------- .../model-characteristics_single-fold.txt | 12 +- .../seco/model-characteristics_train-test.txt | 12 +- .../out/seco/parameters_cross-validation.txt | 120 +++++++++--------- .../res/out/seco/parameters_single-fold.txt | 12 +- .../res/out/seco/parameters_train-test.txt | 12 +- .../seco/partial-heads_kln-lift-function.txt | 12 +- .../seco/partial-heads_no-lift-function.txt | 12 +- .../seco/partial-heads_peak-lift-function.txt | 12 +- .../tests/res/out/seco/single-label-heads.txt | 12 +- 41 files changed, 491 insertions(+), 455 deletions(-) diff --git a/python/subprojects/testbed/mlrl/testbed/model_characteristics.py b/python/subprojects/testbed/mlrl/testbed/model_characteristics.py index 99653f2ebe..657b5c8592 100644 --- a/python/subprojects/testbed/mlrl/testbed/model_characteristics.py +++ b/python/subprojects/testbed/mlrl/testbed/model_characteristics.py @@ -60,8 +60,8 @@ class RuleModelCharacteristics(Formattable, Tabularizable): def __init__(self, default_rule_index: int, default_rule_pos_predictions: int, default_rule_neg_predictions: int, num_numerical_leq: np.ndarray, num_numerical_gr: np.ndarray, - num_nominal_eq: np.ndarray, num_nominal_neq: np.ndarray, num_pos_predictions: np.ndarray, - num_neg_predictions: np.ndarray): + num_ordinal_leq: np.ndarray, num_ordinal_gr: np.ndarray, num_nominal_eq: np.ndarray, + num_nominal_neq: np.ndarray, num_pos_predictions: np.ndarray, num_neg_predictions: np.ndarray): """ :param default_rule_index: The index of the default rule or None, if no default rule is used :param default_rule_pos_predictions: The number of positive predictions of the default rule, if any @@ -70,6 +70,10 @@ def __init__(self, default_rule_index: int, default_rule_pos_predictions: int, numerical conditions that use the <= operator per rule :param num_numerical_gr: A `np.ndarray`, shape `(num_rules)` that stores the number of numerical conditions that use the > operator per rule + :param num_ordinal_leq: A `np.ndarray`, shape `(num_rules)` that stores the number of + ordinal conditions that use the <= operator per rule + :param num_ordinal_gr: A `np.ndarray`, shape `(num_rules)` that stores the number of + ordinal conditions that use the > operator per rule :param num_nominal_eq: A `np.ndarray`, shape `(num_rules)` that stores the number of nominal conditions that use the == operator per rule :param num_nominal_neq: A `np.ndarray`, shape `(num_rules)` that stores the number of @@ -84,6 +88,8 @@ def __init__(self, default_rule_index: int, default_rule_pos_predictions: int, self.default_rule_neg_predictions = default_rule_neg_predictions self.num_numerical_leq = num_numerical_leq self.num_numerical_gr = num_numerical_gr + self.num_ordinal_leq = num_ordinal_leq + self.num_ordinal_gr = num_ordinal_gr self.num_nominal_eq = num_nominal_eq self.num_nominal_neq = num_nominal_neq self.num_pos_predictions = num_pos_predictions @@ -95,12 +101,14 @@ def format(self, options: Options, **_): See :func:`mlrl.testbed.output_writer.Formattable.format` """ num_predictions = self.num_pos_predictions + self.num_neg_predictions - num_conditions = self.num_numerical_leq + self.num_numerical_gr + self.num_nominal_eq + self.num_nominal_neq + num_conditions = self.num_numerical_leq + self.num_numerical_gr + self.num_ordinal_leq + self.num_ordinal_gr + self.num_nominal_eq + self.num_nominal_neq num_total_conditions = np.sum(num_conditions) if num_total_conditions > 0: frac_numerical_leq = np.sum(self.num_numerical_leq) / num_total_conditions * 100 frac_numerical_gr = np.sum(self.num_numerical_gr) / num_total_conditions * 100 + frac_ordinal_leq = np.sum(self.num_ordinal_leq) / num_total_conditions * 100 + frac_ordinal_gr = np.sum(self.num_ordinal_gr) / num_total_conditions * 100 frac_nominal_eq = np.sum(self.num_nominal_eq) / num_total_conditions * 100 frac_nominal_neq = np.sum(self.num_nominal_neq) / num_total_conditions * 100 num_conditions_mean = np.mean(num_conditions) @@ -110,6 +118,8 @@ def format(self, options: Options, **_): else: frac_numerical_leq = 0.0 frac_numerical_gr = 0.0 + frac_ordinal_leq = 0.0 + frac_ordinal_gr = 0.0 frac_nominal_eq = 0.0 frac_nominal_neq = 0.0 num_conditions_mean = 0.0 @@ -133,8 +143,11 @@ def format(self, options: Options, **_): num_rules = num_predictions.shape[0] - header = ['Statistics about conditions', 'Total', '<= operator', '> operator', '== operator', '!= operator'] - alignment = ['left', 'right', 'right', 'right', 'right', 'right'] + header = [ + 'Statistics about conditions', 'Total', 'Numerical <= operator', 'Numerical > operator', + 'Ordinal <= operator', 'Ordinal > operator', 'Nominal == operator', 'Nominal != operator' + ] + alignment = ['left', 'right', 'right', 'right', 'right', 'right', 'right', 'right'] rows = [] if self.default_rule_index is not None: @@ -144,6 +157,8 @@ def format(self, options: Options, **_): format_percentage(0), format_percentage(0), format_percentage(0), + format_percentage(0), + format_percentage(0), format_percentage(0) ]) @@ -152,6 +167,8 @@ def format(self, options: Options, **_): str(num_total_conditions), format_percentage(frac_numerical_leq), format_percentage(frac_numerical_gr), + format_percentage(frac_ordinal_leq), + format_percentage(frac_ordinal_gr), format_percentage(frac_nominal_eq), format_percentage(frac_nominal_neq) ]) @@ -214,6 +231,8 @@ def tabularize(self, options: Options, **_) -> Optional[List[Dict[str, str]]]: rule_name += ' (Default rule)' num_numerical_leq = 0 num_numerical_gr = 0 + num_ordinal_leq = 0 + num_ordinal_gr = 0 num_nominal_eq = 0 num_nominal_neq = 0 num_pos_predictions = self.default_rule_pos_predictions @@ -221,6 +240,8 @@ def tabularize(self, options: Options, **_) -> Optional[List[Dict[str, str]]]: else: num_numerical_leq = self.num_numerical_leq[j] num_numerical_gr = self.num_numerical_gr[j] + num_ordinal_leq = self.num_ordinal_leq[j] + num_ordinal_gr = self.num_ordinal_gr[j] num_nominal_eq = self.num_nominal_eq[j] num_nominal_neq = self.num_nominal_neq[j] num_pos_predictions = self.num_pos_predictions[j] @@ -228,8 +249,9 @@ def tabularize(self, options: Options, **_) -> Optional[List[Dict[str, str]]]: j += 1 num_numerical = num_numerical_leq + num_numerical_gr + num_ordinal = num_ordinal_leq + num_ordinal_gr num_nominal = num_nominal_eq + num_nominal_neq - num_conditions = num_numerical + num_nominal + num_conditions = num_numerical + num_ordinal + num_nominal num_predictions = num_pos_predictions + num_neg_predictions rows.append({ 'Rule': rule_name, @@ -237,6 +259,9 @@ def tabularize(self, options: Options, **_) -> Optional[List[Dict[str, str]]]: 'numerical conditions': num_numerical, 'conditions using <= operator': num_numerical_leq, 'conditions using > operator': num_numerical_gr, + 'ordinal conditions': num_ordinal, + 'conditions using <= operator': num_ordinal_leq, + 'conditions using > operator': num_ordinal_gr, 'nominal conditions': num_nominal, 'conditions using == operator': num_nominal_eq, 'conditions using != operator': num_nominal_neq, @@ -255,6 +280,8 @@ class RuleModelCharacteristicsVisitor(RuleModelVisitor): def __init__(self): self.num_numerical_leq = [] self.num_numerical_gr = [] + self.num_ordinal_leq = [] + self.num_ordinal_gr = [] self.num_nominal_eq = [] self.num_nominal_neq = [] self.num_pos_predictions = [] @@ -280,6 +307,9 @@ def visit_conjunctive_body(self, body: ConjunctiveBody): body.numerical_leq_indices.shape[0] if body.numerical_leq_indices is not None else 0) self.num_numerical_gr.append( body.numerical_gr_indices.shape[0] if body.numerical_gr_indices is not None else 0) + self.num_ordinal_leq.append( + body.ordinal_leq_indices.shape[0] if body.ordinal_leq_indices is not None else 0) + self.num_ordinal_gr.append(body.ordinal_gr_indices.shape[0] if body.ordinal_gr_indices is not None else 0) self.num_nominal_eq.append(body.nominal_eq_indices.shape[0] if body.nominal_eq_indices is not None else 0) self.num_nominal_neq.append( body.nominal_neq_indices.shape[0] if body.nominal_neq_indices is not None else 0) @@ -329,6 +359,8 @@ def _generate_output_data(self, meta_data: MetaData, x, y, data_split: DataSplit default_rule_neg_predictions=visitor.default_rule_neg_predictions, num_numerical_leq=np.asarray(visitor.num_numerical_leq), num_numerical_gr=np.asarray(visitor.num_numerical_gr), + num_ordinal_leq=np.asarray(visitor.num_ordinal_leq), + num_ordinal_gr=np.asarray(visitor.num_ordinal_gr), num_nominal_eq=np.asarray(visitor.num_nominal_eq), num_nominal_neq=np.asarray(visitor.num_nominal_neq), num_pos_predictions=np.asarray(visitor.num_pos_predictions), diff --git a/python/subprojects/testbed/mlrl/testbed/models.py b/python/subprojects/testbed/mlrl/testbed/models.py index 6491943cfe..21944aa324 100644 --- a/python/subprojects/testbed/mlrl/testbed/models.py +++ b/python/subprojects/testbed/mlrl/testbed/models.py @@ -153,6 +153,10 @@ def visit_conjunctive_body(self, body: ConjunctiveBody): '<=') num_conditions = self.__format_conditions(num_conditions, body.numerical_gr_indices, body.numerical_gr_thresholds, '>') + num_conditions = self.__format_conditions(num_conditions, body.ordinal_leq_indices, + body.ordinal_leq_thresholds, '<=') + num_conditions = self.__format_conditions(num_conditions, body.ordinal_gr_indices, + body.ordinal_gr_thresholds, '>') num_conditions = self.__format_conditions(num_conditions, body.nominal_eq_indices, body.nominal_eq_thresholds, '==') self.__format_conditions(num_conditions, body.nominal_neq_indices, body.nominal_neq_thresholds, '!=') diff --git a/python/subprojects/testbed/tests/res/out/boomer/example-wise-complete-heads.txt b/python/subprojects/testbed/tests/res/out/boomer/example-wise-complete-heads.txt index 6abc46262c..709c68bd7f 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/example-wise-complete-heads.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/example-wise-complete-heads.txt @@ -31,12 +31,12 @@ Subset Accuracy 29.08 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 12085 │ 51.10% │ 48.90% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 12085 │ 51.10% │ 48.90% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/example-wise-complete-heads_equal-width-label-binning.txt b/python/subprojects/testbed/tests/res/out/boomer/example-wise-complete-heads_equal-width-label-binning.txt index 314864b812..2ac32d24c6 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/example-wise-complete-heads_equal-width-label-binning.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/example-wise-complete-heads_equal-width-label-binning.txt @@ -31,12 +31,12 @@ Subset Accuracy 29.08 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 10418 │ 51.26% │ 48.74% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 10418 │ 51.26% │ 48.74% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-dynamic-heads.txt b/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-dynamic-heads.txt index b61322e9ce..bfa9391f86 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-dynamic-heads.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-dynamic-heads.txt @@ -31,12 +31,12 @@ Subset Accuracy 27.55 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5586 │ 50.50% │ 49.50% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5586 │ 50.50% │ 49.50% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-dynamic-heads_equal-width-label-binning.txt b/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-dynamic-heads_equal-width-label-binning.txt index 1d6f949853..ca817d8a76 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-dynamic-heads_equal-width-label-binning.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-dynamic-heads_equal-width-label-binning.txt @@ -31,12 +31,12 @@ Subset Accuracy 31.63 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 4980 │ 51.71% │ 48.29% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 4980 │ 51.71% │ 48.29% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-fixed-heads.txt b/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-fixed-heads.txt index 2da068b729..15248d0d1c 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-fixed-heads.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-fixed-heads.txt @@ -31,12 +31,12 @@ Subset Accuracy 27.04 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 6380 │ 50.50% │ 49.50% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 6380 │ 50.50% │ 49.50% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-fixed-heads_equal-width-label-binning.txt b/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-fixed-heads_equal-width-label-binning.txt index e3dc5a9e98..864ff67c43 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-fixed-heads_equal-width-label-binning.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/example-wise-partial-fixed-heads_equal-width-label-binning.txt @@ -31,12 +31,12 @@ Subset Accuracy 29.59 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 6445 │ 49.56% │ 50.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 6445 │ 49.56% │ 50.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/example-wise-single-label-heads.txt b/python/subprojects/testbed/tests/res/out/boomer/example-wise-single-label-heads.txt index 2b2d8d1e71..6045988cf7 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/example-wise-single-label-heads.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/example-wise-single-label-heads.txt @@ -31,12 +31,12 @@ Subset Accuracy 25 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5437 │ 50.97% │ 49.03% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5437 │ 50.97% │ 49.03% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/label-wise-complete-heads.txt b/python/subprojects/testbed/tests/res/out/boomer/label-wise-complete-heads.txt index 821c62ba7b..628a6d4175 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/label-wise-complete-heads.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/label-wise-complete-heads.txt @@ -31,12 +31,12 @@ Subset Accuracy 29.08 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 11897 │ 50.70% │ 49.30% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 11897 │ 50.70% │ 49.30% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/label-wise-complete-heads_equal-width-label-binning.txt b/python/subprojects/testbed/tests/res/out/boomer/label-wise-complete-heads_equal-width-label-binning.txt index 91f663bf32..5568bf9f82 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/label-wise-complete-heads_equal-width-label-binning.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/label-wise-complete-heads_equal-width-label-binning.txt @@ -31,12 +31,12 @@ Subset Accuracy 30.61 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 11699 │ 51.00% │ 49.00% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 11699 │ 51.00% │ 49.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-dynamic-heads.txt b/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-dynamic-heads.txt index d73f691cfb..5055cc0919 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-dynamic-heads.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-dynamic-heads.txt @@ -31,12 +31,12 @@ Subset Accuracy 23.98 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 6254 │ 50.51% │ 49.49% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 6254 │ 50.51% │ 49.49% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-dynamic-heads_equal-width-label-binning.txt b/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-dynamic-heads_equal-width-label-binning.txt index c821a26332..c764780eb3 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-dynamic-heads_equal-width-label-binning.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-dynamic-heads_equal-width-label-binning.txt @@ -31,12 +31,12 @@ Subset Accuracy 28.57 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5569 │ 50.08% │ 49.92% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5569 │ 50.08% │ 49.92% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-fixed-heads.txt b/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-fixed-heads.txt index 4d6bf72be4..eb393c9ece 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-fixed-heads.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-fixed-heads.txt @@ -31,12 +31,12 @@ Subset Accuracy 29.59 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 8475 │ 52.06% │ 47.94% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 8475 │ 52.06% │ 47.94% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-fixed-heads_equal-width-label-binning.txt b/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-fixed-heads_equal-width-label-binning.txt index 399073f7ef..9df4a71eaf 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-fixed-heads_equal-width-label-binning.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/label-wise-partial-fixed-heads_equal-width-label-binning.txt @@ -31,12 +31,12 @@ Subset Accuracy 30.1 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5629 │ 51.29% │ 48.71% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5629 │ 51.29% │ 48.71% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/label-wise-single-label-heads.txt b/python/subprojects/testbed/tests/res/out/boomer/label-wise-single-label-heads.txt index b111e40e5f..5abd7eca01 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/label-wise-single-label-heads.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/label-wise-single-label-heads.txt @@ -31,12 +31,12 @@ Subset Accuracy 25.51 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5563 │ 50.39% │ 49.61% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5563 │ 50.39% │ 49.61% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/model-characteristics_cross-validation.txt b/python/subprojects/testbed/tests/res/out/boomer/model-characteristics_cross-validation.txt index f1f610d048..d17454ea86 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/model-characteristics_cross-validation.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/model-characteristics_cross-validation.txt @@ -9,12 +9,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 1): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5852 │ 49.98% │ 50.02% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5852 │ 49.98% │ 50.02% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -37,12 +37,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 2): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 6067 │ 49.56% │ 50.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 6067 │ 49.56% │ 50.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -65,12 +65,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 3): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 6116 │ 50.52% │ 49.48% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 6116 │ 50.52% │ 49.48% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -93,12 +93,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 4): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5969 │ 49.69% │ 50.31% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5969 │ 49.69% │ 50.31% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -121,12 +121,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 5): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5974 │ 49.56% │ 50.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5974 │ 49.56% │ 50.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -149,12 +149,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 6): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5932 │ 49.46% │ 50.54% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5932 │ 49.46% │ 50.54% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -177,12 +177,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 7): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5921 │ 49.30% │ 50.70% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5921 │ 49.30% │ 50.70% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -205,12 +205,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 8): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5910 │ 50.39% │ 49.61% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5910 │ 50.39% │ 49.61% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -233,12 +233,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 9): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5925 │ 50.16% │ 49.84% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5925 │ 50.16% │ 49.84% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -261,12 +261,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 10): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5882 │ 50.58% │ 49.42% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5882 │ 50.58% │ 49.42% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/model-characteristics_single-fold.txt b/python/subprojects/testbed/tests/res/out/boomer/model-characteristics_single-fold.txt index 03b2fa1822..8283192cff 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/model-characteristics_single-fold.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/model-characteristics_single-fold.txt @@ -9,12 +9,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 1): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5852 │ 49.98% │ 50.02% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5852 │ 49.98% │ 50.02% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/model-characteristics_train-test.txt b/python/subprojects/testbed/tests/res/out/boomer/model-characteristics_train-test.txt index cd626bd983..98de221a54 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/model-characteristics_train-test.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/model-characteristics_train-test.txt @@ -8,12 +8,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5563 │ 50.39% │ 49.61% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5563 │ 50.39% │ 49.61% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/no-default-rule.txt b/python/subprojects/testbed/tests/res/out/boomer/no-default-rule.txt index 4836dc77a6..c127455a62 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/no-default-rule.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/no-default-rule.txt @@ -31,11 +31,11 @@ Subset Accuracy 23.98 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ 1000 local rules │ 5492 │ 49.71% │ 50.29% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ 1000 local rules │ 5492 │ 49.71% │ 50.29% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/parameters_cross-validation.txt b/python/subprojects/testbed/tests/res/out/boomer/parameters_cross-validation.txt index a9db08e35f..9470b4cf26 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/parameters_cross-validation.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/parameters_cross-validation.txt @@ -19,12 +19,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 1): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -57,12 +57,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 2): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -95,12 +95,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 3): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -133,12 +133,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 4): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -171,12 +171,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 5): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -209,12 +209,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 6): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -247,12 +247,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 7): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -285,12 +285,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 8): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -323,12 +323,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 9): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -361,12 +361,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 10): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/parameters_single-fold.txt b/python/subprojects/testbed/tests/res/out/boomer/parameters_single-fold.txt index df8fe84dad..6d3702c4fe 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/parameters_single-fold.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/parameters_single-fold.txt @@ -19,12 +19,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 1): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/parameters_train-test.txt b/python/subprojects/testbed/tests/res/out/boomer/parameters_train-test.txt index 7dc99f1f12..6a819b206c 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/parameters_train-test.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/parameters_train-test.txt @@ -18,12 +18,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 66.67% │ 33.33% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 66.67% │ 33.33% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/post-pruning_no-holdout.txt b/python/subprojects/testbed/tests/res/out/boomer/post-pruning_no-holdout.txt index b111e40e5f..5abd7eca01 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/post-pruning_no-holdout.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/post-pruning_no-holdout.txt @@ -31,12 +31,12 @@ Subset Accuracy 25.51 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5563 │ 50.39% │ 49.61% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5563 │ 50.39% │ 49.61% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/post-pruning_random-holdout.txt b/python/subprojects/testbed/tests/res/out/boomer/post-pruning_random-holdout.txt index c24fd28396..746c60be46 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/post-pruning_random-holdout.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/post-pruning_random-holdout.txt @@ -31,12 +31,12 @@ Subset Accuracy 25 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 123 local rules │ 588 │ 50.51% │ 49.49% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 123 local rules │ 588 │ 50.51% │ 49.49% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/post-pruning_stratified-example-wise-holdout.txt b/python/subprojects/testbed/tests/res/out/boomer/post-pruning_stratified-example-wise-holdout.txt index f493d05470..3df0795729 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/post-pruning_stratified-example-wise-holdout.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/post-pruning_stratified-example-wise-holdout.txt @@ -31,12 +31,12 @@ Subset Accuracy 23.47 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 244 local rules │ 1055 │ 51.56% │ 48.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 244 local rules │ 1055 │ 51.56% │ 48.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/post-pruning_stratified-label-wise-holdout.txt b/python/subprojects/testbed/tests/res/out/boomer/post-pruning_stratified-label-wise-holdout.txt index d040fa741c..22650b4594 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/post-pruning_stratified-label-wise-holdout.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/post-pruning_stratified-label-wise-holdout.txt @@ -31,12 +31,12 @@ Subset Accuracy 23.47 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 127 local rules │ 602 │ 54.65% │ 45.35% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 127 local rules │ 602 │ 54.65% │ 45.35% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_no-holdout.txt b/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_no-holdout.txt index b111e40e5f..5abd7eca01 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_no-holdout.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_no-holdout.txt @@ -31,12 +31,12 @@ Subset Accuracy 25.51 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 999 local rules │ 5563 │ 50.39% │ 49.61% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 999 local rules │ 5563 │ 50.39% │ 49.61% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_random-holdout.txt b/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_random-holdout.txt index c24fd28396..746c60be46 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_random-holdout.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_random-holdout.txt @@ -31,12 +31,12 @@ Subset Accuracy 25 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 123 local rules │ 588 │ 50.51% │ 49.49% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 123 local rules │ 588 │ 50.51% │ 49.49% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_stratified-example-wise-holdout.txt b/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_stratified-example-wise-holdout.txt index f493d05470..3df0795729 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_stratified-example-wise-holdout.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_stratified-example-wise-holdout.txt @@ -31,12 +31,12 @@ Subset Accuracy 23.47 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 244 local rules │ 1055 │ 51.56% │ 48.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 244 local rules │ 1055 │ 51.56% │ 48.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_stratified-label-wise-holdout.txt b/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_stratified-label-wise-holdout.txt index d040fa741c..22650b4594 100644 --- a/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_stratified-label-wise-holdout.txt +++ b/python/subprojects/testbed/tests/res/out/boomer/pre-pruning_stratified-label-wise-holdout.txt @@ -31,12 +31,12 @@ Subset Accuracy 23.47 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 127 local rules │ 602 │ 54.65% │ 45.35% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 127 local rules │ 602 │ 54.65% │ 45.35% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/seco/model-characteristics_cross-validation.txt b/python/subprojects/testbed/tests/res/out/seco/model-characteristics_cross-validation.txt index 51847a88eb..d9b3c46d42 100644 --- a/python/subprojects/testbed/tests/res/out/seco/model-characteristics_cross-validation.txt +++ b/python/subprojects/testbed/tests/res/out/seco/model-characteristics_cross-validation.txt @@ -9,12 +9,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 1): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 73 local rules │ 94 │ 46.81% │ 53.19% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 73 local rules │ 94 │ 46.81% │ 53.19% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -37,12 +37,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 2): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 71 local rules │ 84 │ 54.76% │ 45.24% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 71 local rules │ 84 │ 54.76% │ 45.24% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -65,12 +65,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 3): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 77 local rules │ 92 │ 50.00% │ 50.00% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 77 local rules │ 92 │ 50.00% │ 50.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -93,12 +93,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 4): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 72 local rules │ 94 │ 59.57% │ 40.43% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 72 local rules │ 94 │ 59.57% │ 40.43% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -121,12 +121,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 5): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 79 local rules │ 93 │ 52.69% │ 47.31% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 79 local rules │ 93 │ 52.69% │ 47.31% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -149,12 +149,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 6): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 68 local rules │ 84 │ 54.76% │ 45.24% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 68 local rules │ 84 │ 54.76% │ 45.24% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -177,12 +177,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 7): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 80 local rules │ 98 │ 51.02% │ 48.98% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 80 local rules │ 98 │ 51.02% │ 48.98% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -205,12 +205,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 8): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 72 local rules │ 84 │ 46.43% │ 53.57% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 72 local rules │ 84 │ 46.43% │ 53.57% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -233,12 +233,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 9): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 75 local rules │ 94 │ 43.62% │ 56.38% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 75 local rules │ 94 │ 43.62% │ 56.38% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -261,12 +261,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 10): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 77 local rules │ 91 │ 52.75% │ 47.25% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 77 local rules │ 91 │ 52.75% │ 47.25% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/seco/model-characteristics_single-fold.txt b/python/subprojects/testbed/tests/res/out/seco/model-characteristics_single-fold.txt index 20d0194f15..a4591b9ef8 100644 --- a/python/subprojects/testbed/tests/res/out/seco/model-characteristics_single-fold.txt +++ b/python/subprojects/testbed/tests/res/out/seco/model-characteristics_single-fold.txt @@ -9,12 +9,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 1): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 73 local rules │ 94 │ 46.81% │ 53.19% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 73 local rules │ 94 │ 46.81% │ 53.19% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/seco/model-characteristics_train-test.txt b/python/subprojects/testbed/tests/res/out/seco/model-characteristics_train-test.txt index 68dd501982..714617c5f1 100644 --- a/python/subprojects/testbed/tests/res/out/seco/model-characteristics_train-test.txt +++ b/python/subprojects/testbed/tests/res/out/seco/model-characteristics_train-test.txt @@ -8,12 +8,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 61 local rules │ 68 │ 57.35% │ 42.65% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 61 local rules │ 68 │ 57.35% │ 42.65% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/seco/parameters_cross-validation.txt b/python/subprojects/testbed/tests/res/out/seco/parameters_cross-validation.txt index b05be0952f..ac66b634b5 100644 --- a/python/subprojects/testbed/tests/res/out/seco/parameters_cross-validation.txt +++ b/python/subprojects/testbed/tests/res/out/seco/parameters_cross-validation.txt @@ -19,12 +19,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 1): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -57,12 +57,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 2): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -95,12 +95,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 3): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 66.67% │ 33.33% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 66.67% │ 33.33% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -133,12 +133,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 4): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -171,12 +171,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 5): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -209,12 +209,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 6): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 77.78% │ 22.22% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 77.78% │ 22.22% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -247,12 +247,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 7): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -285,12 +285,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 8): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -323,12 +323,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 9): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ @@ -361,12 +361,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 10): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 66.67% │ 33.33% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 66.67% │ 33.33% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/seco/parameters_single-fold.txt b/python/subprojects/testbed/tests/res/out/seco/parameters_single-fold.txt index ad32a6de76..08eb66142e 100644 --- a/python/subprojects/testbed/tests/res/out/seco/parameters_single-fold.txt +++ b/python/subprojects/testbed/tests/res/out/seco/parameters_single-fold.txt @@ -19,12 +19,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics (Fold 1): -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 44.44% │ 55.56% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/seco/parameters_train-test.txt b/python/subprojects/testbed/tests/res/out/seco/parameters_train-test.txt index 608753a454..b813669e9d 100644 --- a/python/subprojects/testbed/tests/res/out/seco/parameters_train-test.txt +++ b/python/subprojects/testbed/tests/res/out/seco/parameters_train-test.txt @@ -18,12 +18,12 @@ DEBUG A dense matrix is used to store the labels of the training examples INFO Successfully fit model in INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 9 local rules │ 9 │ 55.56% │ 44.44% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/seco/partial-heads_kln-lift-function.txt b/python/subprojects/testbed/tests/res/out/seco/partial-heads_kln-lift-function.txt index 7f3e9a9c8c..30aa1bac02 100644 --- a/python/subprojects/testbed/tests/res/out/seco/partial-heads_kln-lift-function.txt +++ b/python/subprojects/testbed/tests/res/out/seco/partial-heads_kln-lift-function.txt @@ -31,12 +31,12 @@ Subset Accuracy 20.41 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 68 local rules │ 75 │ 45.33% │ 54.67% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 68 local rules │ 75 │ 45.33% │ 54.67% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/seco/partial-heads_no-lift-function.txt b/python/subprojects/testbed/tests/res/out/seco/partial-heads_no-lift-function.txt index a320ec304e..bb87fa17a7 100644 --- a/python/subprojects/testbed/tests/res/out/seco/partial-heads_no-lift-function.txt +++ b/python/subprojects/testbed/tests/res/out/seco/partial-heads_no-lift-function.txt @@ -31,12 +31,12 @@ Subset Accuracy 19.39 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 61 local rules │ 68 │ 57.35% │ 42.65% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 61 local rules │ 68 │ 57.35% │ 42.65% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/seco/partial-heads_peak-lift-function.txt b/python/subprojects/testbed/tests/res/out/seco/partial-heads_peak-lift-function.txt index bca43519bb..cd46265294 100644 --- a/python/subprojects/testbed/tests/res/out/seco/partial-heads_peak-lift-function.txt +++ b/python/subprojects/testbed/tests/res/out/seco/partial-heads_peak-lift-function.txt @@ -31,12 +31,12 @@ Subset Accuracy 17.86 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 58 local rules │ 64 │ 50.00% │ 50.00% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 58 local rules │ 64 │ 50.00% │ 50.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ diff --git a/python/subprojects/testbed/tests/res/out/seco/single-label-heads.txt b/python/subprojects/testbed/tests/res/out/seco/single-label-heads.txt index a320ec304e..bb87fa17a7 100644 --- a/python/subprojects/testbed/tests/res/out/seco/single-label-heads.txt +++ b/python/subprojects/testbed/tests/res/out/seco/single-label-heads.txt @@ -31,12 +31,12 @@ Subset Accuracy 19.39 INFO Model characteristics: -┌───────────────────────────────┬─────────┬───────────────┬──────────────┬───────────────┬───────────────┐ -│ Statistics about conditions │ Total │ <= operator │ > operator │ == operator │ != operator │ -├───────────────────────────────┼─────────┼───────────────┼──────────────┼───────────────┼───────────────┤ -│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ -│ 61 local rules │ 68 │ 57.35% │ 42.65% │ 0.00% │ 0.00% │ -└───────────────────────────────┴─────────┴───────────────┴──────────────┴───────────────┴───────────────┘ +┌───────────────────────────────┬─────────┬─────────────────────────┬────────────────────────┬───────────────────────┬──────────────────────┬───────────────────────┬───────────────────────┐ +│ Statistics about conditions │ Total │ Numerical <= operator │ Numerical > operator │ Ordinal <= operator │ Ordinal > operator │ Nominal == operator │ Nominal != operator │ +├───────────────────────────────┼─────────┼─────────────────────────┼────────────────────────┼───────────────────────┼──────────────────────┼───────────────────────┼───────────────────────┤ +│ Default rule │ 0 │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +│ 61 local rules │ 68 │ 57.35% │ 42.65% │ 0.00% │ 0.00% │ 0.00% │ 0.00% │ +└───────────────────────────────┴─────────┴─────────────────────────┴────────────────────────┴───────────────────────┴──────────────────────┴───────────────────────┴───────────────────────┘ ┌────────────────────────────────┬─────────┬────────────┬────────────┐ │ Statistics about predictions │ Total │ Positive │ Negative │ From c7f6e129bd0bce6726a30d1ac5fa7adecf8bbaaa Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 19:35:41 +0200 Subject: [PATCH 17/20] Add function "isOrdinal" to class IFeatureType. --- .../common/include/mlrl/common/input/feature_type.hpp | 7 +++++++ .../include/mlrl/common/input/feature_type_nominal.hpp | 2 ++ .../include/mlrl/common/input/feature_type_numerical.hpp | 2 ++ .../include/mlrl/common/input/feature_type_ordinal.hpp | 2 ++ 4 files changed, 13 insertions(+) diff --git a/cpp/subprojects/common/include/mlrl/common/input/feature_type.hpp b/cpp/subprojects/common/include/mlrl/common/input/feature_type.hpp index e1960f7524..0c2d2d0d4a 100644 --- a/cpp/subprojects/common/include/mlrl/common/input/feature_type.hpp +++ b/cpp/subprojects/common/include/mlrl/common/input/feature_type.hpp @@ -11,6 +11,13 @@ class IFeatureType { virtual ~IFeatureType() {}; + /** + * Returns whether the feature is ordinal or not. + * + * @return True, if the feature is ordinal, false otherwise + */ + virtual bool isOrdinal() const = 0; + /** * Returns whether the feature is nominal or not. * diff --git a/cpp/subprojects/common/include/mlrl/common/input/feature_type_nominal.hpp b/cpp/subprojects/common/include/mlrl/common/input/feature_type_nominal.hpp index 01afab2032..168d04ec13 100644 --- a/cpp/subprojects/common/include/mlrl/common/input/feature_type_nominal.hpp +++ b/cpp/subprojects/common/include/mlrl/common/input/feature_type_nominal.hpp @@ -11,5 +11,7 @@ class NominalFeatureType final : public IFeatureType { public: + bool isOrdinal() const override; + bool isNominal() const override; }; diff --git a/cpp/subprojects/common/include/mlrl/common/input/feature_type_numerical.hpp b/cpp/subprojects/common/include/mlrl/common/input/feature_type_numerical.hpp index 09eb1ab77d..f8bd0eccb6 100644 --- a/cpp/subprojects/common/include/mlrl/common/input/feature_type_numerical.hpp +++ b/cpp/subprojects/common/include/mlrl/common/input/feature_type_numerical.hpp @@ -11,5 +11,7 @@ class NumericalFeatureType final : public IFeatureType { public: + bool isOrdinal() const override; + bool isNominal() const override; }; diff --git a/cpp/subprojects/common/include/mlrl/common/input/feature_type_ordinal.hpp b/cpp/subprojects/common/include/mlrl/common/input/feature_type_ordinal.hpp index 811d040cf8..cb8e77152f 100644 --- a/cpp/subprojects/common/include/mlrl/common/input/feature_type_ordinal.hpp +++ b/cpp/subprojects/common/include/mlrl/common/input/feature_type_ordinal.hpp @@ -11,5 +11,7 @@ class OrdinalFeatureType final : public IFeatureType { public: + bool isOrdinal() const override; + bool isNominal() const override; }; From 2e0b505cdede213f052a979bf5166de497efbf8a Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 19:40:33 +0200 Subject: [PATCH 18/20] Format code. --- .../common/include/mlrl/common/input/feature_type.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/subprojects/common/include/mlrl/common/input/feature_type.hpp b/cpp/subprojects/common/include/mlrl/common/input/feature_type.hpp index 0c2d2d0d4a..ed06ffb052 100644 --- a/cpp/subprojects/common/include/mlrl/common/input/feature_type.hpp +++ b/cpp/subprojects/common/include/mlrl/common/input/feature_type.hpp @@ -13,8 +13,8 @@ class IFeatureType { /** * Returns whether the feature is ordinal or not. - * - * @return True, if the feature is ordinal, false otherwise + * + * @return True, if the feature is ordinal, false otherwise */ virtual bool isOrdinal() const = 0; From daa675230ce7df7ff4ce4797d2f721084e22fdf4 Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 19:40:51 +0200 Subject: [PATCH 19/20] Format code. --- .../common/src/mlrl/common/input/feature_type_nominal.cpp | 4 ++++ .../common/src/mlrl/common/input/feature_type_numerical.cpp | 4 ++++ .../common/src/mlrl/common/input/feature_type_ordinal.cpp | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/cpp/subprojects/common/src/mlrl/common/input/feature_type_nominal.cpp b/cpp/subprojects/common/src/mlrl/common/input/feature_type_nominal.cpp index 7464d8b885..bbb52d00c2 100644 --- a/cpp/subprojects/common/src/mlrl/common/input/feature_type_nominal.cpp +++ b/cpp/subprojects/common/src/mlrl/common/input/feature_type_nominal.cpp @@ -1,5 +1,9 @@ #include "mlrl/common/input/feature_type_nominal.hpp" +bool NominalFeatureType::isOrdinal() const { + return false; +} + bool NominalFeatureType::isNominal() const { return true; } diff --git a/cpp/subprojects/common/src/mlrl/common/input/feature_type_numerical.cpp b/cpp/subprojects/common/src/mlrl/common/input/feature_type_numerical.cpp index b7208179ac..8b58664979 100644 --- a/cpp/subprojects/common/src/mlrl/common/input/feature_type_numerical.cpp +++ b/cpp/subprojects/common/src/mlrl/common/input/feature_type_numerical.cpp @@ -1,5 +1,9 @@ #include "mlrl/common/input/feature_type_numerical.hpp" +bool NumericalFeatureType::isOrdinal() const { + return false; +} + bool NumericalFeatureType::isNominal() const { return false; } diff --git a/cpp/subprojects/common/src/mlrl/common/input/feature_type_ordinal.cpp b/cpp/subprojects/common/src/mlrl/common/input/feature_type_ordinal.cpp index 39b7d914b0..a61646c9b8 100644 --- a/cpp/subprojects/common/src/mlrl/common/input/feature_type_ordinal.cpp +++ b/cpp/subprojects/common/src/mlrl/common/input/feature_type_ordinal.cpp @@ -1,5 +1,9 @@ #include "mlrl/common/input/feature_type_ordinal.hpp" +bool OrdinalFeatureType::isOrdinal() const { + return true; +} + bool OrdinalFeatureType::isNominal() const { return false; } From 5429468c3c81c571587c3bf63ff1db180d09d41e Mon Sep 17 00:00:00 2001 From: Michael Rapp Date: Sun, 13 Aug 2023 19:53:01 +0200 Subject: [PATCH 20/20] Use appropriate conditions if a feature is nominal. --- .../rule_refinement_approximate.hpp | 5 ++- .../rule_refinement/rule_refinement_exact.hpp | 7 +++- .../rule_refinement_approximate.cpp | 28 +++++++------- .../rule_refinement/rule_refinement_exact.cpp | 38 +++++++++---------- .../thresholds/thresholds_approximate.cpp | 4 +- .../common/thresholds/thresholds_exact.cpp | 3 +- 6 files changed, 47 insertions(+), 38 deletions(-) diff --git a/cpp/subprojects/common/include/mlrl/common/rule_refinement/rule_refinement_approximate.hpp b/cpp/subprojects/common/include/mlrl/common/rule_refinement/rule_refinement_approximate.hpp index 99fdc7c067..48d608c20d 100644 --- a/cpp/subprojects/common/include/mlrl/common/rule_refinement/rule_refinement_approximate.hpp +++ b/cpp/subprojects/common/include/mlrl/common/rule_refinement/rule_refinement_approximate.hpp @@ -27,6 +27,8 @@ class ApproximateRuleRefinement final : public IRuleRefinement { const uint32 featureIndex_; + const bool ordinal_; + const bool nominal_; typedef IRuleRefinementCallback Callback; @@ -41,12 +43,13 @@ class ApproximateRuleRefinement final : public IRuleRefinement { * @param numExamples The total number of training examples with non-zero weights that are covered by the * existing rule * @param featureIndex The index of the feature, the new condition corresponds to + * @param ordinal True, if the feature at index `featureIndex` is ordinal, false otherwise * @param nominal True, if the feature at index `featureIndex` is nominal, false otherwise * @param callbackPtr An unique pointer to an object of type `IRuleRefinementCallback` that allows to * retrieve the information that is required to search for potential refinements */ ApproximateRuleRefinement(const IndexVector& labelIndices, uint32 numExamples, uint32 featureIndex, - bool nominal, std::unique_ptr callbackPtr); + bool ordinal, bool nominal, std::unique_ptr callbackPtr); void findRefinement(SingleRefinementComparator& comparator, uint32 minCoverage) override; diff --git a/cpp/subprojects/common/include/mlrl/common/rule_refinement/rule_refinement_exact.hpp b/cpp/subprojects/common/include/mlrl/common/rule_refinement/rule_refinement_exact.hpp index b436c181ce..d36d3b439c 100644 --- a/cpp/subprojects/common/include/mlrl/common/rule_refinement/rule_refinement_exact.hpp +++ b/cpp/subprojects/common/include/mlrl/common/rule_refinement/rule_refinement_exact.hpp @@ -26,6 +26,8 @@ class ExactRuleRefinement final : public IRuleRefinement { const uint32 featureIndex_; + const bool ordinal_; + const bool nominal_; const bool hasZeroWeights_; @@ -42,13 +44,14 @@ class ExactRuleRefinement final : public IRuleRefinement { * @param numExamples The total number of training examples with non-zero weights that are covered by the * existing rule * @param featureIndex The index of the feature, the new condition corresponds to + * @param ordinal True, if the feature at index `featureIndex` is ordinal, false otherwise * @param nominal True, if the feature at index `featureIndex` is nominal, false otherwise * @param hasZeroWeights True, if some training examples may have zero weights, false otherwise * @param callbackPtr An unique pointer to an object of type `IRuleRefinementCallback` that allows to * retrieve the information that is required to search for potential refinements */ - ExactRuleRefinement(const IndexVector& labelIndices, uint32 numExamples, uint32 featureIndex, bool nominal, - bool hasZeroWeights, std::unique_ptr callbackPtr); + ExactRuleRefinement(const IndexVector& labelIndices, uint32 numExamples, uint32 featureIndex, bool ordinal, + bool nominal, bool hasZeroWeights, std::unique_ptr callbackPtr); void findRefinement(SingleRefinementComparator& comparator, uint32 minCoverage) override; diff --git a/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_approximate.cpp b/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_approximate.cpp index 2477cd7e95..b94a4918a0 100644 --- a/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_approximate.cpp +++ b/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_approximate.cpp @@ -4,7 +4,7 @@ template static inline void findRefinementInternally(const IndexVector& labelIndices, uint32 numExamples, uint32 featureIndex, - bool nominal, uint32 minCoverage, + bool ordinal, bool nominal, uint32 minCoverage, IRuleRefinementCallback& callback, RefinementComparator& comparator) { Refinement refinement; @@ -66,7 +66,7 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin refinement.numCovered = numCovered; refinement.covered = true; refinement.threshold = thresholdIterator[r - 1]; - refinement.comparator = nominal ? NOMINAL_EQ : NUMERICAL_LEQ; + refinement.comparator = nominal ? NOMINAL_EQ : (ordinal ? ORDINAL_LEQ : NUMERICAL_LEQ); comparator.pushRefinement(refinement, scoreVector); } } @@ -86,7 +86,7 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin refinement.numCovered = coverage; refinement.covered = false; refinement.threshold = thresholdIterator[r - 1]; - refinement.comparator = nominal ? NOMINAL_NEQ : NUMERICAL_GR; + refinement.comparator = nominal ? NOMINAL_NEQ : (ordinal ? ORDINAL_GR : NUMERICAL_GR); comparator.pushRefinement(refinement, scoreVector); } } @@ -122,7 +122,7 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin refinement.numCovered = numCovered; refinement.covered = true; refinement.threshold = thresholdIterator[sparseBinIndex - 1]; - refinement.comparator = nominal ? NOMINAL_EQ : NUMERICAL_LEQ; + refinement.comparator = nominal ? NOMINAL_EQ : (ordinal ? ORDINAL_LEQ : NUMERICAL_LEQ); comparator.pushRefinement(refinement, scoreVector); } } @@ -142,7 +142,7 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin refinement.numCovered = coverage; refinement.covered = false; refinement.threshold = thresholdIterator[sparseBinIndex - 1]; - refinement.comparator = nominal ? NOMINAL_NEQ : NUMERICAL_GR; + refinement.comparator = nominal ? NOMINAL_NEQ : (ordinal ? ORDINAL_GR : NUMERICAL_GR); comparator.pushRefinement(refinement, scoreVector); } } @@ -197,7 +197,7 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin refinement.comparator = NOMINAL_EQ; } else { refinement.threshold = thresholdIterator[r]; - refinement.comparator = NUMERICAL_GR; + refinement.comparator = ordinal ? ORDINAL_GR : NUMERICAL_GR; } comparator.pushRefinement(refinement, scoreVector); @@ -224,7 +224,7 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin refinement.comparator = NOMINAL_NEQ; } else { refinement.threshold = thresholdIterator[r]; - refinement.comparator = NUMERICAL_LEQ; + refinement.comparator = ordinal ? ORDINAL_LEQ : NUMERICAL_LEQ; } comparator.pushRefinement(refinement, scoreVector); @@ -267,7 +267,7 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin refinement.comparator = NOMINAL_EQ; } else { refinement.threshold = thresholdIterator[sparseBinIndex]; - refinement.comparator = NUMERICAL_GR; + refinement.comparator = ordinal ? ORDINAL_GR : NUMERICAL_GR; } comparator.pushRefinement(refinement, scoreVector); @@ -294,7 +294,7 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin refinement.comparator = NOMINAL_NEQ; } else { refinement.threshold = thresholdIterator[sparseBinIndex]; - refinement.comparator = NUMERICAL_LEQ; + refinement.comparator = ordinal ? ORDINAL_LEQ : NUMERICAL_LEQ; } comparator.pushRefinement(refinement, scoreVector); @@ -354,21 +354,21 @@ static inline void findRefinementInternally(const IndexVector& labelIndices, uin template ApproximateRuleRefinement::ApproximateRuleRefinement(const IndexVector& labelIndices, uint32 numExamples, - uint32 featureIndex, bool nominal, + uint32 featureIndex, bool ordinal, bool nominal, std::unique_ptr callbackPtr) - : labelIndices_(labelIndices), numExamples_(numExamples), featureIndex_(featureIndex), nominal_(nominal), - callbackPtr_(std::move(callbackPtr)) {} + : labelIndices_(labelIndices), numExamples_(numExamples), featureIndex_(featureIndex), ordinal_(ordinal), + nominal_(nominal), callbackPtr_(std::move(callbackPtr)) {} template void ApproximateRuleRefinement::findRefinement(SingleRefinementComparator& comparator, uint32 minCoverage) { - findRefinementInternally(labelIndices_, numExamples_, featureIndex_, nominal_, minCoverage, *callbackPtr_, + findRefinementInternally(labelIndices_, numExamples_, featureIndex_, ordinal_, nominal_, minCoverage, *callbackPtr_, comparator); } template void ApproximateRuleRefinement::findRefinement(FixedRefinementComparator& comparator, uint32 minCoverage) { - findRefinementInternally(labelIndices_, numExamples_, featureIndex_, nominal_, minCoverage, *callbackPtr_, + findRefinementInternally(labelIndices_, numExamples_, featureIndex_, ordinal_, nominal_, minCoverage, *callbackPtr_, comparator); } diff --git a/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_exact.cpp b/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_exact.cpp index c1f6a1aa48..50f0f28b24 100644 --- a/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_exact.cpp +++ b/cpp/subprojects/common/src/mlrl/common/rule_refinement/rule_refinement_exact.cpp @@ -32,9 +32,9 @@ static inline void adjustRefinement(Refinement& refinement, FeatureVector::const template static inline void findRefinementInternally( - const IndexIterator& labelIndices, uint32 numExamples, uint32 featureIndex, bool nominal, uint32 minCoverage, - bool hasZeroWeights, IRuleRefinementCallback& callback, - RefinementComparator& comparator) { + const IndexIterator& labelIndices, uint32 numExamples, uint32 featureIndex, bool ordinal, bool nominal, + uint32 minCoverage, bool hasZeroWeights, + IRuleRefinementCallback& callback, RefinementComparator& comparator) { Refinement refinement; refinement.featureIndex = featureIndex; @@ -119,7 +119,7 @@ static inline void findRefinementInternally( refinement.comparator = NOMINAL_EQ; refinement.threshold = previousThreshold; } else { - refinement.comparator = NUMERICAL_LEQ; + refinement.comparator = ordinal ? ORDINAL_LEQ : NUMERICAL_LEQ; refinement.threshold = arithmeticMean(previousThreshold, currentThreshold); } @@ -147,7 +147,7 @@ static inline void findRefinementInternally( refinement.comparator = NOMINAL_NEQ; refinement.threshold = previousThreshold; } else { - refinement.comparator = NUMERICAL_GR; + refinement.comparator = ordinal ? ORDINAL_GR : NUMERICAL_GR; refinement.threshold = arithmeticMean(previousThreshold, currentThreshold); } @@ -275,7 +275,7 @@ static inline void findRefinementInternally( refinement.comparator = NOMINAL_EQ; refinement.threshold = previousThreshold; } else { - refinement.comparator = NUMERICAL_GR; + refinement.comparator = ordinal ? ORDINAL_GR : NUMERICAL_GR; refinement.threshold = arithmeticMean(currentThreshold, previousThreshold); } @@ -303,7 +303,7 @@ static inline void findRefinementInternally( refinement.comparator = NOMINAL_NEQ; refinement.threshold = previousThreshold; } else { - refinement.comparator = NUMERICAL_LEQ; + refinement.comparator = ordinal ? ORDINAL_LEQ : NUMERICAL_LEQ; refinement.threshold = arithmeticMean(currentThreshold, previousThreshold); } @@ -411,7 +411,7 @@ static inline void findRefinementInternally( } else { refinement.end = lastNegativeR; refinement.previous = previousR; - refinement.comparator = NUMERICAL_GR; + refinement.comparator = ordinal ? ORDINAL_GR : NUMERICAL_GR; refinement.threshold = previousThreshold * 0.5; } @@ -443,7 +443,7 @@ static inline void findRefinementInternally( refinement.end = lastNegativeR; refinement.previous = previousR; refinement.numCovered = (numExamples - numAccumulated); - refinement.comparator = NUMERICAL_LEQ; + refinement.comparator = ordinal ? ORDINAL_LEQ : NUMERICAL_LEQ; refinement.threshold = previousThreshold * 0.5; } @@ -470,7 +470,7 @@ static inline void findRefinementInternally( refinement.previous = previousRNegative; refinement.numCovered = numAccumulatedNegative; refinement.covered = true; - refinement.comparator = NUMERICAL_LEQ; + refinement.comparator = ordinal ? ORDINAL_LEQ : NUMERICAL_LEQ; if (numAccumulatedTotal < numExamples) { // If the condition separates an example with feature value < 0 from an (sparse) example with @@ -500,7 +500,7 @@ static inline void findRefinementInternally( refinement.previous = previousRNegative; refinement.numCovered = coverage; refinement.covered = false; - refinement.comparator = NUMERICAL_GR; + refinement.comparator = ordinal ? ORDINAL_GR : NUMERICAL_GR; if (numAccumulatedTotal < numExamples) { // If the condition separates an example with feature value < 0 from an (sparse) example with @@ -530,21 +530,21 @@ static inline void findRefinementInternally( template ExactRuleRefinement::ExactRuleRefinement(const IndexVector& labelIndices, uint32 numExamples, - uint32 featureIndex, bool nominal, bool hasZeroWeights, - std::unique_ptr callbackPtr) - : labelIndices_(labelIndices), numExamples_(numExamples), featureIndex_(featureIndex), nominal_(nominal), - hasZeroWeights_(hasZeroWeights), callbackPtr_(std::move(callbackPtr)) {} + uint32 featureIndex, bool ordinal, bool nominal, + bool hasZeroWeights, std::unique_ptr callbackPtr) + : labelIndices_(labelIndices), numExamples_(numExamples), featureIndex_(featureIndex), ordinal_(ordinal), + nominal_(nominal), hasZeroWeights_(hasZeroWeights), callbackPtr_(std::move(callbackPtr)) {} template void ExactRuleRefinement::findRefinement(SingleRefinementComparator& comparator, uint32 minCoverage) { - findRefinementInternally(labelIndices_, numExamples_, featureIndex_, nominal_, minCoverage, hasZeroWeights_, - *callbackPtr_, comparator); + findRefinementInternally(labelIndices_, numExamples_, featureIndex_, ordinal_, nominal_, minCoverage, + hasZeroWeights_, *callbackPtr_, comparator); } template void ExactRuleRefinement::findRefinement(FixedRefinementComparator& comparator, uint32 minCoverage) { - findRefinementInternally(labelIndices_, numExamples_, featureIndex_, nominal_, minCoverage, hasZeroWeights_, - *callbackPtr_, comparator); + findRefinementInternally(labelIndices_, numExamples_, featureIndex_, ordinal_, nominal_, minCoverage, + hasZeroWeights_, *callbackPtr_, comparator); } template class ExactRuleRefinement; diff --git a/cpp/subprojects/common/src/mlrl/common/thresholds/thresholds_approximate.cpp b/cpp/subprojects/common/src/mlrl/common/thresholds/thresholds_approximate.cpp index eb909e1527..810359274c 100644 --- a/cpp/subprojects/common/src/mlrl/common/thresholds/thresholds_approximate.cpp +++ b/cpp/subprojects/common/src/mlrl/common/thresholds/thresholds_approximate.cpp @@ -202,10 +202,12 @@ class ApproximateThresholds final : public AbstractThresholds { std::unique_ptr featureTypePtr = thresholds_.featureInfo_.createFeatureType(featureIndex); + bool ordinal = featureTypePtr->isOrdinal(); bool nominal = featureTypePtr->isNominal(); std::unique_ptr callbackPtr = std::make_unique(*this, featureIndex, nominal); return std::make_unique>( - labelIndices, coverageSet_.getNumCovered(), featureIndex, nominal, std::move(callbackPtr)); + labelIndices, coverageSet_.getNumCovered(), featureIndex, ordinal, nominal, + std::move(callbackPtr)); } public: diff --git a/cpp/subprojects/common/src/mlrl/common/thresholds/thresholds_exact.cpp b/cpp/subprojects/common/src/mlrl/common/thresholds/thresholds_exact.cpp index 1ddfde28f2..5102748720 100644 --- a/cpp/subprojects/common/src/mlrl/common/thresholds/thresholds_exact.cpp +++ b/cpp/subprojects/common/src/mlrl/common/thresholds/thresholds_exact.cpp @@ -316,10 +316,11 @@ class ExactThresholds final : public AbstractThresholds { std::unique_ptr featureTypePtr = thresholds_.featureInfo_.createFeatureType(featureIndex); + bool ordinal = featureTypePtr->isOrdinal(); bool nominal = featureTypePtr->isNominal(); std::unique_ptr callbackPtr = std::make_unique(*this, featureIndex); return std::make_unique>( - labelIndices, numCoveredExamples_, featureIndex, nominal, weights_.hasZeroWeights(), + labelIndices, numCoveredExamples_, featureIndex, ordinal, nominal, weights_.hasZeroWeights(), std::move(callbackPtr)); }