|
| 1 | +Statistics |
| 2 | +************* |
| 3 | + |
| 4 | +Feature Store provides functionality to compute statistics for feature groups & datasets and persist them along with the metadata. These statistics can help you |
| 5 | +to derive insights about the data quality. |
| 6 | + |
| 7 | +.. note:: |
| 8 | + |
| 9 | + Feature Store utilizes MLM Insights which is a Python API that helps evaluate & monitor data for entirety of ML Observability lifecycle. It performs data summarization which reduces a dataset into a set of descriptive statistics. |
| 10 | + |
| 11 | + |
| 12 | +Statistics Configuration |
| 13 | +======================== |
| 14 | +Computation of statistical metrics happens by default for all the features but you can configure it using ``StatisticsConfig`` object. This object can be passed at the creation of |
| 15 | +feature group or dataset or it can be later updated as well. |
| 16 | + |
| 17 | +.. code-block:: python3 |
| 18 | +
|
| 19 | + # Define statistics configuration for selected features |
| 20 | + stats_config = StatisticsConfig().with_is_enabled(True).with_columns(["column1", "column2"]) |
| 21 | +
|
| 22 | +
|
| 23 | +This can be used with feature group instance. |
| 24 | + |
| 25 | +.. code-block:: python3 |
| 26 | +
|
| 27 | + # Fetch stats results for a feature group job |
| 28 | + from ads.feature_store.feature_group import FeatureGroup |
| 29 | +
|
| 30 | + feature_group_resource = ( |
| 31 | + FeatureGroup() |
| 32 | + .with_feature_store_id(feature_store.id) |
| 33 | + .with_primary_keys(["<key>"]) |
| 34 | + .with_name("<name>") |
| 35 | + .with_entity_id(entity.id) |
| 36 | + .with_compartment_id(<compartment_id>) |
| 37 | + .with_schema_details_from_dataframe(<dataframe>) |
| 38 | + .with_statistics_config(stats_config) |
| 39 | +
|
| 40 | +Similarly for dataset instance. |
| 41 | + |
| 42 | +.. code-block:: python3 |
| 43 | +
|
| 44 | + from ads.feature_store.dataset import Dataset |
| 45 | +
|
| 46 | + dataset = ( |
| 47 | + Dataset |
| 48 | + .with_name("<dataset_name>") |
| 49 | + .with_entity_id(<entity_id>) |
| 50 | + .with_feature_store_id("<feature_store_id>") |
| 51 | + .with_description("<dataset_description>") |
| 52 | + .with_compartment_id("<compartment_id>") |
| 53 | + .with_dataset_ingestion_mode(DatasetIngestionMode.SQL) |
| 54 | + .with_query('SELECT col FROM <entity_id>.<feature_group_name>') |
| 55 | + .with_statistics_config(stats_config) |
| 56 | + ) |
| 57 | +
|
| 58 | +Statistics Results |
| 59 | +================== |
| 60 | +You can call the ``get_statistics()`` method of the FeatureGroup or Dataset instance to fetch validation results for a specific ingestion job. |
| 61 | + |
| 62 | +The ``get_statistics()`` method takes the following optional parameter: |
| 63 | + |
| 64 | +- ``job_id: string``. Id of feature group/dataset job |
| 65 | + |
| 66 | +.. code-block:: python3 |
| 67 | +
|
| 68 | + # Fetch stats results for a feature group job |
| 69 | + df = feature_group.get_statistics(job_id).to_pandas() |
| 70 | +
|
| 71 | +similarly for dataset instance |
| 72 | + |
| 73 | +.. code-block:: python3 |
| 74 | +
|
| 75 | + # Fetch stats results for a dataset job |
| 76 | + df = dataset.get_statistics(job_id).to_pandas() |
| 77 | +
|
| 78 | +.. image:: figures/stats_1.png |
0 commit comments