density_algs

nomad.stop_detection.density_algs.dbstop(data, dist_thresh, min_pts, time_thresh, dur_min=5, complete_output=False, passthrough_cols=None, keep_col_names=True, traj_cols=None, passthrough_agg=None, **kwargs)[source]

Temporal-augmented DBSCAN stop detection with summarization.

Parameters:
  • data (pd.DataFrame) – Input trajectory with spatial and temporal columns.

  • time_thresh (int) – Max time gap (minutes) for neighbors.

  • dist_thresh (float) – Max spatial distance for neighbors.

  • min_pts (int) – Minimum number of neighbors for a core point.

  • dur_min (int, optional) – Minimum duration (minutes) for a stop (default: 5).

  • complete_output (bool, optional) – Include extra stats if True (default: False).

  • passthrough_cols (list, optional) – Columns to retain per stop.

  • passthrough_agg (dict, optional) – Aggregation functions for selected passthrough columns.

  • traj_cols (dict, optional) – Mapping for column names.

  • **kwargs – Passed to internal helpers.

Returns:

One row per stop with medoid/centroid, duration, and optionally extra columns.

Return type:

pd.DataFrame

Raises:

ValueError if multi-user data detected; use dbstop_per_user instead. –

nomad.stop_detection.density_algs.dbstop_labels(data, dist_thresh, min_pts, time_thresh, return_cores=False, traj_cols=None, **kwargs)[source]

Return density-based stop labels.

Parameters:

return_cores (bool, default False) – Return core labels and promotion_time with cluster labels. promotion_time is the sweep time that propagates final membership.

Notes

promotion_time records approximate final-membership propagation time. For plotting, accent a ping at max(ping_time, promotion_time). Its raw value can show propagation edges from cores, including to later pings.

nomad.stop_detection.density_algs.dbstop_labels_per_user(data, dist_thresh, min_pts, time_thresh, return_cores=False, traj_cols=None, n_jobs=1, print_progress=False, **kwargs)[source]

Run dbstop_labels on each user separately and concatenate labels.

Raises if ‘user_id’ not in traj_cols or missing from data.

nomad.stop_detection.density_algs.dbstop_per_user(data, dist_thresh, min_pts, time_thresh, dur_min=5, complete_output=False, passthrough_cols=None, keep_col_names=True, traj_cols=None, n_jobs=1, print_progress=False, passthrough_agg=None, **kwargs)[source]

Run dbstop on each user separately, then concatenate results. Raises if ‘user_id’ not in traj_cols or missing from data.

nomad.stop_detection.density_algs.hdbscan_labels(data, time_thresh, min_pts=2, min_cluster_size=1, dur_min=5, delta_roam=None, dist_thresh=None, return_cores=False, traj_cols=None, **kwargs)[source]

Compute HDBSCAN cluster labels for trajectory data, with core/border assignment.

Parameters:
  • data (pd.DataFrame) – Input trajectory data.

  • time_thresh (int) – Maximum allowed time gap (minutes) for temporal neighbors.

  • min_pts (int, optional) – Minimum neighbors for a core point (default: 2).

  • min_cluster_size (int, optional) – Minimum cluster size for a valid stop (default: 1).

  • dur_min (int, optional) – Minimum duration (minutes) for a stop (default: 5).

  • return_cores (bool, default False) – Return core labels and promotion_time with cluster labels. Core pings use their own time; border pings use their propagating core time.

  • traj_cols (dict, optional) – Mapping for key columns.

  • **kwargs – Passed to internal helpers.

Returns:

Cluster labels, or cluster, core, and promotion_time when return_cores is true.

Return type:

pd.Series or pd.DataFrame

Notes

promotion_time records approximate final-membership propagation time. For plotting, accent a ping at max(ping_time, promotion_time). Its raw value can show propagation edges from cores, including to later pings.

nomad.stop_detection.density_algs.hdbscan_labels_per_user(data, time_thresh, min_pts=2, min_cluster_size=1, dur_min=5, delta_roam=None, return_cores=False, traj_cols=None, n_jobs=1, print_progress=False, **kwargs)[source]

Run hdbscan_labels on each user separately and concatenate labels.

Raises if ‘user_id’ not in traj_cols or missing from data.

nomad.stop_detection.density_algs.seqscan(data, dist_thresh, min_pts, time_thresh, dur_min=5, complete_output=False, passthrough_cols=None, keep_col_names=True, traj_cols=None, passthrough_agg=None, **kwargs)[source]

Temporal-augmented DBSCAN stop detection with summarization.

Parameters:
  • data (pd.DataFrame) – Input trajectory with spatial and temporal columns.

  • time_thresh (int) – Max time gap (minutes) for neighbors.

  • dist_thresh (float) – Max spatial distance for neighbors.

  • min_pts (int) – Minimum number of neighbors for a core point.

  • dur_min (int, optional) – Minimum duration (minutes) for a stop (default: 5).

  • complete_output (bool, optional) – Include extra stats if True (default: False).

  • passthrough_cols (list, optional) – Columns to retain per stop.

  • passthrough_agg (dict, optional) – Aggregation functions for selected passthrough columns.

  • traj_cols (dict, optional) – Mapping for column names.

  • **kwargs – Passed to internal helpers.

Returns:

One row per stop with medoid/centroid, duration, and optionally extra columns.

Return type:

pd.DataFrame

Raises:

ValueError if multi-user data detected; use ta_dbscan_per_user instead. –

