示例#1
0
 def pipeline(self):
     """
     :return: the roc auc score and the accuracy
     """
     self.train()
     y_pred = self.predict()
     roc_results(y_pred, self.y_test, 'XGBoost')
     return roc_auc_score(self.y_test, y_pred), results(y_pred, self.y_test)
示例#2
0
文件: lr.py 项目: jbitton/ml-project
 def pipeline(self):
     """
     :return: the roc auc score and the accuracy
     """
     self.train()
     y_pred_class = self.predict(threshold=0.436)
     y_pred = self.predict_probability()
     roc_results(y_pred[:, 1], self.y_test, 'Logistic Regression')
     return roc_auc_score(self.y_test,
                          y_pred[:, 1]), results(y_pred_class, self.y_test)
示例#3
0
文件: nb.py 项目: jbitton/ml-project
 def pipeline(self):
     """
     :return: the roc auc score and the accuracy
     """
     self.train()
     y_pred_class = self.predict()
     y_pred = self.predict_probability()
     roc_results(y_pred[:, 1], self.y_test, 'Gaussian Naive Bayes')
     return roc_auc_score(self.y_test,
                          y_pred[:, 1]), results(y_pred_class, self.y_test)
示例#4
0
def rf_pipeline(x_train, y_train, x_test, y_test):
    """
    :param x_train: the x-values we want to train on (2D numpy array)
    :param x_test: the y-values that correspond to x_train (1D numpy array)
    :param y_train: the x-values we want to test on (2D numpy array)
    :param y_test: the y-values that correspond to x_test (1D numpy array)
    :return: the roc auc score
    """
    clf = rf_training(x_train, y_train)
    y_pred = rf_classification(clf, x_test)
    roc_results(y_pred, y_test, 'Random Forest')
    return roc_auc_score(y_test, y_pred), results(y_pred, y_test)
def lr_pipeline(x_train, y_train, x_test, y_test):
    """
    :param x_train: the x-values we want to train on (2D numpy array)
    :param y_train: the y-values that correspond to x_train (1D numpy array)
    :param x_test:  the x-values we want to test on (2D numpy array)
    :param y_test:  the y-values that correspond to x_test (1D numpy array)
    :return: the roc auc score
    """
    prob = lr_training(x_train, y_train)
    y_pred = lr_probability(prob, x_test)
    y_pred_class = lr_classification(np.copy(y_pred[:, 1]), threshold=0.436)
    roc_results(y_pred[:, 1], y_test, 'Logistic Regression')
    return roc_auc_score(y_test, y_pred[:, 1]), results(y_pred_class, y_test)
def nb_pipeline(x_train, y_train, x_test, y_test):
    """
    :param x_train: the x-values we want to train on (2D numpy array)
    :param y_train: the y-values that correspond to x_train (1D numpy array)
    :param x_test:  the x-values we want to test on (2D numpy array)
    :param y_test:  the y-values that correspond to x_test (1D numpy array)
    :return: the roc auc score
    """
    prob = nb_training(x_train, y_train)
    y_pred = nb_probability(prob, x_test)
    y_pred_class = nb_classification(np.copy(y_pred[:, 1]))
    roc_results(y_pred[:, 1], y_test, 'Gaussian Naive Bayes')
    return roc_auc_score(y_test, y_pred[:, 1]), results(y_pred_class, y_test)