olpy/classifiers/__base.py
def fit(self, X: np.ndarray, Y: np.ndarray, verbose=False, **kwargs):
        """Fits the model to the (X,Y) pair passed to the function.

        Args:
            X (:obj:`numpy.ndarray`): Input data with n rows and
                m columns
            Y (:obj:`numpy.ndarray`): Output variable with binary
                labels.
            verbose (:obj:`bool`, optional): Specifies whether the 
                performances should be reported or not. Defaults to False.
            ** kwargs: Arbitrary keyword arguments.
        
        Returns:
            self: the trained model.
        """
        positive_label = kwargs.get('positive_label', 1)

        self.weights = np.zeros(X.shape[1])
        y_transformed, self.labels = LabelEncoder(
            positive_label=self.positive_label).fit_transform(
            Y,
            return_labels=True
        )
        if self.class_weight is not None:
            weights = self.class_weight / sum(self.class_weight)
            self.class_weight_ = {
                -1: weights[self.labels[0]],
                1: weights[positive_label],
            }
        random.seed(self.random_state)
        self._setup(X)

        for iteration in range(1, self.num_iterations + 1):
            start = time.time()
            idx = random.sample(range(X.shape[0]), k=X.shape[0])
            for x, y in zip(X[idx, :], y_transformed[idx]):
                self._update(x, y)

            if verbose:
                prediction = self.predict(X)
                print('Iteration ({}/{}) \tRuntime: {}s \tAccuracy:  {}/{}'.
                    format(
                    iteration, self.num_iterations,
                    time.time() - start,
                    np.count_nonzero(prediction == Y), X.shape[0]))
        return self
Fits the model to the (X,Y) pair passed to the function.

        Args:
            X (:obj:`numpy.ndarray`): Input data with n rows and
                m columns
            Y (:obj:`numpy.ndarray`): Output variable with binary
                labels.
            verbose (:obj:`bool`, optional): Specifies whether the 
                performances should be reported or not. Defaults to False.
            ** kwargs: Arbitrary keyword arguments.
        
        Returns:
            self: the trained model.
        
Fits the model to the (X,Y) pair passed to the function.
Fits the model to the ( X Y ) pair passed to the function .
def fit(self, X: np.ndarray, Y: np.ndarray, verbose=False, **kwargs):
        positive_label = kwargs.get('positive_label', 1)
        self.weights = np.zeros(X.shape[1])
        y_transformed, self.labels = LabelEncoder(
            positive_label=self.positive_label).fit_transform(
            Y,
            return_labels=True
        )
        if self.class_weight is not None:
            weights = self.class_weight / sum(self.class_weight)
            self.class_weight_ = {
                -1: weights[self.labels[0]],
                1: weights[positive_label],
            }
        random.seed(self.random_state)
        self._setup(X)
        for iteration in range(1, self.num_iterations + 1):
            start = time.time()
            idx = random.sample(range(X.shape[0]), k=X.shape[0])
            for x, y in zip(X[idx, :], y_transformed[idx]):
                self._update(x, y)
            if verbose:
                prediction = self.predict(X)
                print('Iteration ({}/{}) \tRuntime: {}s \tAccuracy:  {}/{}'.
                    format(
                    iteration, self.num_iterations,
                    time.time() - start,
                    np.count_nonzero(prediction == Y), X.shape[0]))
        return self
def fit ( self , X : np . ndarray , Y : np . ndarray , verbose = False , ** kwargs ) : positive_label = kwargs . get ( 'positive_label' , 1 ) self . weights = np . zeros ( X . shape [ 1 ] ) y_transformed , self . labels = LabelEncoder ( positive_label = self . positive_label ) . fit_transform ( Y , return_labels = True ) if self . class_weight is not None : weights = self . class_weight / sum ( self . class_weight ) self . class_weight_ = { - 1 : weights [ self . labels [ 0 ] ] , 1 : weights [ positive_label ] , } random . seed ( self . random_state ) self . _setup ( X ) for iteration in range ( 1 , self . num_iterations + 1 ) : start = time . time ( ) idx = random . sample ( range ( X . shape [ 0 ] ) , k = X . shape [ 0 ] ) for x , y in zip ( X [ idx , : ] , y_transformed [ idx ] ) : self . _update ( x , y ) if verbose : prediction = self . predict ( X ) print ( 'Iteration ({}/{}) \tRuntime: {}s \tAccuracy:  {}/{}' . format ( iteration , self . num_iterations , time . time ( ) - start , np . count_nonzero ( prediction == Y ) , X . shape [ 0 ] ) ) return self
Fits the model to the (X,Y) pair passed to the function.
Fits the model to the ( X Y ) pair passed to the function .
"""Fits the model to the (X,Y) pair passed to the function.

        Args:
            X (:obj:`numpy.ndarray`): Input data with n rows and
                m columns
            Y (:obj:`numpy.ndarray`): Output variable with binary
                labels.
            verbose (:obj:`bool`, optional): Specifies whether the 
                performances should be reported or not. Defaults to False.
            ** kwargs: Arbitrary keyword arguments.
        
        Returns:
            self: the trained model.
        """
the trained model.
the trained model .
self
self
X
np.ndarray
Y
np.ndarray
verbose
X (
`numpy.ndarray`): Input data with n rows and
m columns
` numpy . ndarray ` ) : Input data with n rows and m columns
Y (
`numpy.ndarray`): Output variable with binary
labels.
` numpy . ndarray ` ) : Output variable with binary labels .
verbose (
`bool`, optional): Specifies whether the
performances should be reported or not. Defaults to False.
` bool ` optional ) : Specifies whether the performances should be reported or not . Defaults to False .
** kwargs
Arbitrary keyword arguments.
Arbitrary keyword arguments .