Created
June 13, 2017 06:24
-
-
Save jamesrajendran/3e3c60c3f47e2262aff8794aa78d8ae9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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