Add Feature Extraction Support for API Classifiers#77
Open
mohamedelabbas1996 wants to merge 12 commits intomainfrom
Open
Add Feature Extraction Support for API Classifiers#77mohamedelabbas1996 wants to merge 12 commits intomainfrom
mohamedelabbas1996 wants to merge 12 commits intomainfrom
Conversation
🔍 Existing Issues For ReviewYour pull request is modifying functions with the following pre-existing issues: 📄 File: trapdata/api/models/classification.py
Did you find this useful? React with a 👍 or 👎 |
mihow
reviewed
Apr 26, 2025
| ] | ||
|
|
||
| plotly = "^5.21.0" | ||
| scikit-learn = "^1.3.0" |
Collaborator
There was a problem hiding this comment.
I think we should make these optional dependencies and just use numpy in the tests. unless we need to use them in the core app.
[tool.poetry.extras]
dev = ["plotly", "scikit-learn"]
mihow
reviewed
Apr 26, 2025
mihow
reviewed
Apr 26, 2025
| model.eval() | ||
| return model | ||
|
|
||
| def get_features(self, batch_input: torch.Tensor) -> torch.Tensor: |
Collaborator
There was a problem hiding this comment.
Nice work on this method of extracting features! It seems more flexible than our current feature extractor. Perhaps we should add a comment in both feature extractors that the other one exists. And eventually update the old one to use this code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds support for returning model feature vectors (embeddings) alongside classification results in the Data Companion API.
The classification pipeline now supports returning a vector embedding per classification, derived from the classification model backbone.
The changes are fully backward-compatible for models that do not implement custom get_features(), as they will fallback to returning
Nonefrom the base class.Related Issues
#752
Screenshots
Detection features clustering visualization using K-means + PCA
