Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
gauss naive bayes
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.pipeline import make_pipeline
from sklearn.naive_bayes import GaussianNB
from sklearn.preprocessing import QuantileTransformer
from sklearn.metrics import roc_curve, auc
plt.style.use('bmh')
plt.rcParams['figure.figsize'] = (10, 10)
title_config = {'fontsize': 20, 'y': 1.05}
train = pd.read_csv('D:\\Documents\\Desktop\\train.csv')
X_train = train.iloc[:, 2:].values.astype('float64')
y_train = train['target'].values
pipeline = make_pipeline(QuantileTransformer(output_distribution='normal'), GaussianNB())
pipeline.fit(X_train, y_train)
fpr, tpr, thr = roc_curve(y_train, pipeline.predict_proba(X_train)[:,1])
plt.plot(fpr, tpr)
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver Operating Characteristic Plot', **title_config)
auc(fpr, tpr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment