Segment
Segment
Segment
Inherits all attributes from :class:`~fiddler.entities.CustomExpression`.
# High-value customer segment
high_value_segment = Segment(
name=”high_value_customers”,
model_id=model.id,
definition=”customer_lifetime_value > 10000 AND account_age_days > 365”,
description=”Customers with high LTV and established accounts”
).create()
# Geographic segment
west_coast_segment = Segment(
name=”west_coast_users”,
model_id=model.id,
definition=”state IN (‘CA’, ‘OR’, ‘WA’)”,
description=”Users from West Coast states”
).create()
# Risk-based segment
high_risk_segment = Segment(
name=”high_risk_applications”,
model_id=model.id,
definition=”credit_score < 600 OR debt_to_income > 0.4”,
description=”Loan applications with elevated risk factors”
).create()
# Age-based demographic segment
young_adults_segment = Segment(
name=”young_adults”,
model_id=model.id,
definition=”age >= 18 AND age <= 35”,
description=”Young adult demographic (18-35 years)”
).create()
# Use segment in alert rule for targeted monitoring
segment_alert = AlertRule(
name=”high_value_drift_alert”,
model_id=model.id,
metric_id=”drift_score”,
priority=Priority.HIGH,
compare_to=CompareTo.BASELINE,
condition=AlertCondition.GT,
bin_size=BinSize.HOUR,
critical_threshold=0.7,
baseline_id=baseline.id,
segment_id=high_value_segment.id
).create()Last updated
Was this helpful?