-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add first version of presets and report.
- Loading branch information
Showing
6 changed files
with
153 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,32 @@ | ||
import abc | ||
import dataclasses | ||
from typing import Dict | ||
from typing import List | ||
|
||
from evidently.model.widget import BaseWidgetInfo | ||
from evidently.v2.metrics import Metric | ||
from evidently.v2.metrics import MetricResult | ||
from evidently.v2.metrics.base import MetricId | ||
from evidently.v2.metrics.base import render_widgets | ||
from evidently.v2.report import Context | ||
|
||
|
||
@dataclasses.dataclass | ||
class PresetResult: | ||
widget: List[BaseWidgetInfo] | ||
|
||
def _repr_html_(self): | ||
return render_widgets(self.widget) | ||
|
||
|
||
class MetricPreset: | ||
def call(self, context: Context) -> PresetResult: | ||
return self.calculate({metric.id: context.calculate_metric(metric) for metric in self.metrics()}) | ||
|
||
@abc.abstractmethod | ||
def metrics(self) -> List[Metric]: | ||
raise NotImplementedError() | ||
|
||
@abc.abstractmethod | ||
def calculate(self, metric_results: Dict[MetricId, MetricResult]) -> PresetResult: | ||
raise NotImplementedError() |
This file contains 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