Ejemplo n.º 1
0
    def __configure_feature_binning(self, config: BoostingRuleLearnerConfig):
        feature_binning = self.feature_binning

        if feature_binning is not None:
            if feature_binning == AUTOMATIC:
                config.use_automatic_feature_binning()
            else:
                configure_feature_binning(config, feature_binning)
Ejemplo n.º 2
0
    def __configure_l2_regularization(self, config: BoostingRuleLearnerConfig):
        l2_regularization_weight = self.l2_regularization_weight

        if l2_regularization_weight is not None:
            if l2_regularization_weight == 0:
                config.use_no_l2_regularization()
            else:
                config.use_l2_regularization().set_regularization_weight(
                    l2_regularization_weight)
Ejemplo n.º 3
0
    def __configure_post_processor(self, config: BoostingRuleLearnerConfig):
        shrinkage = self.shrinkage

        if shrinkage is not None:
            if shrinkage == 1:
                config.use_no_post_processor()
            else:
                config.use_constant_shrinkage_post_processor().set_shrinkage(
                    shrinkage)
Ejemplo n.º 4
0
    def __configure_parallel_statistic_update(
            self, config: BoostingRuleLearnerConfig):
        parallel_statistic_update = self.parallel_statistic_update

        if parallel_statistic_update is not None:
            if parallel_statistic_update == AUTOMATIC:
                config.use_automatic_parallel_statistic_update()
            else:
                configure_parallel_statistic_update(config,
                                                    parallel_statistic_update)
Ejemplo n.º 5
0
    def __configure_parallel_rule_refinement(
            self, config: BoostingRuleLearnerConfig):
        parallel_rule_refinement = self.parallel_rule_refinement

        if parallel_rule_refinement is not None:
            if parallel_rule_refinement == AUTOMATIC:
                config.use_automatic_parallel_rule_refinement()
            else:
                configure_parallel_rule_refinement(config,
                                                   parallel_rule_refinement)
Ejemplo n.º 6
0
    def __configure_label_binning(self, config: BoostingRuleLearnerConfig):
        label_binning = self.label_binning

        if label_binning is not None:
            value, options = parse_param_and_options('label_binning',
                                                     label_binning,
                                                     LABEL_BINNING_VALUES)

            if value == NONE:
                config.use_no_label_binning()
            elif value == AUTOMATIC:
                config.use_automatic_label_binning()
            if value == BINNING_EQUAL_WIDTH:
                c = config.use_equal_width_label_binning()
                c.set_bin_ratio(
                    options.get_float(ARGUMENT_BIN_RATIO, c.get_bin_ratio()))
                c.set_min_bins(
                    options.get_int(ARGUMENT_MIN_BINS, c.get_min_bins()))
                c.set_max_bins(
                    options.get_int(ARGUMENT_MAX_BINS, c.get_max_bins()))
Ejemplo n.º 7
0
    def __configure_loss(self, config: BoostingRuleLearnerConfig):
        loss = self.loss

        if loss is not None:
            value = parse_param("loss", loss, LOSS_VALUES)

            if value == LOSS_SQUARED_ERROR_LABEL_WISE:
                config.use_label_wise_squared_error_loss()
            elif value == LOSS_SQUARED_HINGE_LABEL_WISE:
                config.use_label_wise_squared_hinge_loss()
            elif value == LOSS_LOGISTIC_LABEL_WISE:
                config.use_label_wise_logistic_loss()
            elif value == LOSS_LOGISTIC_EXAMPLE_WISE:
                config.use_example_wise_logistic_loss()
Ejemplo n.º 8
0
    def __configure_head_type(self, config: BoostingRuleLearnerConfig):
        head_type = self.head_type

        if head_type is not None:
            value = parse_param("head_type", head_type, HEAD_TYPE_VALUES)

            if value == AUTOMATIC:
                config.use_automatic_heads()
            elif value == HEAD_TYPE_SINGLE:
                config.use_single_label_heads()
            elif value == HEAD_TYPE_COMPLETE:
                config.use_complete_heads()
Ejemplo n.º 9
0
    def __configure_classification_predictor(
            self, config: BoostingRuleLearnerConfig):
        predictor = self.predictor

        if predictor is not None:
            value = parse_param('predictor', predictor, PREDICTOR_VALUES)

            if predictor == AUTOMATIC:
                config.use_automatic_label_binning()
            elif value == PREDICTOR_LABEL_WISE:
                config.use_label_wise_classification_predictor()
            elif value == PREDICTOR_EXAMPLE_WISE:
                config.use_example_wise_classification_predictor()
Ejemplo n.º 10
0
 def _create_learner(self) -> RuleLearnerWrapper:
     config = BoostingRuleLearnerConfig()
     configure_rule_model_assemblage(config, self.rule_model_assemblage)
     configure_rule_induction(config, self.rule_induction)
     self.__configure_feature_binning(config)
     configure_label_sampling(config, self.label_sampling)
     configure_instance_sampling(config, self.instance_sampling)
     configure_feature_sampling(config, self.feature_sampling)
     configure_partition_sampling(config, self.holdout)
     configure_pruning(config, self.pruning)
     self.__configure_parallel_rule_refinement(config)
     self.__configure_parallel_statistic_update(config)
     configure_parallel_prediction(config, self.parallel_prediction)
     configure_size_stopping_criterion(config, max_rules=self.max_rules)
     configure_time_stopping_criterion(config, time_limit=self.time_limit)
     self.__configure_measure_stopping_criterion(config)
     self.__configure_post_processor(config)
     self.__configure_head_type(config)
     self.__configure_l1_regularization(config)
     self.__configure_l2_regularization(config)
     self.__configure_loss(config)
     self.__configure_label_binning(config)
     self.__configure_classification_predictor(config)
     return BoostingRuleLearnerWrapper(config)