build/lib/AutoMxL/Modelisation/Bagging.py
def predict(self, df):
        """Apply models fitted on sample to a  dataset.
        Combine models by averaging the outputs (for regression) or voting (for classification)

        Parameters
        ----------
        df : DataFrame
            Dataset to apply the model

        Returns
        -------
        numpy.ndarray (float)
            Averaged classification probabilities
        numpy.ndarray (int)
            Predictions for each observation
        """
        assert self.is_fitted, "Fit first !"
        # Init probs storage matrix
        mat_prob = np.zeros((self.niter, df.shape[0]))

        # for each fitted models
        for j in range(self.niter):
            # apply the model on test set
            y_prob_rf = self.list_model[j].predict_proba(df)
            # probabilities storage in matrix
            mat_prob[j] = y_prob_rf[:, 1]

        # probas averaging
        list_prob_pred = mat_prob.sum(axis=0) / self.niter
        # voting
        list_pred = [round(elem, 0) for elem in list_prob_pred]

        return list_prob_pred, list_pred
Apply models fitted on sample to a  dataset.
        Combine models by averaging the outputs (for regression) or voting (for classification)

        Parameters
        ----------
        df : DataFrame
            Dataset to apply the model

        Returns
        -------
        numpy.ndarray (float)
            Averaged classification probabilities
        numpy.ndarray (int)
            Predictions for each observation
        
Apply models fitted on sample to a  dataset.
Combine models by averaging the outputs (for regression) or voting (for classification)

Parameters

df : DataFrame
Dataset to apply the model

Returns

numpy.ndarray (float)
Averaged classification probabilities
numpy.ndarray (int)
Predictions for each observation
Apply models fitted on sample to a dataset . Combine models by averaging the outputs ( for regression ) or voting ( for classification ) Parameters df : DataFrame Dataset to apply the model Returns numpy . ndarray ( float ) Averaged classification probabilities numpy . ndarray ( int ) Predictions for each observation
def predict(self, df):
        assert self.is_fitted, "Fit first !"
        mat_prob = np.zeros((self.niter, df.shape[0]))
        for j in range(self.niter):
            y_prob_rf = self.list_model[j].predict_proba(df)
            mat_prob[j] = y_prob_rf[:, 1]
        list_prob_pred = mat_prob.sum(axis=0) / self.niter
        list_pred = [round(elem, 0) for elem in list_prob_pred]
        return list_prob_pred, list_pred
def predict ( self , df ) : assert self . is_fitted , "Fit first !" mat_prob = np . zeros ( ( self . niter , df . shape [ 0 ] ) ) for j in range ( self . niter ) : y_prob_rf = self . list_model [ j ] . predict_proba ( df ) mat_prob [ j ] = y_prob_rf [ : , 1 ] list_prob_pred = mat_prob . sum ( axis = 0 ) / self . niter list_pred = [ round ( elem , 0 ) for elem in list_prob_pred ] return list_prob_pred , list_pred
Apply models fitted on sample to a  dataset.
Apply models fitted on sample to a dataset .
"""Apply models fitted on sample to a  dataset.
        Combine models by averaging the outputs (for regression) or voting (for classification)

        Parameters
        ----------
        df : DataFrame
            Dataset to apply the model

        Returns
        -------
        numpy.ndarray (float)
            Averaged classification probabilities
        numpy.ndarray (int)
            Predictions for each observation
        """ # Init probs storage matrix # for each fitted models # apply the model on test set # probabilities storage in matrix # probas averaging # voting
self
df