DAY 8,PYTHON MACHINE LEARNING LOGISTIC REGRESSION

 # Train a logistic regression classifier to predict whether a flower is iris virginica or not

from sklearn import datasets

from sklearn.linear_model import LogisticRegression

import numpy as np

import matplotlib.pyplot as plt

iris = datasets.load_iris()

# print(list(iris.keys()))

# print(iris['data'].shape)

# print(iris['target'])

# print(iris['DESCR'])


X = iris["data"][:, 3:]

y = (iris["target"] == 2).astype(np.int)


# Train a logistic regression classifier

clf = LogisticRegression()

clf.fit(X,y)

example = clf.predict(([[2.6]]))

print(example)


# Using matplotlib to plot the visualization

X_new = np.linspace(0,3,1000).reshape(-1,1)

y_prob = clf.predict_proba(X_new)

print(y_prob)

plt.plot(X_new, y_prob[:,1], "g-", label="virginica")

plt.show()



# print(y)

# print(iris["data"])

# print(X)





Comments

Popular posts from this blog

java chapter11 practice question on abstruct class and interfaces

DAY 12 -AZURE DP900(Microsoft Azure Data Fundamentals: Explore non-relational data in Azure)

java exercise4