ageitgey / ageitgey/face_recognition
how to implement SVM inplace of KNN in face recognition
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 56.8k
- Forks
- 13.7k
- PR merge metrics
- No merged PRs in 30d
Description
I tried to implement SVM in place of KNN but got stuck. In KNN we compare the distance from the nearest neighbor with a threshold value. How to do these in SVM?
I made changes here.
svm_clf = SVC(gamma='auto', kernel='rbf', C=20)
svm_clf.fit(X, y)
but don't know what changes i need to do here:
closest_distances= knn_clf.kneighbors(faces_encodings, n_neighbors=1)
is_recognized = [closest_distances[0][i][0] <= DIST_THRESH for i in range(len(X_faces_loc))]
return [(pred, loc) if rec else ("N/A", loc) for pred, loc, rec in zip(knn_clf.predict(faces_encodings), X_faces_loc, is_recognized)]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the existing KNN recognition flow shown around knn_clf.kneighbors, DIST_THRESH, and knn_clf.predict, then compare it with the SVC setup using svm_clf.fit(X, y). Determine how recognition and rejection should work with the SVM approach; done means the face-recognition results preserve the expected prediction and location behavior without the KNN-only distance logic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100