Skip to content

Commit 754e964

Browse files
authored
stats representation via plotly in to_viz interface (#335)
2 parents 05d5032 + 3de6cd3 commit 754e964

20 files changed

+592
-41
lines changed

THIRD_PARTY_LICENSES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ pandavro
229229
* Source code: https://github.com/ynqa/pandavro
230230
* Project home: https://github.com/ynqa/pandavro
231231

232+
plotly
233+
* Copyright (c) 2016-2018 Plotly, Inc
234+
* License: MIT License
235+
* Source code: https://github.com/plotly/plotly.py
236+
* Project home: https://plotly.com/
237+
232238
protobuf
233239
* Copyright 2008 Google Inc. All rights reserved.
234240
* License: Google Protobuf License

ads/feature_store/dataset.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from ads.feature_store.feature_group_expectation import Expectation
3939
from ads.feature_store.feature_option_details import FeatureOptionDetails
4040
from ads.feature_store.service.oci_dataset import OCIDataset
41-
from ads.feature_store.statistics import Statistics
41+
from ads.feature_store.statistics.statistics import Statistics
4242
from ads.feature_store.statistics_config import StatisticsConfig
4343
from ads.feature_store.service.oci_lineage import OCILineage
4444
from ads.feature_store.model_details import ModelDetails
@@ -164,7 +164,7 @@ def __init__(self, spec: Dict = None, **kwargs) -> None:
164164
self.oci_dataset = self._to_oci_dataset(**kwargs)
165165
self.lineage = OCILineage(**kwargs)
166166

167-
def _to_oci_dataset(self, **kwargs):
167+
def _to_oci_dataset(self, **kwargs) -> OCIDataset:
168168
"""Creates an `OCIDataset` instance from the `Dataset`.
169169
170170
kwargs
@@ -235,8 +235,8 @@ def name(self) -> str:
235235
return self.get_spec(self.CONST_NAME)
236236

237237
@name.setter
238-
def name(self, name: str) -> "Dataset":
239-
return self.with_name(name)
238+
def name(self, name: str):
239+
self.with_name(name)
240240

241241
def with_name(self, name: str) -> "Dataset":
242242
"""Sets the name.
@@ -1207,12 +1207,14 @@ def to_dict(self) -> Dict:
12071207
for key, value in spec.items():
12081208
if hasattr(value, "to_dict"):
12091209
value = value.to_dict()
1210-
if hasattr(value, "attribute_map"):
1211-
value = self.oci_dataset.client.base_client.sanitize_for_serialization(
1210+
if key == self.CONST_FEATURE_GROUP:
1211+
spec[
1212+
key
1213+
] = self.oci_dataset.client.base_client.sanitize_for_serialization(
12121214
value
12131215
)
1214-
spec[key] = value
1215-
1216+
else:
1217+
spec[key] = value
12161218
return {
12171219
"kind": self.kind,
12181220
"type": self.type,

ads/feature_store/docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ help:
1818
.PHONY: help Makefile
1919

2020
# Catch-all target: route all unknown targets to Sphinx using the new
21-
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
21+
# "make mode" option. $(O) is me`ant as a shortcut for $(SPHINXOPTS).
2222
%: Makefile
2323
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2424

ads/feature_store/docs/source/dataset.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,14 @@ The ``get_statistics()`` method takes the following optional parameter:
220220
221221
.. image:: figures/dataset_statistics.png
222222

223+
.. code-block:: python3
224+
225+
# Fetch and visualize stats for a dataset job
226+
df = dataset.get_statistics(job_id).to_viz()
227+
228+
.. image:: figures/dataset_statistics_viz.png
229+
230+
223231
.. seealso::
224232

225233
:ref:`Statistics`

ads/feature_store/docs/source/feature_group.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,13 @@ The ``get_statistics()`` method takes the following optional parameter:
254254
255255
.. image:: figures/stats_1.png
256256

257+
.. code-block:: python3
258+
259+
# Fetch and visualize stats for a dataset job
260+
df = feature_group.get_statistics(job_id).to_viz()
261+
262+
.. image:: figures/feature_group_statistics_viz.png
263+
257264
.. seealso::
258265

259266
:ref:`Statistics`
Loading
Loading

ads/feature_store/feature_group.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from ads.feature_store.service.oci_feature_group import OCIFeatureGroup
4545
from ads.feature_store.service.oci_feature_group_job import OCIFeatureGroupJob
4646
from ads.feature_store.service.oci_lineage import OCILineage
47-
from ads.feature_store.statistics import Statistics
47+
from ads.feature_store.statistics.statistics import Statistics
4848
from ads.feature_store.statistics_config import StatisticsConfig
4949
from ads.feature_store.validation_output import ValidationOutput
5050

@@ -244,8 +244,8 @@ def name(self) -> str:
244244
return self.get_spec(self.CONST_NAME)
245245

246246
@name.setter
247-
def name(self, name: str) -> "FeatureGroup":
248-
return self.with_name(name)
247+
def name(self, name: str):
248+
self.with_name(name)
249249

250250
def with_name(self, name: str) -> "FeatureGroup":
251251
"""Sets the name.
@@ -338,7 +338,7 @@ def transformation_kwargs(self, value: Dict):
338338
self.with_transformation_kwargs(value)
339339

340340
def with_transformation_kwargs(
341-
self, transformation_kwargs: Dict = {}
341+
self, transformation_kwargs: Dict = ()
342342
) -> "FeatureGroup":
343343
"""Sets the primary keys of the feature group.
344344
@@ -604,7 +604,6 @@ def with_statistics_config(
604604
FeatureGroup
605605
The FeatureGroup instance (self).
606606
"""
607-
statistics_config_in = None
608607
if isinstance(statistics_config, StatisticsConfig):
609608
statistics_config_in = statistics_config
610609
elif isinstance(statistics_config, bool):
@@ -1108,7 +1107,6 @@ def restore(self, version_number: int = None, timestamp: datetime = None):
11081107
f"RESTORE TABLE {target_table} TO VERSION AS OF {version_number}"
11091108
)
11101109
else:
1111-
iso_timestamp = timestamp.isoformat(" ", "seconds").__str__()
11121110
sql_query = f"RESTORE TABLE {target_table} TO TIMESTAMP AS OF {timestamp}"
11131111

11141112
restore_output = self.spark_engine.sql(sql_query)

ads/feature_store/statistics.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

ads/feature_store/statistics/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)