def fit(self, X, s, prob_s_eq_1=None, cv_n_folds=3):
        '''Train the classifier using X examples and s labels.
    
    Parameters
    ----------
    X : np.array
      Input feature matrix (N, D), 2D numpy array
      
    s : np.array
      A binary vector of labels, s, which may contain mislabeling
      
    prob_s_eq_1 : iterable (list or np.array)
      The probability, for each example, whether it is s==1 P(s==1|x). 
      If you are not sure, leave prob_s_eq_q = None (default) and
      it will be computed for you using cross-validation.
      
    cv_n_folds : int
      The number of cross-validation folds used to compute
      out-of-sample probabilities for each example in X.
    '''

        assert_inputs_are_valid(X, s, prob_s_eq_1)

        if prob_s_eq_1 is None:
            prob_s_eq_1 = cv_pred_proba(
                X=X,
                s=s,
                clf=self.clf,
                cv_n_folds=cv_n_folds,
            )

        if self.e1 is None:
            self.e1 = np.mean(prob_s_eq_1[s == 1])

        self.clf.fit(X, s)
    def fit(self, X, s, pulearning=None):
        '''
    Parameters
    ----------
    X : np.array
      Input feature matrix (N, D), 2D numpy array
      
    s : np.array
      A binary vector of labels, s, which may contain mislabeling
      
    pulearning : bool
      Set to True if you wish to perform PU learning. PU learning assumes 
      that positive examples are perfectly labeled (contain no mislabeling)
      and therefore frac_neg2pos = 0 (rh0 = 0). If
      you are not sure, leave pulearning = None (default).
    '''

        # Check if we are in the PU learning setting.
        if pulearning is None:
            pulearning = (self.rh0 == 0)

        assert_inputs_are_valid(X, s)

        # Set rh0 = 0 if no negatives exist in P.
        rh0 = 0.0 if pulearning else self.rh0
        rh1 = self.rh1

        alpha = float(1 - rh1 + rh0) / 2
        sample_weight = np.ones(np.shape(s)) * (1 - alpha)
        sample_weight[s == 0] = alpha
        self.clf.fit(X, s, sample_weight=sample_weight)
    def fit(
        self,
        X,
        s,
        pulearning=None,
        prob_s_eq_1=None,
        cv_n_folds=3,
    ):
        '''
    Parameters
    ----------
    X : np.array
      Input feature matrix (N, D), 2D numpy array
      
    s : np.array
      A binary vector of labels, s, which may contain mislabeling
      
    pulearning : bool
      Set to True if you wish to perform PU learning. PU learning assumes 
      that positive examples are perfectly labeled (contain no mislabeling)
      and therefore frac_neg2pos = 0 (rh0 = 0). If
      you are not sure, leave pulearning = None (default).
      
    prob_s_eq_1 : iterable (list or np.array)
      The probability, for each example, whether it is s==1 P(s==1|x). 
      If you are not sure, leave prob_s_eq_q = None (default) and
      it will be computed for you using cross-validation.
      
    cv_n_folds : int
      The number of cross-validation folds used to compute
      out-of-sample probabilities for each example in X.
    '''

        # Check if we are in the PU learning setting.
        if pulearning is None:
            pulearning = (self.rh0 == 0)

        assert_inputs_are_valid(X, s, prob_s_eq_1)

        # Set rh0 = 0 if no negatives exist in P.
        rh0 = 0.0 if pulearning else self.rh0
        rh1 = self.rh1

        if prob_s_eq_1 is None:
            prob_s_eq_1 = cv_pred_proba(
                X=X,
                s=s,
                clf=self.clf,
                cv_n_folds=cv_n_folds,
            )

        # Liu2016 using probabilities
        assert prob_s_eq_1 is not None, "Error: prob_s_eq_1 is None type."
        rho_s_opposite = np.ones(np.shape(prob_s_eq_1)) * rh0
        rho_s_opposite[s == 0] = rh1
        sample_weight = (prob_s_eq_1 -
                         rho_s_opposite) / prob_s_eq_1 / float(1 - rh1 - rh0)
        self.clf.fit(X, s, sample_weight=sample_weight)
    def fit(self, X, s):
        '''Train the classifier clf with s labels.
    
    X : np.array
      Input feature matrix (N, D), 2D numpy array
    s : np.array
      A binary vector of labels, s, which may contain mislabeling
    '''

        assert_inputs_are_valid(X, s)

        self.clf.fit(X, s)