vivainsights.identify_usage_segments

Segment employees into usage-based groups from collaboration metrics.

vivainsights.identify_usage_segments.identify_usage_segments(data, metric=None, metric_str=None, version='12w', return_type='data', threshold=None, width=None, max_window=None, power_thres=None)[source]

Segment employees into usage-based groups.

Classifies employees as Power User, Habitual User, Novice User, Low User, or Non-user based on rolling averages and habit detection.

Parameters:
  • data (pandas.DataFrame) – Person query data. Must include PersonId and MetricDate.

  • metric (str or None, default None) – Single metric column to classify.

  • metric_str (list of str or None, default None) – Multiple metric columns to aggregate before classification. Provide exactly one of metric or metric_str.

  • version (str or None, default "12w") – "12w" for 12-week rolling, "4w" for 4-week rolling, or None for custom parameters.

  • return_type (str, default "data") – "data" for a classified DataFrame, "plot" for a stacked bar chart, or "table" for a summary pivot table.

  • threshold (int or None, default None) – Habit identification threshold (required when version=None).

  • width (int or None, default None) – Habit width parameter (required when version=None).

  • max_window (int or None, default None) – Habit window parameter (required when version=None).

  • power_thres (float or None, default None) – Power-user threshold (required when version=None).

Returns:

Classified data, a stacked bar chart, or a summary table depending on return_type.

Return type:

pandas.DataFrame or matplotlib.figure.Figure

Examples

Classify usage segments using the 12-week preset:

>>> import vivainsights as vi
>>> pq_data = vi.load_pq_data()
>>> vi.identify_usage_segments(pq_data, metric="Emails_sent", version="12w")

Return a stacked bar chart:

>>> vi.identify_usage_segments(pq_data, metric="Emails_sent", version="12w", return_type="plot")

Return a summary table:

>>> vi.identify_usage_segments(pq_data, metric="Emails_sent", version="12w", return_type="table")

Use a metric string instead of a column name:

>>> vi.identify_usage_segments(pq_data, metric_str="Emails_sent", version="4w")
vivainsights.identify_usage_segments.plot_ts_us(data, cus, caption, figsize=None)[source]

Plot usage segments over time as a stacked bar chart.

Parameters:
  • data (pandas.DataFrame) – Dataset with usage segments and a MetricDate column.

  • cus (str) – Column name containing usage segment classifications.

  • caption (str) – Caption text displayed below the chart.

  • figsize (tuple or None, default None) – Figure size (width, height) in inches. Defaults to (8, 6).

Returns:

A stacked bar plot of usage segments over time.

Return type:

matplotlib.figure.Figure