-
Notifications
You must be signed in to change notification settings - Fork 11
add eval capes to sdk #460
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
Open
luke-e-schaefer
wants to merge
11
commits into
master
Choose a base branch
from
add-eval-capabilities
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4c6083e
add eval capes to sdk
luke-e-schaefer 36f6b4a
Apply suggestion from @greptile-apps[bot]
luke-e-schaefer 3caaf8d
Apply suggestion from @greptile-apps[bot]
luke-e-schaefer 13a91b2
run hooks
luke-e-schaefer cce066e
merge remote
luke-e-schaefer aced4aa
Update nucleus/data_transfer_object/evaluation_v2.py
luke-e-schaefer 866ac71
fix p1
luke-e-schaefer 6582163
address comments
luke-e-schaefer ff6e671
Merge branch 'master' into add-eval-capabilities
luke-e-schaefer f88b665
fix lint
luke-e-schaefer cd38ab6
Merge branch 'add-eval-capabilities' of https://github.com/scaleapi/n…
luke-e-schaefer 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
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
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,162 @@ | ||
| """Response and filter models for Evaluation V2.""" | ||
|
|
||
| from typing import Any, Dict, List, Literal, Optional | ||
|
|
||
| from nucleus.pydantic_base import DictCompatibleModel | ||
|
|
||
|
|
||
| def _snake_to_camel(name: str) -> str: | ||
| parts = name.split("_") | ||
| if len(parts) == 1: | ||
| return name | ||
| return parts[0] + "".join(part.capitalize() for part in parts[1:]) | ||
|
|
||
|
|
||
| def _camelize_filter_value(value: Any) -> Any: | ||
| if isinstance(value, dict): | ||
| return { | ||
| _snake_to_camel(key): ( | ||
| val if key == "value" else _camelize_filter_value(val) | ||
| ) | ||
| for key, val in value.items() | ||
| } | ||
| if isinstance(value, list): | ||
| return [_camelize_filter_value(item) for item in value] | ||
| return value | ||
|
|
||
|
|
||
| class RangeNum(DictCompatibleModel): | ||
| min: Optional[float] = None | ||
| max: Optional[float] = None | ||
|
|
||
|
|
||
| class MetadataPredicate(DictCompatibleModel): | ||
| key: str | ||
| op: Literal["EQ", "IN", "GT", "LT"] | ||
| value: Optional[Any] = None | ||
|
|
||
|
|
||
| _FILTER_API_KEYS = { | ||
| "confidence_range": "confidenceRange", | ||
| "iou_range": "iouRange", | ||
| "pred_labels": "predLabels", | ||
| "gt_labels": "gtLabels", | ||
| "item_metadata": "itemMetadata", | ||
| "prediction_metadata": "predictionMetadata", | ||
| "label_equality": "labelEquality", | ||
| "has_ground_truth": "hasGroundTruth", | ||
| "tide_background": "tideBackground", | ||
| } | ||
|
|
||
|
|
||
| class EvaluationV2FilterArgs(DictCompatibleModel): | ||
| """Optional filters for :meth:`nucleus.evaluation_v2.EvaluationV2.charts` and :meth:`nucleus.evaluation_v2.EvaluationV2.examples`.""" | ||
|
|
||
| confidence_range: Optional[RangeNum] = None | ||
| iou_range: Optional[RangeNum] = None | ||
| pred_labels: Optional[List[str]] = None | ||
| gt_labels: Optional[List[str]] = None | ||
| item_metadata: Optional[List[MetadataPredicate]] = None | ||
| prediction_metadata: Optional[List[MetadataPredicate]] = None | ||
| label_equality: Optional[Literal["EQ", "NEQ"]] = None | ||
| has_ground_truth: Optional[bool] = None | ||
| tide_background: Optional[bool] = None | ||
|
|
||
| def to_api_filters(self) -> Dict[str, Any]: | ||
| """Return filters as a dict ready for API requests.""" | ||
| d = self.dict(exclude_none=True) | ||
| return { | ||
| api_key: _camelize_filter_value(d[snake_key]) | ||
| for snake_key, api_key in _FILTER_API_KEYS.items() | ||
| if snake_key in d | ||
| } | ||
|
|
||
|
|
||
| class MapSummary(DictCompatibleModel): | ||
| mapAt50: Optional[float] = None | ||
| mapAt75: Optional[float] = None | ||
| mapAt5095: Optional[float] = None | ||
|
|
||
|
|
||
| class PerClassAp(DictCompatibleModel): | ||
| classLabel: str | ||
| ap: float | ||
|
|
||
|
|
||
| class ConfusionEntry(DictCompatibleModel): | ||
| gtLabel: str | ||
| predLabel: str | ||
| count: int | ||
|
|
||
|
|
||
| class ScoreHistogramBucket(DictCompatibleModel): | ||
| bucketMin: float | ||
| bucketMax: float | ||
| count: int | ||
|
|
||
|
|
||
| class TotalCounts(DictCompatibleModel): | ||
| tp: int | ||
| fp: int | ||
| fn: int | ||
| predsWithConfidence: int | ||
|
|
||
|
|
||
| class ApBySize(DictCompatibleModel): | ||
| small: Optional[float] = None | ||
| medium: Optional[float] = None | ||
| large: Optional[float] = None | ||
|
|
||
|
|
||
| class PrCurvePoint(DictCompatibleModel): | ||
| classLabel: str | ||
| recall: float | ||
| precision: float | ||
|
|
||
|
|
||
| class TideAttribution(DictCompatibleModel): | ||
| truePositive: int | ||
| localization: int | ||
| classification: int | ||
| both: int | ||
| duplicate: int | ||
| background: int | ||
| missed: int | ||
|
|
||
|
|
||
| class EvaluationV2Charts(DictCompatibleModel): | ||
| mapSummary: MapSummary | ||
| perClassAp: List[PerClassAp] | ||
| confusionMatrix: List[ConfusionEntry] | ||
| scoreHistogram: List[ScoreHistogramBucket] | ||
| computedIouRanges: List[float] | ||
| totalCounts: TotalCounts | ||
| apBySize: ApBySize | ||
| prCurve: List[PrCurvePoint] | ||
| tideAttribution: TideAttribution | ||
|
|
||
|
|
||
| class EvaluationV2MatchExample(DictCompatibleModel): | ||
|
luke-e-schaefer marked this conversation as resolved.
|
||
| id: str | ||
| evaluation_id: str | ||
| dataset_item_id: str | ||
| model_prediction_id: Optional[str] = None | ||
| ground_truth_annotation_id: Optional[str] = None | ||
| pred_canonical_label: Optional[str] = None | ||
| gt_canonical_label: Optional[str] = None | ||
| pred_raw_label: Optional[str] = None | ||
| gt_raw_label: Optional[str] = None | ||
| iou: Optional[float] = None | ||
| confidence: Optional[float] = None | ||
| true_positive: bool | ||
| match_type: str | ||
| gt_area: Optional[float] = None | ||
| item_metadata: Optional[Dict[str, Any]] = None | ||
| prediction_metadata: Optional[Dict[str, Any]] = None | ||
|
luke-e-schaefer marked this conversation as resolved.
|
||
| prediction_row: Optional[Dict[str, Any]] = None | ||
| annotation_row: Optional[Dict[str, Any]] = None | ||
|
|
||
|
|
||
| class EvaluationV2ExamplesPage(DictCompatibleModel): | ||
| rows: List[EvaluationV2MatchExample] | ||
| total: int | ||
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.