trajminer.preprocessing.TrajectorySegmenter

class trajminer.preprocessing.TrajectorySegmenter(attributes, thresholds=None, mode='strict', ignore_missing=False, n_jobs=1)

Trajectory segmenter.

attributesarray-like

The attributes of a trajectory dataset.

thresholdsdict (default=None)

A dictionary with callables for the attributes that will be used in the segmentation (e.g. dict[‘time’] is the callable for attribute time). A callable takes as input two attribute values and outputs True if the trajectory should be segmented and False otherwise.

For instance, suppose we have a dataset with a time attribute which represents the minutes from midnight when a trajectory point was recorded. If we’d like to segment trajectories every time there is a distance of more than 60 minutes between points, the callable for time would be defined as:

lambda x, y: abs(y - x) > 60 if y >= x else 60 * 24 - x + y > 60

If None, then trajectories are segmented whenever two attribute values are different (this behavior changes according to the mode parameter).

modestr (default=’strict’)

A string in {‘strict’, ‘any’}:

  • If ‘strict’, then trajectories are segmented when thresholds are True for all attributes.

  • If ‘any’, then trajectories are segmented when at least one threshold is True for any attribute.

ignore_missingbool (default=False)

If False, then trajectories are segmented whenever a missing value is found (this behavior changes according to the mode parameter).

n_jobsint (default=1)

The number of parallel jobs.

__init__(attributes, thresholds=None, mode='strict', ignore_missing=False, n_jobs=1)

Initialize self. See help(type(self)) for accurate signature.

fit_transform(X)

Fit and segment trajectories.

Xtrajminer.TrajectoryData

Input dataset to segment.

X_outtrajminer.TrajectoryData

Segmented dataset.