(self, data_instances=None, validate_data=None)
Fit OneVsRest model
        Parameters:
        ----------
        data_instances: Table of instances
Fit OneVsRest model
        Parameters:
        ----------
        data_instances: Table of instances
Fit OneVsRest model Parameters : ---------- data_instances : Table of instances
def fit(self, data_instances=None, validate_data=None):
        """
        Fit OneVsRest model
        Parameters:
        ----------
        data_instances: Table of instances
        """
        if self.mode == consts.HOMO:
            raise ValueError("Currently, One vs Rest is not supported for homo algorithm")

        LOGGER.info("mode is {}, role is {}, start to one_vs_rest fit".format(self.mode, self.role))

        LOGGER.info("Total classes:{}".format(self.classes))

        self.classifier.callback_one_vs_rest = True
        current_flow_id = self.classifier.flowid
        summary_dict = {}
        for label_index, label in enumerate(self.classes):
            LOGGER.info("Start to train OneVsRest with label_index:{}, label:{}".format(label_index, label))
            classifier = copy.deepcopy(self.classifier)
            classifier.need_one_vs_rest = False
            classifier.set_flowid(".".join([current_flow_id, "model_" + str(label_index)]))
            if self.has_label:
                header = data_instances.schema.get("header")
                data_instances_mask_label = self._mask_data_label(data_instances, label=label)
                data_instances_mask_label.schema['header'] = header

                if validate_data is not None:
                    validate_mask_label_data = self._mask_data_label(validate_data, label=label)
                    validate_mask_label_data.schema['header'] = header
                else:
                    validate_mask_label_data = validate_data
                LOGGER.info("finish mask label:{}".format(label))

                LOGGER.info("start classifier fit")
                classifier.fit_binary(data_instances_mask_label, validate_data=validate_mask_label_data)
            else:
                LOGGER.info("start classifier fit")
                classifier.fit_binary(data_instances, validate_data=validate_data)
            _summary = classifier.summary()
            _summary['one_vs_rest'] = True
            summary_dict[label] = _summary
            self.models.append(classifier)
            LOGGER.info("Finish model_{} training!".format(label_index))
        self.classifier.set_summary(summary_dict)
def fit ( self , data_instances = None , validate_data = None ) : if self . mode == consts . HOMO : raise ValueError ( "Currently, One vs Rest is not supported for homo algorithm" ) LOGGER . info ( "mode is {}, role is {}, start to one_vs_rest fit" . format ( self . mode , self . role ) ) LOGGER . info ( "Total classes:{}" . format ( self . classes ) ) self . classifier . callback_one_vs_rest = True current_flow_id = self . classifier . flowid summary_dict = { } for label_index , label in enumerate ( self . classes ) : LOGGER . info ( "Start to train OneVsRest with label_index:{}, label:{}" . format ( label_index , label ) ) classifier = copy . deepcopy ( self . classifier ) classifier . need_one_vs_rest = False classifier . set_flowid ( "." . join ( [ current_flow_id , "model_" + str ( label_index ) ] ) ) if self . has_label : header = data_instances . schema . get ( "header" ) data_instances_mask_label = self . _mask_data_label ( data_instances , label = label ) data_instances_mask_label . schema [ 'header' ] = header if validate_data is not None : validate_mask_label_data = self . _mask_data_label ( validate_data , label = label ) validate_mask_label_data . schema [ 'header' ] = header else : validate_mask_label_data = validate_data LOGGER . info ( "finish mask label:{}" . format ( label ) ) LOGGER . info ( "start classifier fit" ) classifier . fit_binary ( data_instances_mask_label , validate_data = validate_mask_label_data ) else : LOGGER . info ( "start classifier fit" ) classifier . fit_binary ( data_instances , validate_data = validate_data ) _summary = classifier . summary ( ) _summary [ 'one_vs_rest' ] = True summary_dict [ label ] = _summary self . models . append ( classifier ) LOGGER . info ( "Finish model_{} training!" . format ( label_index ) ) self . classifier . set_summary ( summary_dict )