In [ ]:
In [2]:
import numpy as np
import scipy as sp
import pandas as pd
import statsmodels.api as sm
import statsmodels.formula.api as smf
import sklearn as sk
import matplotlib as mpl
import matplotlib.pylab as plt
from mpl_toolkits.mplot3d import Axes3D
import seaborn as sns
sns.set()
sns.set_color_codes()
%matplotlib inline
%config InlineBackend.figure_format='png'
In [3]:
from sklearn.metrics import confusion_matrix
In [5]:
y_true = [2, 0, 2, 2, 0, 1]
y_predict = [2, 1, 2, 2, 2, 2]
confusion_matrix(y_true, y_predict)
Out[5]:
In [6]:
y_true = ["cat", "ant", "cat", "cat", "ant", "bird"]
y_pred = ["ant", "ant", "cat", "cat", "ant", "cat"]
confusion_matrix(y_true, y_pred, labels=["ant", "bird", "cat"])
Out[6]:
In [8]:
from sklearn.metrics import classification_report
In [11]:
y_true = [0, 1, 2, 2, 2]
y_pred = [0, 0, 2, 2, 1]
target_name = ["class 0", "class 1", "class 2"]
print(confusion_matrix(y_true, y_pred))
print(classification_report(y_true, y_pred, target_names = target_name))
In [34]:
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
X, y = make_classification(n_features=1, n_redundant=0, n_informative = 1, n_clusters_per_class = 1, random_state=4)
model = LogisticRegression().fit(X,y)
In [37]:
print(confusion_matrix(y,model.predict(X)))
In [38]:
print(classification_report(y,model.predict(X)))
In [41]:
from sklearn.metrics import roc_curve
fpr, tpr, thresholds = roc_curve(y, model.decision_function(X))
In [42]:
plt.plot(fpr, tpr)
Out[42]:
In [43]:
model.decision_function?
In [ ]: