Features

Feature engineering utilities and decorators.

The features module provides built-in feature functions and a decorator for creating custom graph features.

unravel.utils.features.graph_feature(feature_type, is_custom=False)[source]

A decorator factory that returns a decorator function.

Parameters:
  • feature_type (Literal['edge', 'node']) – The type of feature (“edge” or “node”)

  • is_custom (bool) – Whether this is a custom feature

Returns:

A decorator function that will mark the decorated function

unravel.utils.features.x_normed(**kwargs)[source]
unravel.utils.features.y_normed(**kwargs)[source]
unravel.utils.features.speeds_normed(**kwargs)[source]
unravel.utils.features.velocity_components_2d_normed(**kwargs)[source]
from unravel.utils.features import graph_feature

@graph_feature(
    cols=["x", "y"],
    returns=["distance_from_center"],
    type="node"
)
def distance_from_center(x, y):
    import polars as pl
    return [pl.sqrt(x**2 + y**2)]

# Use in converter
from unravel.soccer import SoccerGraphConverter

converter = SoccerGraphConverter(
    dataset=polars_dataset,
    node_feature_cols=[distance_from_center],
)