Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Import the neighbors classifier
- from sklearn.neighbors import KNeighborsClassifier
- import matplotlib.pyplot as plt
- # Import LabelEncoder
- from sklearn import preprocessing
- #creating labelEncoder
- le = preprocessing.LabelEncoder()
- #********************************
- # WE SHOULD PUT IN SOME DATA HERE
- #********************************
- # converting string labels into numbers
- label=le.fit_transform(fish)
- features=list(zip(weight,length))
- model = KNeighborsClassifier(n_neighbors=5)
- #********************************
- # NOW LET US TRAIN OUR MODEL
- #********************************
- plt.scatter(weight, length, color="blue")
- weight = float(input("Give a weight: "))
- length = float(input("Give a length: "))
- plt.scatter(weight, length, color="green")
- #Predict Output
- predicted= model.predict([[weight,length]])
- print(fish[predicted[0]])
- plt.savefig("fish.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement