-
Notifications
You must be signed in to change notification settings - Fork 3
Support new interface assign_scores to VM dataset #407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AnilSorathiya
merged 8 commits into
main
from
anilsorathiya/sc-11453/support-new-interface-assign-score-assign
Aug 8, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ce58dbe
add assign score interface
AnilSorathiya 2e89294
unit tests for assign score
AnilSorathiya 3baf2d0
support list of value from unit metrics
AnilSorathiya 7201816
new tests and tutorial notebook
AnilSorathiya 54af207
rename from assign_score to assign_scores
AnilSorathiya e772bb3
add text that this feature supports unit_metrics
AnilSorathiya 4417dbb
2.9.0
AnilSorathiya 715dd01
Merge branch 'main' into anilsorathiya/sc-11453/support-new-interface…
AnilSorathiya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| __version__ = "2.8.31" | ||
| __version__ = "2.9.0" |
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
42 changes: 42 additions & 0 deletions
42
validmind/unit_metrics/classification/individual/AbsoluteError.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Copyright © 2023-2024 ValidMind Inc. All rights reserved. | ||
| # See the LICENSE file in the root of this repository for details. | ||
| # SPDX-License-Identifier: AGPL-3.0 AND ValidMind Commercial | ||
|
|
||
| from typing import List | ||
|
|
||
| import numpy as np | ||
|
|
||
| from validmind import tags, tasks | ||
| from validmind.vm_models import VMDataset, VMModel | ||
|
|
||
|
|
||
| @tasks("classification") | ||
| @tags("classification") | ||
| def AbsoluteError(model: VMModel, dataset: VMDataset, **kwargs) -> List[float]: | ||
| """Calculates the absolute error per row for a classification model. | ||
|
|
||
| For classification tasks, this computes the absolute difference between | ||
| the true class labels and predicted class labels for each individual row. | ||
| For binary classification with probabilities, it can also compute the | ||
| absolute difference between true labels and predicted probabilities. | ||
|
|
||
| Args: | ||
| model: The classification model to evaluate | ||
| dataset: The dataset containing true labels and predictions | ||
| **kwargs: Additional parameters (unused for compatibility) | ||
|
|
||
| Returns: | ||
| List[float]: Per-row absolute errors as a list of float values | ||
| """ | ||
| y_true = dataset.y | ||
| y_pred = dataset.y_pred(model) | ||
|
|
||
| # Convert to numpy arrays and ensure same data type | ||
| y_true = np.asarray(y_true) | ||
| y_pred = np.asarray(y_pred) | ||
|
|
||
| # For classification, compute absolute difference between true and predicted labels | ||
| absolute_errors = np.abs(y_true - y_pred) | ||
|
|
||
| # Return as a list of floats | ||
| return absolute_errors.astype(float).tolist() |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.