Segment Overview
Interactive segment comparison heatmap for Jupyter notebooks.
Rows are metrics, columns are segment values. Click a cell to see that
metric's distribution for the segment; shift-click a second cell in the
same row to compare two distributions side by side. segment_col and
metrics are also editable from the widget's sidebar without
re-running the cell.
Usage
stream.segment_overview(
segment_col="plan",
metrics=[
{"metric": "length", "agg": "mean"},
{"metric": "event_count", "metric_args": {"events": "purchase"}, "agg": "mean"},
],
)
Parameters
Data
Data parameters change the computed result. They are exactly the arguments of
the widget's headless twin stream.segment_overview_data() — see
headless mode below.
No parameters.
Display
Display parameters only affect how the widget is rendered.
| Parameter | Type | Description |
|---|---|---|
segment_col | str, optional | Segment column to split by; must be one of schema.segment_cols. Required (directly or via the sidebar) before the widget computes anything. |
metrics | list of dict, optional | Metric configurations, each with a "metric" key, optional "metric_args", and an "agg" key ("mean", "median", "q5", "q25", "q75", "q95", or "complement_distance") controlling how per-path values roll up across a segment. See the Path Metrics documentation page for the metric reference. |
path_col | str, optional | Path ID column override; defaults to schema.path_col. |
height | int, default 480 | Widget height in pixels. |
sidebar_open | bool, default True | Whether the sidebar starts open. |
Headless mode
stream.segment_overview_data()
Compute aggregated metrics across segment values (headless).
Returns a DataFrame with metrics as rows and segment values as columns. Always includes segment_size and segment_share as first two rows.
Examples
Basic
stream.segment_overview(
segment_col="platform",
metrics=[
{"metric": "length", "agg": "mean"},
{"metric": "event_count", "metric_args": {"events": "purchase"}, "agg": "mean"},
],
)