Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. # Import the neighbors classifier
  2. from sklearn.neighbors import KNeighborsClassifier
  3. import matplotlib.pyplot as plt
  4.  
  5. # Import LabelEncoder
  6. from sklearn import preprocessing
  7. #creating labelEncoder
  8. le = preprocessing.LabelEncoder()
  9.  
  10. #********************************
  11. # WE SHOULD PUT IN SOME DATA HERE
  12. #********************************
  13.  
  14. # converting string labels into numbers
  15. label=le.fit_transform(fish)
  16. features=list(zip(weight,length))
  17. model = KNeighborsClassifier(n_neighbors=5)
  18.  
  19. #********************************
  20. # NOW LET US TRAIN OUR MODEL
  21. #********************************
  22.  
  23. plt.scatter(weight, length, color="blue")
  24.  
  25. weight = float(input("Give a weight: "))
  26. length = float(input("Give a length: "))
  27.  
  28. plt.scatter(weight, length, color="green")
  29.  
  30. #Predict Output
  31. predicted= model.predict([[weight,length]])
  32. print(fish[predicted[0]])
  33. plt.savefig("fish.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement