tusk
In nature, narwhals use their tusk to find mates.
In data science, you can use tusk to connect narwhals dataframes.
This package implements deep feature synthesis to automate feature engineering with the power of your favorite dataframe library. Powered by narwhals, inspired by featuretools.
Install
uv add tusk-ml
Usage
from datetime import datetime
import tusk
from tusk.primitives import Quantiles
db = tusk.Database("retail")
db.add_table("customers", customers_lf, primary_key="id", row_creation_time="signed_up_at")
db.add_table("sessions", sessions_lf, primary_key="id", row_creation_time="started_at")
db.add_table("transactions", tx_lf, primary_key="id", row_creation_time="occurred_at")
db.add_relationship(parent="customers", child="sessions", foreign_key="customer_id")
db.add_relationship(parent="sessions", child="transactions", foreign_key="session_id")
db.validate() # optional: confirm the keys really are keys, before you trust the numbers
feature_matrix, features = tusk.deep_feature_synthesis(
database=db,
target_table="customers",
agg_primitives=["mean", "count", Quantiles(qs=(0.25, 0.5, 0.75))],
trans_primitives=["month", "weekday"],
max_depth=2,
cutoff_time=datetime(2026, 1, 1),
)
feature_matrix comes back as an uncomputed query plan — tusk never collects —
so on a backend with a lazy frame type you get one back and decide when to
compute:
matrix = feature_matrix.collect()
features is a FeatureList — a sequence of inspectable definitions that
knows its target table and can re-apply itself to new data:
matrix = features.apply(db_new)
Documentation
Full documentation lives in docs/:
- Databases — tables, keys, relationships, and validating them against the data.
- Running DFS — depth, cutoff times, and the column naming scheme.
- Primitives — what ships with tusk and how it behaves.
- Custom primitives — the extension point.
- scikit-learn pipelines — DFS as a pipeline step, and computing only the features you keep.
- Differences from featuretools — if you are porting.
- API reference — every public symbol.
Build the site locally with:
uv run --group docs zensical serve
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tusk_ml-0.1.0.tar.gz.
File metadata
- Download URL: tusk_ml-0.1.0.tar.gz
- Upload date:
- Size: 38.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe0da06f6ff594dd92304a6a8db039199d78e83af2bda66806a2a74067de2404
|
|
| MD5 |
3a1d06cf4d350643ddd0abbe718eaf7d
|
|
| BLAKE2b-256 |
58d16735f66d434694b12adfc534843dd7a1ec410008dab462fa017a46828832
|
File details
Details for the file tusk_ml-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tusk_ml-0.1.0-py3-none-any.whl
- Upload date:
- Size: 47.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c8b534caf4717f637cdae9287426738e821328f6758f8525f16491f5f33f926
|
|
| MD5 |
b3a73e0d6fbb0ba4adcafe23ec48a7cd
|
|
| BLAKE2b-256 |
473a23c9b0870622ebe479eaaac3acfb9ea35147d0628914e604f391be15e60a
|