Feature Monitoring Configuration#
Yoou can create a feature monitoring configuration from a feature group using FeatureGroup.create_statistics_monitoring or FeatureGroup.create_feature_monitoring; and with FeatureView.create_statistics_monitoring or FeatureView.create_feature_monitoring to create it from a feature view. You can retrieve an existing feature monitoring configuration by calling FeatureGroup.get_feature_monitoring_configs and FeatureView.get_feature_monitoring_configs.
FeatureMonitoringConfig #
description property writable #
description: str | None
Description of the feature monitoring configuration.
detection_window_config property writable #
detection_window_config: mwc.MonitoringWindowConfig
Configuration for the detection window.
enabled property writable #
enabled: bool
Controls whether or not this config is spawning new feature monitoring jobs.
This field belongs to the scheduler configuration but is made transparent to the user for convenience.
feature_group_id property #
feature_group_id: int | None
Id of the Feature Group to which this feature monitoring configuration is attached.
feature_monitoring_type property #
feature_monitoring_type: str | None
The type of feature monitoring to perform. Used for internal validation.
Info
This property is read-only.
feature_name property #
feature_name: str | None
The name of the feature to monitor.
If not set, all features of the Feature Group or Feature View are monitored, only available for scheduled statistics.
Info
This property is read-only
feature_view_name property #
feature_view_name: str | None
Name of the Feature View to which this feature monitoring configuration is attached.
feature_view_version property #
feature_view_version: int | None
Version of the Feature View to which this feature monitoring configuration is attached.
job_schedule property writable #
job_schedule: JobSchedule
Schedule of the feature monitoring job.
This field belongs to the job configuration but is made transparent to the user for convenience.
name property writable #
name: str
The name of the feature monitoring config.
A Feature Group or Feature View cannot have multiple feature monitoring configurations with the same name. The name of a feature monitoring configuration is limited to 63 characters.
Info
This property is read-only once the feature monitoring configuration has been saved.
reference_window_config property writable #
reference_window_config: mwc.MonitoringWindowConfig
Configuration for the reference window.
statistics_comparison_config property writable #
Configuration for the comparison of detection and reference statistics.
compare_on #
compare_on(
metric: str | None,
threshold: float | None,
strict: bool | None = False,
relative: bool | None = False,
) -> FeatureMonitoringConfig
Sets the statistics comparison criteria for feature monitoring with a reference window.
Example
# Fetch your feature group or feature view
fg = fs.get_feature_group(name="my_feature_group", version=1)
# Setup feature monitoring, a detection window and a reference window
my_monitoring_config = fg.create_feature_monitoring(
...
).with_detection_window(...).with_reference_window(...)
# Choose a metric and set a threshold for the difference
# e.g compare the relative mean of detection and reference window
my_monitoring_config.compare_on(
metric="mean",
threshold=1.0,
relative=True,
).save()
Note
Detection window and reference window/value/training_dataset must be set prior to comparison configuration.
| PARAMETER | DESCRIPTION |
|---|---|
metric | The metric to use for comparison. Different metric are available for different feature type. TYPE: |
threshold | The threshold to apply to the difference to potentially trigger an alert. TYPE: |
strict | Whether to use a strict comparison (e.g. > or <) or a non-strict comparison (e.g. >= or <=). TYPE: |
relative | Whether to use a relative comparison (e.g. relative mean) or an absolute comparison (e.g. absolute mean). TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
FeatureMonitoringConfig |
|
delete #
delete()
Deletes the feature monitoring configuration.
Example
# Fetch your feature group or feature view
fg = fs.get_feature_group(name="my_feature_group", version=1)
# Fetch registered config by name
my_monitoring_config = fg.get_feature_monitoring_configs(name="my_monitoring_config")
# Delete the feature monitoring config
my_monitoring_config.delete()
| RAISES | DESCRIPTION |
|---|---|
`hopsworks.client.exceptions.FeatureStoreException` | If the feature monitoring config has not been saved. |
disable #
disable()
Disables the schedule of the feature monitoring job.
Example
# Fetch your feature group or feature view
fg = fs.get_feature_group(name="my_feature_group", version=1)
# Fetch registered config by name
my_monitoring_config = fg.get_feature_monitoring_configs(name="my_monitoring_config")
# Disable the feature monitoring config
my_monitoring_config.disable()
| RAISES | DESCRIPTION |
|---|---|
`hopsworks.client.exceptions.FeatureStoreException` | If the feature monitoring config has not been saved. |
enable #
enable()
Enables the schedule of the feature monitoring job.
The scheduler can be configured via the job_schedule property.
Example
# Fetch your feature group or feature view
fg = fs.get_feature_group(name="my_feature_group", version=1)
# Fetch registered config by name
my_monitoring_config = fg.get_feature_monitoring_configs(name="my_monitoring_config")
# Enable the feature monitoring config
my_monitoring_config.enable()
| RAISES | DESCRIPTION |
|---|---|
`hopsworks.client.exceptions.FeatureStoreException` | If the feature monitoring config has not been saved. |
get_history #
get_history(
start_time: datetime | date | str | int | None = None,
end_time: datetime | date | str | int | None = None,
with_statistics: bool = True,
) -> list[FeatureMonitoringResult]
Fetch the history of the computed statistics and comparison results for this configuration.
Example
# Fetch your feature group or feature view
fg = fs.get_feature_group(name="my_feature_group", version=1)
# Fetch registered config by name
my_monitoring_config = fg.get_feature_monitoring_configs(name="my_monitoring_config")
# Fetch the history of the computed statistics for this configuration
history = my_monitoring_config.get_history(
start_time="2021-01-01",
end_time="2021-01-31",
)
| PARAMETER | DESCRIPTION |
|---|---|
start_time | The start time of the time range to fetch the history for. |
end_time | The end time of the time range to fetch the history for. |
with_statistics | Whether to include the computed statistics in the results. TYPE: |
| RAISES | DESCRIPTION |
|---|---|
`hopsworks.client.exceptions.FeatureStoreException` | If the feature monitoring config has not been saved. |
get_job #
get_job()
Get the feature monitoring job which computes and compares statistics on the detection and reference windows.
Example
# Fetch registered config by name via feature group or feature view
my_monitoring_config = fg.get_feature_monitoring_configs(name="my_monitoring_config")
# Get the job which computes statistics on detection and reference window
job = my_monitoring_config.get_job()
# Print job history and ongoing executions
job.executions
Raises: hopsworks.client.exceptions.FeatureStoreException: If the feature monitoring config has not been saved.
| RETURNS | DESCRIPTION |
|---|---|
|
|
run_job #
run_job()
Trigger the feature monitoring job which computes and compares statistics on the detection and reference windows.
Example
# Fetch your feature group or feature view
fg = fs.get_feature_group(name="my_feature_group", version=1)
# Fetch registered config by name
my_monitoring_config = fg.get_feature_monitoring_configs(name="my_monitoring_config")
# Trigger the feature monitoring job once
my_monitoring_config.run_job()
Info
The feature monitoring job will be triggered asynchronously and the method will return immediately. Calling this method does not affect the ongoing schedule.
| RAISES | DESCRIPTION |
|---|---|
`hopsworks.client.exceptions.FeatureStoreException` | If the feature monitoring config has not been saved. |
| RETURNS | DESCRIPTION |
|---|---|
|
|
save #
save()
Saves the feature monitoring configuration.
Example
# Fetch your feature group or feature view
fg = fs.get_feature_group(name="my_feature_group", version=1)
# Setup feature monitoring and a detection window
my_monitoring_config = fg.create_statistics_monitoring(
name="my_monitoring_config",
).save()
| RETURNS | DESCRIPTION |
|---|---|
|
|
update #
update()
Updates allowed fields of the saved feature monitoring configuration.
Example
# Fetch your feature group or feature view
fg = fs.get_feature_group(name="my_feature_group", version=1)
# Fetch registered config by name
my_monitoring_config = fg.get_feature_monitoring_configs(name="my_monitoring_config")
# Update the percentage of rows to use when computing the statistics
my_monitoring_config.detection_window.row_percentage = 10
my_monitoring_config.update()
| RETURNS | DESCRIPTION |
|---|---|
|
|
with_detection_window #
with_detection_window(
time_offset: str | None = None,
window_length: str | None = None,
row_percentage: float | None = None,
) -> FeatureMonitoringConfig
Sets the detection window of data to compute statistics on.
Example
# Fetch your feature group or feature view
fg = fs.get_feature_group(name="my_feature_group", version=1)
# Compute statistics on a regular basis
fg.create_statistics_monitoring(
name="regular_stats",
cron_expression="0 0 12 ? * * *",
).with_detection_window(
time_offset="1d",
window_length="1d",
row_percentage=0.1,
).save()
# Compute and compare statistics
fg.create_feature_monitoring(
name="regular_stats",
feature_name="my_feature",
cron_expression="0 0 12 ? * * *",
).with_detection_window(
time_offset="1d",
window_length="1d",
row_percentage=0.1,
).with_reference_window(...).compare_on(...).save()
| PARAMETER | DESCRIPTION |
|---|---|
time_offset | The time offset from the current time to the start of the time window. TYPE: |
window_length | The length of the time window. TYPE: |
row_percentage | The fraction of rows to use when computing the statistics [0, 1.0]. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
FeatureMonitoringConfig |
|
with_reference_training_dataset #
with_reference_training_dataset(
training_dataset_version: int | None = None,
) -> FeatureMonitoringConfig
Sets the reference training dataset to compare statistics with.
See also with_reference_value(...) and with_reference_window(...) for other reference options.
Example
# Fetch your feature group or feature view
fg = fs.get_feature_group(name="my_feature_group", version=1)
# Setup feature monitoring and a detection window
my_monitoring_config = fg.create_feature_monitoring(...).with_detection_window(...)
# Only for feature views: Compare to the statistics computed for one of your training datasets
# particularly useful if it has been used to train a model currently in production
my_monitoring_config.with_reference_training_dataset(
training_dataset_version=3,
).compare_on(...).save()
Provide a comparison configuration
You must provide a comparison configuration via compare_on() before saving the feature monitoring config.
| PARAMETER | DESCRIPTION |
|---|---|
training_dataset_version | The version of the training dataset to use as reference. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
FeatureMonitoringConfig |
|
with_reference_value #
with_reference_value(
value: float | None = None,
) -> FeatureMonitoringConfig
Sets the reference value to compare statistics with.
See also with_reference_window(...) and with_reference_training_dataset(...) for other reference options.
Example
# Fetch your feature group or feature view
fg = fs.get_feature_group(name="my_feature_group", version=1)
# Setup feature monitoring and a detection window
my_monitoring_config = fg.create_feature_monitoring(...).with_detection_window(...)
# Simplest reference window is a specific value
my_monitoring_config.with_reference_value(
value=0.0,
).compare_on(...).save()
Provide a comparison configuration
You must provide a comparison configuration via compare_on() before saving the feature monitoring config.
| PARAMETER | DESCRIPTION |
|---|---|
value | A float value to use as reference. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
FeatureMonitoringConfig |
|
with_reference_window #
with_reference_window(
time_offset: str | None = None,
window_length: str | None = None,
row_percentage: float | None = None,
) -> FeatureMonitoringConfig
Sets the reference window of data to compute statistics on.
See also with_reference_value(...) and with_reference_training_dataset(...) for other reference options.
Example
# Fetch your feature group or feature view
fg = fs.get_feature_group(name="my_feature_group", version=1)
# Setup feature monitoring and a detection window
my_monitoring_config = fg.create_feature_monitoring(...).with_detection_window(...)
# Statistics computed on a rolling time window, e.g. same day last week
my_monitoring_config.with_reference_window(
time_offset="1w",
window_length="1d",
).compare_on(...).save()
Provide a comparison configuration
You must provide a comparison configuration via compare_on() before saving the feature monitoring config.
| PARAMETER | DESCRIPTION |
|---|---|
time_offset | The time offset from the current time to the start of the time window. TYPE: |
window_length | The length of the time window. TYPE: |
row_percentage | The percentage of rows to use when computing the statistics. Defaults to 20%. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
FeatureMonitoringConfig |
|