Skip to main content

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/:

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

tusk_ml-0.1.2.tar.gz (38.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tusk_ml-0.1.2-py3-none-any.whl (47.8 kB view details)

Uploaded Python 3

File details

Details for the file tusk_ml-0.1.2.tar.gz.

File metadata

  • Download URL: tusk_ml-0.1.2.tar.gz
  • Upload date:
  • Size: 38.8 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

Hashes for tusk_ml-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d87708d6d07a4c394535d9dd927fc2ceb728f4c38cda540113f44552fa7d6912
MD5 804ed38ebbda1e2b6813ac384633be7d
BLAKE2b-256 d4898e3699734f24cce6a2f4c8e336aaaabae3a30037c6190a8784eed3ca00fd

See more details on using hashes here.

File details

Details for the file tusk_ml-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: tusk_ml-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 47.8 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

Hashes for tusk_ml-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 521ec611e0233f35068e95baccef9f60da1c8589505516a120e4c490118e1267
MD5 98cd012afc3262cef67708bf025ab2d6
BLAKE2b-256 d8783b42a93867d7209f1332988054089fe00dad15436b7770c1b44d90473579

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page