nomad.stop_detection.density_algs.seqscan_labels(data, dist_thresh, dur_min=5, time_thresh=90, min_pts=3, user_id=None, return_cores=False, traj_cols=None, back_merge=False, **kwargs)[source]

Return SeqScan labels.

Parameters:

return_cores (bool, default False) – Return core labels and promotion_time with cluster labels. promotion_time is the scan time when final membership is retained.

Notes

promotion_time records approximate final-membership propagation time. For plotting, accent a ping at max(ping_time, promotion_time). Its raw value can show propagation edges from cores, including to later pings.

nomad.stop_detection.density_algs.seqscan_labels_per_user(data, dist_thresh, dur_min=5, time_thresh=90, min_pts=3, return_cores=False, traj_cols=None, back_merge=False, n_jobs=1, print_progress=False, **kwargs)[source]

Run seqscan_labels on each user separately and concatenate labels.

Raises if ‘user_id’ not in traj_cols or missing from data.

nomad.stop_detection.density_algs.seqscan_per_user(data, dist_thresh, min_pts, time_thresh, dur_min=5, complete_output=False, passthrough_cols=None, keep_col_names=True, traj_cols=None, n_jobs=1, print_progress=False, passthrough_agg=None, **kwargs)[source]

Run seqscan on each user separately, then concatenate results. Raises if ‘user_id’ not in traj_cols or missing from data.

nomad.stop_detection.density_algs.st_hdbscan(data, time_thresh, min_pts=2, min_cluster_size=1, dur_min=5, complete_output=False, passthrough_cols=None, traj_cols=None, passthrough_agg=None, **kwargs)[source]

HDBSCAN-based stop detection.

Parameters:
  • data (pd.DataFrame) – Input trajectory data.

  • time_thresh (int) – Maximum allowed time gap (minutes) for temporal neighbors.

  • min_pts (int, optional) – Minimum neighbors for a core point (default: 2).

  • min_cluster_size (int, optional) – Minimum cluster size for a valid stop (default: 1).

  • dur_min (int, optional) – Minimum duration (minutes) for a stop (default: 5).

  • complete_output (bool, optional) – If True, include extra stats.

  • passthrough_cols (list, optional) – Columns to passthrough to final stop table

  • passthrough_agg (dict, optional) – Aggregation functions for selected passthrough columns.

  • traj_cols (dict, optional) – Mapping for key columns.

  • **kwargs – Passed to internal helpers.

Returns:

Stop table

Return type:

pd.DataFrame

nomad.stop_detection.density_algs.st_hdbscan_per_user(data, time_thresh, min_pts=2, min_cluster_size=1, dur_min=5, complete_output=False, passthrough_cols=None, traj_cols=None, n_jobs=1, print_progress=False, passthrough_agg=None, **kwargs)[source]

Run HDBSCAN-based stop detection on each user separately, then concatenate results. Raises if ‘user_id’ not in traj_cols or missing from data.

nomad.stop_detection.density_algs.ta_dbscan(data, dist_thresh, min_pts, time_thresh, dur_min=5, remove_overlaps=True, complete_output=False, passthrough_cols=None, keep_col_names=True, traj_cols=None, passthrough_agg=None, **kwargs)[source]

Temporal-augmented DBSCAN stop detection with summarization.

Parameters:
  • data (pd.DataFrame) – Input trajectory with spatial and temporal columns.

  • time_thresh (int) – Max time gap (minutes) for neighbors.

  • dist_thresh (float) – Max spatial distance for neighbors.

  • min_pts (int) – Minimum number of neighbors for a core point.

  • dur_min (int, optional) – Minimum duration (minutes) for a stop (default: 5).

  • complete_output (bool, optional) – Include extra stats if True (default: False).

  • passthrough_cols (list, optional) – Columns to retain per stop.

  • passthrough_agg (dict, optional) – Aggregation functions for selected passthrough columns.

  • traj_cols (dict, optional) – Mapping for column names.

  • **kwargs – Passed to internal helpers.

Returns:

One row per stop with medoid/centroid, duration, and optionally extra columns.

Return type:

pd.DataFrame

Raises:

ValueError if multi-user data detected; use ta_dbscan_per_user instead. –

nomad.stop_detection.density_algs.ta_dbscan_labels(data, dist_thresh, min_pts, time_thresh, return_cores=False, remove_overlaps=True, traj_cols=None, **kwargs)[source]

Return temporal DBSCAN labels.

Parameters:

return_cores (bool, default False) – Return core labels and promotion_time with cluster labels. Core pings use their own time; border pings use their propagating core time.

Notes

promotion_time records approximate final-membership propagation time. For plotting, accent a ping at max(ping_time, promotion_time). Its raw value can show propagation edges from cores, including to later pings.

nomad.stop_detection.density_algs.ta_dbscan_labels_per_user(data, dist_thresh, min_pts, time_thresh, return_cores=False, remove_overlaps=True, traj_cols=None, n_jobs=1, print_progress=False, **kwargs)[source]

Run ta_dbscan_labels on each user separately and concatenate labels.

Raises if ‘user_id’ not in traj_cols or missing from data.

nomad.stop_detection.density_algs.ta_dbscan_per_user(data, dist_thresh, min_pts, time_thresh, dur_min=5, complete_output=False, passthrough_cols=None, traj_cols=None, n_jobs=1, print_progress=False, passthrough_agg=None, **kwargs)[source]

Run ta_dbscan on each user separately, then concatenate results. Raises if ‘user_id’ not in traj_cols or missing from data.

nomad.stop_detection.density_algs.window_graph(G, lo, hi)[source]