DRDataRaft/ docs
GitHub ↗

H22 Define the cancellation rate

H22A cancellation rate you can explain1 step

Use your current course session. Preparation and course runner · R script ↓

H22 Define the cancellation rate

Goal: Create a reusable metric.

Prerequisites: H21; dataraft.metrics.

The metric references the product ID. The product rule nonempty_denominator already blocks an empty population, rather than reporting a zero rate. Initially the metric is exploratory and not approved for frozen reports.

training_step(
  "H22",
  {
    cancellation_metric <- dataraft.metrics::dr_metric(
      "policies.cancellation_rate",
      "policies.cohort",
      expr = sum(in_cancellations) / sum(in_opening),
      dimensions = "broker_id",
      unit = "ratio",
      approved = FALSE
    )
    print(cancellation_metric)
  },
  needs = c("H21"),
  packages = c("dataraft.metrics")
)

Expected result: A definition with broker_id as an allowed grouping dimension.

Task: Has defining the metric calculated it?

Show solution

No. dr_measure executes it.

Search documentation

Search functions, packages and guides.