Skip to content

Commit

Permalink
chore: Add batch_dedicated_resources parameter for feature attributio…
Browse files Browse the repository at this point in the history
…n spec in Model Monitoring SDK.

PiperOrigin-RevId: 631957771
  • Loading branch information
vertex-sdk-bot authored and Copybara-Service committed May 8, 2024
1 parent 378c68a commit 6150322
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions vertexai/resources/preview/ml_monitoring/spec/objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from google.cloud.aiplatform.compat.types import (
explanation_v1beta1 as explanation,
machine_resources_v1beta1 as machine_resources,
model_monitoring_alert_v1beta1 as model_monitoring_alert,
model_monitoring_spec_v1beta1 as model_monitoring_spec,
)
Expand Down Expand Up @@ -156,6 +157,11 @@ class FeatureAttributionSpec:
features=["feature1"]
default_alert_threshold=0.01,
feature_alert_thresholds={"feature1":0.02, "feature2":0.01},
batch_dedicated_resources=BatchDedicatedResources(
starting_replica_count=1,
max_replica_count=2,
machine_spec=my_machine_spec,
),
)
Attributes:
Expand All @@ -170,17 +176,23 @@ class FeatureAttributionSpec:
feature_alert_thresholds (Dict[str, float]):
Optional. Per feature alert threshold will override default alert
threshold.
batch_dedicated_resources (machine_resources.BatchDedicatedResources):
Optional. The config of resources used by the Model Monitoring during
the batch explanation for non-AutoML models. If not set, `n1-standard-2`
machine type will be used by default.
"""

def __init__(
self,
features: Optional[List[str]] = None,
default_alert_threshold: Optional[float] = None,
feature_alert_thresholds: Optional[Dict[str, float]] = None,
batch_dedicated_resources: Optional[machine_resources.BatchDedicatedResources] = None,
):
self.features = features
self.default_alert_threshold = default_alert_threshold
self.feature_alert_thresholds = feature_alert_thresholds
self.batch_dedicated_resources = batch_dedicated_resources

def _as_proto(
self,
Expand Down Expand Up @@ -216,6 +228,7 @@ def _as_proto(
default_alert_condition=user_default_alert_threshold,
feature_alert_conditions=user_alert_thresholds,
features=user_features,
batch_explanation_dedicated_resources=self.batch_dedicated_resources,
)
)

Expand Down

0 comments on commit 6150322

Please sign in to comment.