def fit(self, x, y):
        """
        :param x: 2D np.ndarray (n_instances, n_features) should be categorical data, must be of type int
        :param y: 1D np.ndarray (n_instances, ) labels
        :return:
        """
        verbose = self.verbose
        # Create temporary files
        data_file = tempfile.NamedTemporaryFile("w+b", delete=False)
        label_file = tempfile.NamedTemporaryFile("w+b", delete=False)

        start = time.time()
        raw_rules = categorical2pysbrl_data(x, y, data_file.name, label_file.name, supp=self.min_support,
                                            zmin=self.min_rule_len, zmax=self.max_rule_len, method=self.fim_method)
        if verbose > 1:
            print("Info: sbrl data files saved to %s and %s temporarily" % (data_file.name, label_file.name))
        data_file.close()
        label_file.close()
        cat_time = time.time() - start
        if verbose:
            print("Info: time for rule mining: %.4fs" % cat_time)
        n_labels = int(np.max(y)) + 1
        start = time.time()
        _model = train_sbrl(data_file.name, label_file.name, self.lambda_, eta=self.eta,
                            max_iters=self.iters, n_chains=self.n_chains, seed=self.seed,
                            alpha=self.alpha, verbose=verbose)
        train_time = time.time() - start
        if verbose:
            print("Info: training time: %.4fs" % train_time)

        # update model parameters
        self._n_classes = n_labels
        self._n_features = x.shape[1]

        # convert the raw parameters to rules
        self.from_raw(_model[0], _model[1], raw_rules)
        self._supports = self.compute_support(x, y)

        # Close the temp files
        os.unlink(data_file.name)
        os.unlink(label_file.name)
def fit ( self , x , y ) : verbose = self . verbose data_file = tempfile . NamedTemporaryFile ( "w+b" , delete = False ) label_file = tempfile . NamedTemporaryFile ( "w+b" , delete = False ) start = time . time ( ) raw_rules = categorical2pysbrl_data ( x , y , data_file . name , label_file . name , supp = self . min_support , zmin = self . min_rule_len , zmax = self . max_rule_len , method = self . fim_method ) if verbose > 1 : print ( "Info: sbrl data files saved to %s and %s temporarily" % ( data_file . name , label_file . name ) ) data_file . close ( ) label_file . close ( ) cat_time = time . time ( ) - start if verbose : print ( "Info: time for rule mining: %.4fs" % cat_time ) n_labels = int ( np . max ( y ) ) + 1 start = time . time ( ) _model = train_sbrl ( data_file . name , label_file . name , self . lambda_ , eta = self . eta , max_iters = self . iters , n_chains = self . n_chains , seed = self . seed , alpha = self . alpha , verbose = verbose ) train_time = time . time ( ) - start if verbose : print ( "Info: training time: %.4fs" % train_time ) self . _n_classes = n_labels self . _n_features = x . shape [ 1 ] self . from_raw ( _model [ 0 ] , _model [ 1 ] , raw_rules ) self . _supports = self . compute_support ( x , y ) os . unlink ( data_file . name ) os . unlink ( label_file . name )
:param x: 2D np.ndarray (n_instances, n_features) should be categorical data, must be of type int
        :param y: 1D np.ndarray (n_instances, ) labels
        :return: