utils¶
- class DataFrameFeature(*args, **kwargs)¶
Bases:
ProtocolA dataframe feature is a function that takes a
Trajectoryor anInstanceCollectionas input and returns aDataFrame.- Parameters:
trajectory (
Trajectory|InstanceCollection) – The trajectory or collection to compute the feature for. Parameter can also be calledcollection.*args – Additional positional arguments.
**kwargs – Additional keyword arguments.
- Returns:
The computed feature.
- Return type:
- class Feature(*args, **kwargs)¶
Bases:
ProtocolA feature is a function that takes a
Trajectoryor anInstanceCollectionas input and returns andarray.- Parameters:
trajectory (
Trajectory|InstanceCollection) – The trajectory or collection to compute the feature for. Parameter can also be calledcollection.*args – Additional positional arguments.
**kwargs – Additional keyword arguments.
- Returns:
The computed feature.
- Return type:
- feature_names(func, relational, dyadic=False, suffixes=None, **kwargs)¶
Generate full feature names for a given function.
- Parameters:
- Return type:
- Returns:
The full feature names.
- get_feature_names(func, **kwargs)¶
Entrypoint for feature name generation.
- Parameters:
func (
Feature) – The feature function to generate names for.**kwargs – Additional keyword arguments to pass to the feature function.
- Return type:
- Returns:
A list of feature names corresponding to the function.
See also
feature_names()to generate feature names, using:names()to generate feature names, or,relational_names()to generate feature names for relational features
- names(func_name, keypoints=None, keypoint_pairs=None)¶
Return the formatted feature names of a feature function, and a combination of keypoints and keypoint pairs.
- pair(keypoint_pair)¶
Return the formatted name of a keypoint pair.
- prune_feature_names(names, *, keep=None, discard=None)¶
Discard (or keep) feature names based on a list of names to keep or discard.
- Return type:
- Parameters:
- Parameters
names: The feature names to prune. keep: A list of feature name patterns to keep, irregardless of the match
discard. discard: A list of feature name patterns to discard.- Returns
A list of feature names after pruning.
- recursive_name(func)¶
Return the name of a feature function.
If the function is a
partial()(i.e., decorated), the name of the original function is returned.- Parameters:
func (
Feature|DataFrameFeature|partial) – The feature function to get the name of.- Return type:
- Returns:
The name of the feature function.
- relational_names(func_name, *, keypoints_1=None, keypoints_2=None, keypoint_pairs_1=None, keypoint_pairs_2=None, element_wise=False)¶
Return the formatted feature names of a relational feature function, and a combination of keypoints and keypoint pairs.
- Parameters:
func_name (
str) – The name of the feature function.keypoints_1 (
Iterable[int] |None, default:None) – The first set of keypoints indices.keypoints_2 (
Iterable[int] |None, default:None) – The second set of keypoints indices.keypoint_pairs_1 (
Iterable[tuple[int,int]] |None, default:None) – The first set of keypoint index pairs.keypoint_pairs_2 (
Iterable[tuple[int,int]] |None, default:None) – The second set of keypoint index pairs.element_wise (
bool|None, default:False) – Whether to return the names of the feature function for each element-wise combination of keypoints and keypoint pairs.
- Return type:
- Returns:
The formatted feature names.