Logistic Regression
# import Logistic Regression
from sklearn.linear_model import LogisticRegression
# create logistic regression model
lr = LogisticRegression(C=1.0, random_state=0)
# C is inverse regulation parameter (smaller the stronger)
# train the model
lr.fit(X_train_std, y_train)
# predict the probabilities of the first sample
lr.predict_proba(X_test_std[0,:])
# plot using user-defined function
plot_decision_regions(X_combined_std,
y_combined, classifier=lr,
test_idx=range(105,150))
plt.xlabel('petal length [standardized]')
plt.ylabel('petal width [standardized]')
plt.legend(loc='upper left')
plt.show()