import numpy as np
from sklearn import datasets
iris = datasets.load_iris()
list(iris.keys())
X = iris['data'][:, 3:] # (150, 1)
Y = (iris['target'] == 2).astype(np.int) # (150, )
from sklearn.linear_model import LogisticRegression
model = LogisticRegression()
model.fit(X, Y)
X_new = np.linspace(0, 3, 1000).reshape(-1, 1)
Y_proba = model.predict_proba(X_new) # (1000, 2)
import matplotlib.pyplot as plt
fig, ax = plt.subplots();
ax.plot(X_new, Y_proba[:, 1], 'g-', label='Iris virginica')
ax.plot(X_new, Y_proba[:, 0], 'b--', label='Not Iris virginica')