Given a machine learning model built on top of scikit-learn, how can I classify new instances but then choose only those with the highest confidence? How do we define confidence in machine learning and how to generate it (if not generated automatically by scikit-learn)? What should I change in this approach if I had more that 2 potential classes?
This is what I have done so far:
# load libraries from sklearn import neighbors # initialize NearestNeighbor classifier knn = neighbors.KNeighborsClassifier(n_neighbors=3) # train model knn.fit([,,,,,], [0,0,0,1,1,1]) # predict ::: get class probabilities print(knn.predict_proba(1.5)) print(knn.predict_proba(37)) print(knn.predict_proba(3.5))