Skip to content

Instantly share code, notes, and snippets.

@jamesrajendran
Created June 13, 2017 06:24
Show Gist options
  • Select an option

  • Save jamesrajendran/3e3c60c3f47e2262aff8794aa78d8ae9 to your computer and use it in GitHub Desktop.

Select an option

Save jamesrajendran/3e3c60c3f47e2262aff8794aa78d8ae9 to your computer and use it in GitHub Desktop.
from sklearn.datasets import load_iris
from sklearn.neighbors import KNeighborsClassifier
#Load the data
iris = load_iris()
type(iris)
print(iris)
print( iris.feature_names)
print(iris.target)
print(iris.target_names)
print(type(iris.data))
print(type(iris.target))
print(iris.data.shape)
print(iris.target.shape)
# Choose the features, lables from given data
# choose the algorithm
# fit/train the data
# predict the new data
X = iris.data
y = iris.target
knn = KNeighborsClassifier(n_neighbors=5)
knn.fit(X,y)
knn.predict([5.2, 3.6, 1.5, 0.3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment