Skip to content
Snippets Groups Projects
Commit 136a8399 authored by Chauhan Chauhan's avatar Chauhan Chauhan
Browse files

Delete 3217-classification-lr-example1.py

parent 6e0645c2
Branches master
No related tags found
No related merge requests found
#Taken from Scikit
import matplotlib.pyplot as plt
from sklearn.linear_model import LogisticRegression
from sklearn import datasets
from sklearn.inspection import DecisionBoundaryDisplay
# import some data from a predefined datatset
iris = datasets.load_iris()
X = iris.data[:, :2] # we only take the first two features.
Y = iris.target
#print shape of the array for X and Y. Also get value of targets
print (X.shape)
print (Y)
print (Y.shape)
# Create an instance of Logistic Regression Classifier and fit the data.
logreg = LogisticRegression(C=1)
logreg.fit(X, Y)
_, ax = plt.subplots(figsize=(4, 3))
DecisionBoundaryDisplay.from_estimator(
logreg,
X,
cmap=plt.cm.Paired,
ax=ax,
response_method="auto",
plot_method="pcolormesh",
shading="auto",
xlabel="Sepal length",
ylabel="Sepal width",
eps=0.5,
)
# Plot the training points
plt.scatter(X[:, 0], X[:, 1], c=Y, edgecolors="k", cmap=plt.cm.Paired)
plt.xticks(())
plt.yticks(())
plt.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment