Guest User

Untitled

a guest
Dec 16th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. // K-Nearest Neighbors
  2.  
  3. X_train = pd.DataFrame([ [0], [1], [2], [3] ])
  4. y_train = [0, 0, 1, 1]
  5. from sklearn.neighbors import KNeighborsClassifier
  6. model = KNeighborsClassifier(n_neighbors=3)
  7. model.fit(X_train, y_train)
  8. # You can pass in a dframe or an ndarray
  9. model.predict([[1.1]])
  10. model.predict_proba([[0.9]])
  11. #[[ 0.66666667 0.33333333]]
Add Comment
Please, Sign In to add comment