Machine learning on multiple related tables, with the scikit-learn API.
Plenty of data lives in several tables: a customer and their orders, a
patient and their visits, a machine and its sensor readings, an account and
its transactions. scikit-link learns from those related rows directly. Put
one entity key per row in X, describe the tables and their keys in a
Database, and fit estimators that follow the keys inside ordinary
scikit-learn pipelines and cross-validation.
Website · Quickstart · Documentation · Case studies · Benchmarks · Comparison · Roadmap
Why scikit-link
- No hand-written joins and group-bys. The estimators compute aggregates
of the related rows themselves, such as
count(orders[type == 'express']), and relational trees learn which rows to count and with which conditions. - No leakage. Every fold of a cross-validation learns its features from
its own training rows, and a cutoff date per row of
Xhides the rows that happened after it. - Rules you can read. A relational tree prints its splits as questions
about the related tables, and
explainshows what one prediction used. - Everything you know from scikit-learn.
fit,predict,Pipeline,GridSearchCV, ensembles and threshold tuning work as usual, andRelationalFeaturizerfeeds any scikit-learn model, XGBoost or LightGBM.
Install
scikit-link requires Python 3.12 or later. Install it from PyPI:
pip install "scikit-link[pandas]"
The extra installs pandas, which the examples use; [polars] and [pyarrow]
are the other table formats. Numba installs with the package and compiles the
tree loops, with the same models. The distribution is called scikit-link and
the import is sklink.
Quickstart
from sklearn.ensemble import HistGradientBoostingClassifier
from sklearn.model_selection import cross_val_score
from sklearn.pipeline import make_pipeline
from sklink.datasets import make_relational_classification
from sklink.feature_extraction import RelationalFeaturizer
from sklink.inspection import export_text
from sklink.tree import RelationalDecisionTreeClassifier
# A Database of customers, orders, order items and products, and X with one
# row per customer. Build your own with sklink.Database(tables=...,
# primary_keys=..., relationships=[("orders.customer_id", "customers.customer_id")]).
db, X, likes_toys = make_relational_classification(
1000, signal="multihop", random_state=0
)
# The label hides a rule across tables: customers who buy toys (order items
# and their products) and placed an express order above 100 (orders).
orders = db.table("orders")
big_express = orders.query("type == 'express' and amount > 100")["customer_id"]
y = (likes_toys & X["customer_id"].isin(big_express)).astype(int)
# 1. Relational features for any scikit-learn estimator.
pipe = make_pipeline(
RelationalFeaturizer(db, entity="customers", key="customer_id"),
HistGradientBoostingClassifier(),
)
print(f"accuracy {cross_val_score(pipe, X, y, cv=5).mean():.3f}")
# 2. A decision tree that learns conditions across tables.
tree = RelationalDecisionTreeClassifier(
db, entity="customers", key="customer_id", max_depth=2, min_impurity_decrease=0.01
)
print(export_text(tree.fit(X, y)))
accuracy 0.959
|--- exists(orders[amount > 100.55 & type == 'express']) <= 0.500
| |--- class: 0
|--- exists(orders[amount > 100.55 & type == 'express']) > 0.500
| |--- proportion(orders.order_items[products.category == 'toys']) <= 0.100
| | |--- class: 0
| |--- proportion(orders.order_items[products.category == 'toys']) > 0.100
| | |--- class: 1
What you can do
| Task | How it works |
|---|---|
| Turn related rows into features for any estimator | RelationalFeaturizer aggregates the related rows of each entity into columns, such as the number of visits or the mean transaction amount, one row per sample, for any scikit-learn model. |
| Classify or regress directly on related tables | Relational decision trees, random forests and gradient boosting learn which related rows to aggregate while they fit. A split can ask whether an entity has any related row above a learned threshold within a learned category. |
| Cluster entities or find anomalies, without labels | RelationalKMeans and RelationalClusteringTree group entities by their related rows; RelationalIsolationForest ranks the entities whose related rows look unlike anyone else's. |
| Prepare the tables with scikit-learn | TransformedTablesEstimator fits scikit-learn transformers, such as a text embedding or a scaler, on the related rows that the training samples reach, and the model learns from the transformed tables. |
| Predict at a point in time without leakage | Give each sample a cutoff date so only earlier rows are used, and validate on later periods with TemporalCutoffSplit. Every fold learns its categories and thresholds from its training samples only. |
| Explain a prediction | sklink.inspection traces the decision path of one sample, groups feature importances by table or column, and exports fitted rules as text or JSON. |
| Plot the schema and the model | sklink.plotting draws the tables and keys, a fitted tree, importances and the path of one prediction, as in the gallery below. |
| Use the tables you already have | A Database takes pandas, Polars or PyArrow tables, dictionaries of NumPy columns, or Parquet file paths, read a few columns at a time to keep memory low on large tables. Composite keys, several levels of relationships and dated rows are supported. |
| Add your own aggregations | Register a custom primitive, such as the spread between the largest and smallest value, and request it by name. |
| Save and deploy a model | sklink.detach drops the tables before pickling, and sklink.rebind attaches fresh tables to score new entities. |
| Fit faster | The tree loops are compiled with Numba, which installs with the package, and n_jobs grows forest trees in parallel, with the same fitted model. |
The examples use a small shop, with customers, orders, order items and products, because it is easy to follow; the same code applies to any tables linked by keys.
Plot gallery
These four sklink.plotting displays use the customers and orders from
sklink.datasets.load_shop(). The target marks customers who placed at least
three orders. Select a figure for the full-size view or see how to create it
in the plotting reference.
|
Database schema |
Decision tree |
|
Feature importance |
One prediction |
Learn by example
- Churn from raw tables to a deployed model: monthly cutoffs, temporal cross-validation, explanations and deployment.
- scikit-learn ensembles and cost-based thresholds on relational models.
- Forecasts with calibrated prediction intervals from sensor readings and repair logs.
- Segments and anomalies without labels from bank transactions.
- Migrate from Featuretools if you use deep feature synthesis today.
How it compares
| scikit-link | Featuretools | getML community | skrub | |
|---|---|---|---|---|
| scikit-learn estimator API | Yes | Partial | No | Yes |
| Learns conditions inside aggregations | Yes | No | No | No |
| Native trees, forests and gradient boosting on related tables | Yes | No | No | No |
| Install on Windows and macOS without Docker | Yes | Yes | No | Yes |
skrub and scikit-link are meant to work together. The comparison page explains when to use each one, and the benchmarks compare scikit-link with gradient boosting on hand-built features, on the same splits and tuning budget.
Contribute
scikit-link is young, and contributions of every size help:
- Share your schema. Tell us about your tables and task in Discussions; real use cases decide what comes next.
- Report a bug or ask for a feature in Issues.
- Add an aggregation. A new primitive is a small, self-contained first pull request; see custom primitives.
- Add a benchmark dataset or a documentation example.
CONTRIBUTING.md covers the development setup, the checks and the testing policy. Security reports follow SECURITY.md. If scikit-link is useful to you, a star on GitHub helps others find it.
Citing
If scikit-link helps your research, please cite it. GitHub's "Cite this repository" button reads CITATION.cff; in BibTeX:
@software{arenas_scikit_link,
author = {Arenas, Rodrigo},
title = {scikit-link: Machine learning on multiple related tables, with the scikit-learn API},
year = {2026},
url = {https://github.com/rodrigo-arenas/scikit-link},
license = {MIT}
}
License
Metadata
Release files for scikit-link 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| scikit_link-0.1.0.tar.gz | 496.9 kB | With provenance | Details for scikit_link-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scikit_link-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for scikit_link-0.1.0-py3-none-any.whl |
Total release size: 883.0 kB
Release files / scikit_link-0.1.0.tar.gz
| Download URL | scikit_link-0.1.0.tar.gz |
|---|---|
| Size | 496.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e6b4b2550daf70a8d08ed2ff707a2c61a3bcc738bc5d200b7fd934366b61375c
|
|
BLAKE2b-256 checksum How to use checksums |
e89c1fb7aebb5b6e4884002a30a6fc76c597ae5f28a65bd2bbe17ce5fd80400b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logRelease files / scikit_link-0.1.0-py3-none-any.whl
| Download URL | scikit_link-0.1.0-py3-none-any.whl |
|---|---|
| Size | 386.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9d80b4aa3c0d228776e8f39a6fd24de54102f798c66e1de460ae108b974fd77c
|
|
BLAKE2b-256 checksum How to use checksums |
a3dda1936907e27c6281b6f1bfc0cc7b1adbdb2fe921794ce9fe5b3293efc0b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logSecurity for scikit-link 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for scikit_link-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.