Open dragon28 opened 7 years ago
Ok, I went to https://zhuanlan.zhihu.com/p/25025596
and got the knn classifier code which was:
from sklearn import metrics
from sklearn.externals import joblib
X_train, X_test, y_train, y_test = train_test_split(X, train_y, test_size=.3, random_state=42)
# KNN Classifier
def knn_classifier(train_x, train_y):
from sklearn.neighbors import KNeighborsClassifier
model = KNeighborsClassifier()
model.fit(train_x, train_y)
return model
classifiers = knn_classifier
model = classifiers(X_train,y_train)
predict = model.predict(X_test)
accuracy = metrics.accuracy_score(y_test, predict)
print ('accuracy: %.2f%%' % (100 * accuracy) )
#保存模型
joblib.dump(model, 'knn.model')
however, there were several problem such as:
train_test_split function was not define X was not define train_y was not define
Thanks
Hi, I have the same issue, @dragon28 ,just uninstall scikit-learn version 0.19.0, then install 0.18.1 to solve this issue
@l-chenyao 感谢
Hello people,
Manage to get the code up and running which got the solution from https://github.com/shanren7/real_time_face_recognition/issues/1#issuecomment-318002762 @JIEMIN1995
but having some minor issue with scikit-learn version 0.18.1 to 0.19.0
I wonder how to do you guys pretrain or export the KNN model from scikit-learn? any resource or direction which you can point? @shanren7 mind point out the direction?
Thanks