Featurizers

A Featurizer is a structure that takes a set of trajectories and returns a feature matrix. The feature matrix is a 2D numpy array with shape (n_trajs, n_features).

This module contains the basic structures for creating featurizers along with the implementation of some of them which compute the most common features used in the literature.

class AccelerationChangeRateGlobalFeaturizer(zero_threshold=1e-12)

Featurizer that computes all the global features related to the acceleration change rate of the trajectory.

Parameters:

zero_threshold (float)

class AccelerationFeaturizer(zero_threshold=1e-12)

Compound featurizer that computes all the features related to the acceleration of the trajectory.

Parameters:

zero_threshold (float)

class AccelerationGlobalFeaturizer(zero_threshold=1e-12)

Featurizer that computes all the gloabl features related to the acceleration of the trajectory.

Parameters:

zero_threshold (float)

class AngleFeaturizer(zero_threshold=1e-12)

Compound featurizer that computes all the features related to the angles of the trajectory.

Parameters:

zero_threshold (float)

class AngleGlobalFeaturizer(zero_threshold=1e-12)

Featurizer that computes all the global features related to the angles of the trajectory.

Parameters:

zero_threshold (float)

class CompoundFeaturizer(*featurizers)

Gather multiple featurizers into one.

Parameters:

*featurizers (Featurizer) – The featurizers to gather.

featurizers_names()

Return the names of the featurizers.

Return type:

list[str]

property count: int

Number of features generated by this featurizer.

featurize(trajs)

Featurize a list of trajectories.

Parameters:

trajs (list[Trajectory]) – A list of trajectories.

Returns:

A numpy array of shape (n_traj, n_features).

Return type:

np.ndarray

class DisplacementFeaturizer(zero_threshold=1e-12)

Featurizer that computes the displacement of the trajectory.

Parameters:

zero_threshold (float)

property count: int

Number of features generated by this featurizer.

featurize(trajs)

Featurize a list of trajectories.

Parameters:

trajs (list[Trajectory]) – A list of trajectories.

Returns:

A numpy array of shape (n_trajs, n_features).

Return type:

np.ndarray

class DistanceFeaturizer(zero_threshold=1e-12)

Featurizer that computes the distance of the trajectory.

Parameters:

zero_threshold (float)

property count: int

Number of features generated by this featurizer.

featurize(trajs)

Featurize a list of trajectories.

Parameters:

trajs (list[Trajectory]) – A list of trajectories.

Returns:

A numpy array of shape (n_trajs, n_features).

Return type:

np.ndarray

class Featurizer(zero_threshold=1e-12)

Base class for featurizers.

A featurizer is a class that takes a set of trajectories and returns a feature matrix. The feature matrix is a 2D numpy array with shape (n_trajs, n_features)

Parameters:

zero_threshold (float, optional) – Threshold to check if a value is zero, by default DEFAULT_ZERO_THRESHOLD

is_zero(val)

Check if a value is zero using the zero threshold.

Parameters:

val (float)

Return type:

bool

abstract property count: int

Number of features generated by this featurizer.

abstract featurize(trajs)

Featurize a list of trajectories.

Parameters:

trajs (list[Trajectory]) – A list of trajectories.

Returns:

A numpy array of shape (n_trajs, n_features).

Return type:

np.ndarray

append(other)

Append another featurizer to this one.

Parameters:

other (Featurizer) – The featurizer to append.

Returns:

A new featurizer that is the concatenation of this one and the other one.

Return type:

CompundFeaturizer

class GlobalStatsFeaturizer(zero_threshold=1e-12)

Featurizer that extracts all the global features related to an array.

Statistics used:
  • mean

  • median

  • kurtoisis

  • autocorrelation coefficient

  • min

  • max

  • range

  • std

  • var

  • coeff of var

  • iqr

Parameters:

zero_threshold (float)

property count: int

Number of features generated by this featurizer.

featurize(trajs)

Featurize a list of trajectories.

Parameters:

trajs (list[Trajectory]) – A list of trajectories.

Returns:

A numpy array of shape (n_trajs, n_features).

Return type:

np.ndarray

class KineticFeaturizer(vel_stop_rate_threshold=1, vel_change_rate_threshold=1, zero_threshold=1e-12)

Compound featurizer that combines the spatial, velocity, acceleration, and angle featurizers.

Parameters:
  • vel_stop_rate_threshold (float)

  • vel_change_rate_threshold (float)

  • zero_threshold (float)

class SpatialFeaturizer(zero_threshold=1e-12)

Compound featurizer that computes all the global features related to the spatial characteristics of the trajectory.

Parameters:

zero_threshold (float)

class TimeFeaturizer(from_zero=True, zero_threshold=1e-12)

Compound featurizer that extracts all the features related to the time array of the trajectories

Parameters:
  • from_zero (bool)

  • zero_threshold (float)

class TimeGlobalFeaturizer(from_zero=True, zero_threshold=1e-12)

Featurizer that extracts all the gloabl features related to the time array of the trajectories

Parameters:
  • from_zero (bool, optional) – If True, the time array is shifted to start from zero, by default True.

  • zero_threshold (float)

class TimeJumpsGlobalFeaturizer(zero_threshold=1e-12)

Featurizer that extracts all the gloabl features related to the time intervals of the trajectories

Parameters:

zero_threshold (float)

class TurningAngleChangeRateGlobalFeaturizer(zero_threshold=1e-12)

Featurizer that computes all the global features related to the turning angle change rate of the trajectory.

Parameters:

zero_threshold (float)

class TurningAngleGobalFeaturizer(zero_threshold=1e-12)

Featurizer that computes all the global features related to the turning angles of the trajectory.

Parameters:

zero_threshold (float)

class UniversalFeaturizer(vel_stop_rate_threshold=1, vel_change_rate_threshold=1, time_from_zero=True, zero_threshold=1e-12)

A featurizer that combines all the featurizers in yupi.

Parameters:
  • vel_stop_rate_threshold (float)

  • vel_change_rate_threshold (float)

  • time_from_zero (bool)

  • zero_threshold (float)

class VelocityChangeRateFeaturizer(threshold=1)

Featurizer that computes the rate of changes of the velocity of the trajectory.

Parameters:

threshold (float) – The threshold to consider a change of velocity.

property count: int

Number of features generated by this featurizer.

featurize(trajs)

Featurize a list of trajectories.

Parameters:

trajs (list[Trajectory]) – A list of trajectories.

Returns:

A numpy array of shape (n_trajs, n_features).

Return type:

np.ndarray

class VelocityFeaturizer(stop_rate_threshold=1, change_rate_threshold=1, zero_threshold=1e-12)

Compound featurizer that computes all the features related to the velocity of the trajectory.

Parameters:
  • stop_rate_threshold (float) – The threshold to consider a stop.

  • change_rate_threshold (float) – The threshold to consider a change.

  • zero_threshold (float)

class VelocityGlobalFeaturizer(zero_threshold=1e-12)

Featurizer that computes all the global features related to the velocity of the trajectory.

Parameters:

zero_threshold (float)

class VelocityStopRateFeaturizer(threshold=1)

Featurizer that computes the rate of stops of the trajectory.

Parameters:

threshold (float) – The threshold below which the velocity is considered stopped.

property count: int

Number of features generated by this featurizer.

featurize(trajs)

Featurize a list of trajectories.

Parameters:

trajs (list[Trajectory]) – A list of trajectories.

Returns:

A numpy array of shape (n_trajs, n_features).

Return type:

np.ndarray