Skip to content

Commit 353eb45

Browse files
committed
to viz update for new mlm changes
1 parent 34c7de9 commit 353eb45

File tree

6 files changed

+38
-27
lines changed

6 files changed

+38
-27
lines changed

ads/feature_store/statistics/abs_feature_value.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818

1919
class AbsFeatureValue:
20+
CONST_METRIC_DATA = "metric_data"
21+
2022
def __init__(self):
2123
self.__validate__()
2224

ads/feature_store/statistics/charts/box_plot.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ def __init__(self, q1: float, q2: float, q3: float):
4545

4646
@classmethod
4747
def __from_json__(cls, json_dict: dict) -> "BoxPlot.Quartiles":
48+
metric_data = json_dict.get(AbsFeatureValue.CONST_METRIC_DATA)
4849
return cls(
49-
json_dict.get(cls.CONST_Q1),
50-
json_dict.get(cls.CONST_Q2),
51-
json_dict.get(cls.CONST_Q3),
50+
metric_data[0],
51+
metric_data[1],
52+
metric_data[2]
5253
)
5354

5455
def __validate__(self):

ads/feature_store/statistics/charts/frequency_distribution.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from typing import List
77
from ads.common.decorator.runtime_dependency import OptionalDependency
8+
from ads.feature_store.statistics.abs_feature_value import AbsFeatureValue
89
from ads.feature_store.statistics.charts.abstract_feature_plot import AbsFeaturePlot
910

1011
try:
@@ -29,21 +30,22 @@ def __init__(self, frequency: List, bins: List):
2930
def __validate__(self):
3031
assert type(self.frequency) == list
3132
assert type(self.bins) == list
32-
assert 0 < len(self.frequency) == len(self.bins) > 0
33+
# assert 0 < len(self.frequency) == len(self.bins) > 0
3334

3435
@classmethod
3536
def __from_json__(cls, json_dict: dict) -> "FrequencyDistribution":
37+
metric_data = json_dict.get(AbsFeatureValue.CONST_METRIC_DATA)
3638
return FrequencyDistribution(
37-
frequency=json_dict.get(cls.CONST_FREQUENCY),
38-
bins=json_dict.get(cls.CONST_BINS),
39+
bins=metric_data[0],
40+
frequency=metric_data[1]
3941
)
4042

4143
def add_to_figure(self, fig: Figure, xaxis: int, yaxis: int):
4244
xaxis_str, yaxis_str, x_str, y_str = self.get_x_y_str_axes(xaxis, yaxis)
4345
if (
44-
type(self.frequency) == list
45-
and type(self.bins) == list
46-
and 0 < len(self.frequency) == len(self.bins) > 0
46+
type(self.frequency) == list
47+
and type(self.bins) == list
48+
and 0 < len(self.frequency) and 0 < len(self.bins)
4749
):
4850
fig.add_bar(
4951
x=self.bins, y=self.frequency, xaxis=x_str, yaxis=y_str, name=""

ads/feature_store/statistics/charts/probability_distribution.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import List
66

77
from ads.common.decorator.runtime_dependency import OptionalDependency
8+
from ads.feature_store.statistics.abs_feature_value import AbsFeatureValue
89
from ads.feature_store.statistics.charts.abstract_feature_plot import AbsFeaturePlot
910

1011
try:
@@ -29,21 +30,22 @@ def __init__(self, density: List, bins: List):
2930
def __validate__(self):
3031
assert type(self.density) == list
3132
assert type(self.bins) == list
32-
assert 0 < len(self.density) == len(self.bins) > 0
33+
# assert 0 < len(self.density) == len(self.bins) > 0
3334

3435
@classmethod
3536
def __from_json__(cls, json_dict: dict) -> "ProbabilityDistribution":
37+
metric_data = json_dict.get(AbsFeatureValue.CONST_METRIC_DATA)
3638
return cls(
37-
density=json_dict.get(ProbabilityDistribution.CONST_DENSITY),
38-
bins=json_dict.get(ProbabilityDistribution.CONST_BINS),
39+
bins=metric_data[0],
40+
density=metric_data[1]
3941
)
4042

4143
def add_to_figure(self, fig: Figure, xaxis: int, yaxis: int):
4244
xaxis_str, yaxis_str, x_str, y_str = self.get_x_y_str_axes(xaxis, yaxis)
4345
if (
4446
type(self.density) == list
4547
and type(self.bins) == list
46-
and 0 < len(self.density) == len(self.bins) > 0
48+
and 0 < len(self.density) and 0 < len(self.bins)
4749
):
4850
fig.add_bar(
4951
x=self.bins,

ads/feature_store/statistics/charts/top_k_frequent_elements.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TopKFrequentElement(AbsFeatureValue):
3030
CONST_UPPER_BOUND = "upper_bound"
3131

3232
def __init__(
33-
self, value: str, estimate: int, lower_bound: int, upper_bound: int
33+
self, value: str, estimate: int, lower_bound: int, upper_bound: int
3434
):
3535
self.value = value
3636
self.estimate = estimate
@@ -53,26 +53,30 @@ def __from_json__(
5353
upper_bound=json_dict.get(cls.CONST_UPPER_BOUND),
5454
)
5555

56-
def __init__(self, elements: List[TopKFrequentElement]):
57-
self.elements = elements
56+
def __init__(self, values: List, estimates: List):
57+
self.values = values
58+
self.estimates = estimates
5859
super().__init__()
5960

6061
def __validate__(self):
61-
assert type(self.elements) == list
62-
assert len(self.elements) > 0
63-
for element in self.elements:
64-
assert element is not None
62+
assert type(self.values) == list
63+
assert type(self.estimates) == list
64+
assert 0 < len(self.values) == len(self.estimates) > 0
6565

6666
@classmethod
6767
def __from_json__(cls, json_dict: dict) -> "TopKFrequentElements":
68-
elements = json_dict.get(cls.CONST_VALUE)
69-
return cls([cls.TopKFrequentElement.from_json(element) for element in elements])
68+
metric_data = json_dict.get(AbsFeatureValue.CONST_METRIC_DATA)
69+
return cls(
70+
values=metric_data[0],
71+
estimates=metric_data[1]
72+
)
7073

7174
def add_to_figure(self, fig: Figure, xaxis: int, yaxis: int):
7275
xaxis_str, yaxis_str, x_str, y_str = self.get_x_y_str_axes(xaxis, yaxis)
73-
if type(self.elements) == list and len(self.elements) > 0:
74-
y_axis = [element.value for element in self.elements]
75-
x_axis = [element.estimate for element in self.elements]
76+
if type(self.values) == list and len(self.values) > 0 and \
77+
type(self.estimates) == list and len(self.estimates) > 0:
78+
y_axis = [value for value in self.values]
79+
x_axis = [estimate for estimate in self.estimates]
7680
fig.add_bar(
7781
x=x_axis, y=y_axis, xaxis=x_str, yaxis=y_str, name="", orientation="h"
7882
)

ads/feature_store/statistics/generic_feature_value.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ def __validate__(self):
1919
def __from_json__(cls, json_dict: dict) -> "GenericFeatureValue":
2020
val = None
2121
if type(json_dict) == dict:
22-
val = json_dict.get(cls.CONST_VALUE)
23-
22+
metric_data = json_dict.get(AbsFeatureValue.CONST_METRIC_DATA)
23+
val = metric_data[0]
2424
return GenericFeatureValue(val=val)

0 commit comments

Comments
 (0)