diff --git a/rulekit/__init__.py b/rulekit/__init__.py index fbf1752..fa02ac0 100644 --- a/rulekit/__init__.py +++ b/rulekit/__init__.py @@ -1,5 +1,5 @@ # pylint: disable=missing-module-docstring from .main import RuleKit -__VERSION__ = '1.7.5' -__RULEKIT_RELEASE_VERSION__ = '1.7.4' +__VERSION__ = '1.7.6' +__RULEKIT_RELEASE_VERSION__ = '1.7.5' diff --git a/rulekit/classification.py b/rulekit/classification.py index 1f6f981..cd68edc 100644 --- a/rulekit/classification.py +++ b/rulekit/classification.py @@ -73,7 +73,7 @@ class RuleClassifier(BaseOperator, BaseClassifier): def __init__( self, - minsupp_new: int = DEFAULT_PARAMS_VALUE['minsupp_new'], + minsupp_new: float = DEFAULT_PARAMS_VALUE['minsupp_new'], induction_measure: Measures = DEFAULT_PARAMS_VALUE['induction_measure'], pruning_measure: Union[Measures, str] = DEFAULT_PARAMS_VALUE['pruning_measure'], @@ -88,14 +88,14 @@ def __init__( max_rule_count: int = DEFAULT_PARAMS_VALUE['max_rule_count'], approximate_induction: bool = DEFAULT_PARAMS_VALUE['approximate_induction'], approximate_bins_count: int = DEFAULT_PARAMS_VALUE['approximate_bins_count'], - min_rule_covered: Optional[int] = None, + min_rule_covered: Optional[float] = None, ): """ Parameters ---------- - minsupp_new : int = 5 - positive integer representing minimum number of previously uncovered examples to be - covered by a new rule (positive examples for classification problems); default: 5 + minsupp_new : float = 5.0 + a minimum number (or fraction, if value < 1.0) of previously uncovered examples + to be covered by a new rule (positive examples for classification problems); default: 5, induction_measure : :class:`rulekit.params.Measures` = :class:`rulekit.params.\ Measures.Correlation` measure used during induction; default measure is correlation @@ -137,7 +137,7 @@ def __init__( data sets, results may change in future; approximate_bins_count: int = 100 maximum number of bins for an attribute evaluated in the approximate induction. - min_rule_covered : int = None + min_rule_covered : float = None alias to `minsupp_new`. Parameter is deprecated and will be removed in the next major version, use `minsupp_new` @@ -327,7 +327,7 @@ class ExpertRuleClassifier(ExpertKnowledgeOperator, RuleClassifier): def __init__( self, - minsupp_new: int = DEFAULT_PARAMS_VALUE['minsupp_new'], + minsupp_new: float = DEFAULT_PARAMS_VALUE['minsupp_new'], induction_measure: Measures = DEFAULT_PARAMS_VALUE['induction_measure'], pruning_measure: Union[Measures, str] = DEFAULT_PARAMS_VALUE['pruning_measure'], @@ -352,14 +352,14 @@ def __init__( 'preferred_conditions_per_rule'], preferred_attributes_per_rule: int = DEFAULT_PARAMS_VALUE[ 'preferred_attributes_per_rule'], - min_rule_covered: Optional[int] = None + min_rule_covered: Optional[float] = None ): """ Parameters ---------- - minsupp_new : int = 5 - positive integer representing minimum number of previously uncovered examples to be - covered by a new rule (positive examples for classification problems); default: 5 + minsupp_new : float = 5.0 + a minimum number (or fraction, if value < 1.0) of previously uncovered examples + to be covered by a new rule (positive examples for classification problems); default: 5, induction_measure : :class:`rulekit.params.Measures` = \ :class:`rulekit.params.Measures.Correlation` measure used during induction; default measure is correlation @@ -421,7 +421,7 @@ def __init__( maximum number of preferred conditions per rule; default: unlimited, preferred_attributes_per_rule : int = None maximum number of preferred attributes per rule; default: unlimited. - min_rule_covered : int = None + min_rule_covered : float = None alias to `minsupp_new`. Parameter is deprecated and will be removed in the next major version, use `minsupp_new` @@ -555,7 +555,7 @@ def __init__( penalty_strength: float = DEFAULT_PARAMS_VALUE['penalty_strength'], penalty_saturation: float = DEFAULT_PARAMS_VALUE['penalty_saturation'], - minsupp_new: int = DEFAULT_PARAMS_VALUE['minsupp_new'], + minsupp_new: float = DEFAULT_PARAMS_VALUE['minsupp_new'], induction_measure: Measures = DEFAULT_PARAMS_VALUE['induction_measure'], pruning_measure: Union[Measures, str] = DEFAULT_PARAMS_VALUE['pruning_measure'], @@ -585,9 +585,9 @@ def __init__( (s) - penalty strength; Default is 0.5 penalty_saturation: float the value of p_new / P at which penalty reward saturates; Default is 0.2. - minsupp_new : int = 5 - positive integer representing minimum number of previously uncovered examples to be - covered by a new rule (positive examples for classification problems); default: 5 + minsupp_new : float = 5.0 + a minimum number (or fraction, if value < 1.0) of previously uncovered examples + to be covered by a new rule (positive examples for classification problems); default: 5, induction_measure : :class:`rulekit.params.Measures` = \ :class:`rulekit.params.Measures.Correlation` measure used during induction; default measure is correlation diff --git a/rulekit/params.py b/rulekit/params.py index b625028..249c4c5 100644 --- a/rulekit/params.py +++ b/rulekit/params.py @@ -59,8 +59,8 @@ class Measures(Enum): DEFAULT_PARAMS_VALUE = { - 'minsupp_new': 5, - 'min_rule_covered': 5, + 'minsupp_new': 5.0, + 'min_rule_covered': 5.0, 'induction_measure': Measures.Correlation, 'pruning_measure': Measures.Correlation, 'voting_measure': Measures.Correlation, @@ -96,8 +96,8 @@ class Measures(Enum): class ModelsParams(BaseModel): """Model for validating models hyperparameters """ - min_rule_covered: Optional[int] = None - minsupp_new: Optional[int] = DEFAULT_PARAMS_VALUE['minsupp_new'] + min_rule_covered: Optional[float] = None + minsupp_new: Optional[float] = DEFAULT_PARAMS_VALUE['minsupp_new'] induction_measure: Optional[Measures] = DEFAULT_PARAMS_VALUE['induction_measure'] pruning_measure: Optional[Measures] = DEFAULT_PARAMS_VALUE['pruning_measure'] voting_measure: Optional[Measures] = DEFAULT_PARAMS_VALUE['voting_measure'] diff --git a/rulekit/regression.py b/rulekit/regression.py index 71181c8..d77df5f 100644 --- a/rulekit/regression.py +++ b/rulekit/regression.py @@ -27,7 +27,7 @@ class RuleRegressor(BaseOperator): def __init__( self, - minsupp_new: int = DEFAULT_PARAMS_VALUE['minsupp_new'], + minsupp_new: float = DEFAULT_PARAMS_VALUE['minsupp_new'], induction_measure: Measures = DEFAULT_PARAMS_VALUE['induction_measure'], pruning_measure: Union[Measures, str] = DEFAULT_PARAMS_VALUE['pruning_measure'], @@ -40,14 +40,14 @@ def __init__( complementary_conditions: bool = DEFAULT_PARAMS_VALUE['complementary_conditions'], mean_based_regression: bool = DEFAULT_PARAMS_VALUE['mean_based_regression'], max_rule_count: int = DEFAULT_PARAMS_VALUE['max_rule_count'], - min_rule_covered: Optional[int] = None, + min_rule_covered: Optional[float] = None, ): """ Parameters ---------- - minsupp_new : int = 5 - positive integer representing minimum number of previously uncovered examples to be - covered by a new rule (positive examples for classification problems); default: 5 + minsupp_new : float = 5.0 + a minimum number (or fraction, if value < 1.0) of previously uncovered examples + to be covered by a new rule (positive examples for classification problems); default: 5, induction_measure : :class:`rulekit.params.Measures` = \ :class:`rulekit.params.Measures.Correlation` measure used during induction; default measure is correlation @@ -82,7 +82,7 @@ def __init__( max_rule_count : int = 0 Maximum number of rules to be generated (for classification data sets it applies to a single class); 0 indicates no limit. - min_rule_covered : int = None + min_rule_covered : float = None alias to `minsupp_new`. Parameter is deprecated and will be removed in the next major version, use `minsupp_new` @@ -176,7 +176,7 @@ class ExpertRuleRegressor(ExpertKnowledgeOperator, RuleRegressor): def __init__( self, - minsupp_new: int = DEFAULT_PARAMS_VALUE['minsupp_new'], + minsupp_new: float = DEFAULT_PARAMS_VALUE['minsupp_new'], induction_measure: Measures = DEFAULT_PARAMS_VALUE['induction_measure'], pruning_measure: Union[Measures, str] = DEFAULT_PARAMS_VALUE['pruning_measure'], @@ -199,14 +199,14 @@ def __init__( preferred_attributes_per_rule: int = DEFAULT_PARAMS_VALUE[ 'preferred_attributes_per_rule'], - min_rule_covered: Optional[int] = None + min_rule_covered: Optional[float] = None ): """ Parameters ---------- - minsupp_new : int = 5 - positive integer representing minimum number of previously uncovered examples to be - covered by a new rule (positive examples for classification problems); default: 5 + minsupp_new : float = 5.0 + a minimum number (or fraction, if value < 1.0) of previously uncovered examples + to be covered by a new rule (positive examples for classification problems); default: 5, induction_measure : :class:`rulekit.params.Measures` = \ :class:`rulekit.params.Measures.Correlation` measure used during induction; default measure is correlation @@ -364,7 +364,7 @@ def __init__( penalty_strength: float = DEFAULT_PARAMS_VALUE['penalty_strength'], penalty_saturation: float = DEFAULT_PARAMS_VALUE['penalty_saturation'], - minsupp_new: int = DEFAULT_PARAMS_VALUE['minsupp_new'], + minsupp_new: float = DEFAULT_PARAMS_VALUE['minsupp_new'], induction_measure: Measures = DEFAULT_PARAMS_VALUE['induction_measure'], pruning_measure: Union[Measures, str] = DEFAULT_PARAMS_VALUE['pruning_measure'], @@ -392,9 +392,9 @@ def __init__( (s) - penalty strength; Default is 0.5 penalty_saturation: float the value of p_new / P at which penalty reward saturates; Default is 0.2. - minsupp_new : int = 5 - positive integer representing minimum number of previously uncovered examples to be - covered by a new rule (positive examples for classification problems); default: 5 + minsupp_new : float = 5.0 + a minimum number (or fraction, if value < 1.0) of previously uncovered examples + to be covered by a new rule (positive examples for classification problems); default: 5, induction_measure : :class:`rulekit.params.Measures` = \ :class:`rulekit.params.Measures.Correlation` measure used during induction; default measure is correlation diff --git a/rulekit/survival.py b/rulekit/survival.py index 01c75ba..62431e7 100644 --- a/rulekit/survival.py +++ b/rulekit/survival.py @@ -9,7 +9,6 @@ from ._helpers import ( PredictionResultMapper, - get_rule_generator, create_example_set ) from ._operator import BaseOperator, ExpertKnowledgeOperator, Data @@ -21,13 +20,13 @@ class SurvivalModelsParams(BaseModel): """Model for validating survival models hyperparameters """ survival_time_attr: Optional[str] - minsupp_new: Optional[int] = DEFAULT_PARAMS_VALUE['minsupp_new'] + minsupp_new: Optional[float] = DEFAULT_PARAMS_VALUE['minsupp_new'] max_growing: Optional[float] = DEFAULT_PARAMS_VALUE['max_growing'] enable_pruning: Optional[bool] = DEFAULT_PARAMS_VALUE['enable_pruning'] ignore_missing: Optional[bool] = DEFAULT_PARAMS_VALUE['ignore_missing'] max_uncovered_fraction: Optional[float] = DEFAULT_PARAMS_VALUE['max_uncovered_fraction'] select_best_candidate: Optional[bool] = DEFAULT_PARAMS_VALUE['select_best_candidate'] - min_rule_covered: Optional[int] = None + min_rule_covered: Optional[float] = None complementary_conditions: Optional[bool] = DEFAULT_PARAMS_VALUE['complementary_conditions'] extend_using_preferred: Optional[bool] = None @@ -63,9 +62,9 @@ def __init__( # pylint: disable=super-init-not-called survival_time_attr : str name of column containing survival time data (use when data passed to model is padnas dataframe). - minsupp_new : int = 5 - positive integer representing minimum number of previously uncovered examples to be - covered by a new rule (positive examples for classification problems); default: 5 + minsupp_new : float = 5.0 + a minimum number (or fraction, if value < 1.0) of previously uncovered examples + to be covered by a new rule (positive examples for classification problems); default: 5, max_growing : int = 0.0 non-negative integer representing maximum number of conditions which can be added to the rule in the growing phase (use this parameter for large datasets if execution time @@ -88,7 +87,7 @@ def __init__( # pylint: disable=super-init-not-called max_rule_count : int = 0 Maximum number of rules to be generated (for classification data sets it applies to a single class); 0 indicates no limit. - min_rule_covered : int = None + min_rule_covered : float = None alias to `minsupp_new`. Parameter is deprecated and will be removed in the next major version, use `minsupp_new` @@ -239,7 +238,7 @@ class ExpertSurvivalRules(ExpertKnowledgeOperator, SurvivalRules): def __init__( # pylint: disable=super-init-not-called self, survival_time_attr: str = None, - minsupp_new: int = DEFAULT_PARAMS_VALUE['minsupp_new'], + minsupp_new: float = DEFAULT_PARAMS_VALUE['minsupp_new'], max_growing: int = DEFAULT_PARAMS_VALUE['max_growing'], enable_pruning: bool = DEFAULT_PARAMS_VALUE['enable_pruning'], ignore_missing: bool = DEFAULT_PARAMS_VALUE['ignore_missing'], @@ -256,14 +255,14 @@ def __init__( # pylint: disable=super-init-not-called preferred_attributes_per_rule: int = DEFAULT_PARAMS_VALUE[ 'preferred_attributes_per_rule'], max_rule_count: int = DEFAULT_PARAMS_VALUE['max_rule_count'], - min_rule_covered: Optional[int] = None + min_rule_covered: Optional[float] = None ): """ Parameters ---------- - minsupp_new : int = 5 - positive integer representing minimum number of previously uncovered examples to be - covered by a new rule (positive examples for classification problems); default: 5 + minsupp_new : float = 5.0 + a minimum number (or fraction, if value < 1.0) of previously uncovered examples + to be covered by a new rule (positive examples for classification problems); default: 5, survival_time_attr : str name of column containing survival time data (use when data passed to model is pandas dataframe). @@ -309,7 +308,7 @@ def __init__( # pylint: disable=super-init-not-called maximum number of preferred conditions per rule; default: unlimited, preferred_attributes_per_rule : int = None maximum number of preferred attributes per rule; default: unlimited. - min_rule_covered : int = None + min_rule_covered : float = None alias to `minsupp_new`. Parameter is deprecated and will be removed in the next major version, use `minsupp_new` @@ -420,7 +419,7 @@ def __init__( # pylint: disable=super-init-not-called penalty_saturation: float = DEFAULT_PARAMS_VALUE['penalty_saturation'], survival_time_attr: str = None, - minsupp_new: int = DEFAULT_PARAMS_VALUE['minsupp_new'], + minsupp_new: float = DEFAULT_PARAMS_VALUE['minsupp_new'], max_growing: int = DEFAULT_PARAMS_VALUE['max_growing'], enable_pruning: bool = DEFAULT_PARAMS_VALUE['enable_pruning'], ignore_missing: bool = DEFAULT_PARAMS_VALUE['ignore_missing'], @@ -446,9 +445,9 @@ def __init__( # pylint: disable=super-init-not-called survival_time_attr : str name of column containing survival time data (use when data passed to model is pandas dataframe). - minsupp_new : int = 5 - positive integer representing minimum number of previously uncovered examples to be - covered by a new rule (positive examples for classification problems); default: 5 + minsupp_new : float = 5.0 + a minimum number (or fraction, if value < 1.0) of previously uncovered examples + to be covered by a new rule (positive examples for classification problems); default: 5, max_growing : int = 0.0 non-negative integer representing maximum number of conditions which can be added to the rule in the growing phase (use this parameter for large datasets if execution time diff --git a/setup.py b/setup.py index d512709..0165b81 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setuptools.setup( name="rulekit", - version='1.7.5', + version='1.7.6', author="Cezary Maszczyk", author_email="cezary.maszczyk@gmail.com", description="Comprehensive suite for rule-based learning",