scikit-link documentation
Use scikit-link when one prediction draws on several tables, such as a customer and their orders, a patient and their visits, or a machine and its sensor readings. Each row of X identifies one entity, and a Database holds the tables and the keys that connect them. The guides use a small shop of customers and orders because it is easy to follow; the same code works for any tables linked by keys.
You could compute such columns yourself with groupby and merge. scikit-link does it inside a scikit-learn pipeline, so each cross-validation fold learns its features only from its training rows, and with dates it uses only the rows that existed at each prediction date. Its trees can also learn which related rows to count, such as express orders above an amount, instead of using a fixed list of aggregates. New to the idea? Read what relational machine learning is.
Run your first model
- Install scikit-link with pandas.
- Fit a model on the shop dataset. The data comes with the package. By the end you can read the rule that predicts a customer's label.
- Learn the core ideas: the database, the entity table,
X, canonical names and cutoffs. - Describe your own database. Choose the table you predict for and connect a second table by its foreign key.
- Build
Xandyfrom your own tables: one row per prediction, and a label that does not leak.
How orders become features
A customer can appear on several order rows. To use order amounts in a customer model, follow the customer key and compute one value for that customer.
customers
| PKcustomer_id | country |
|---|---|
| c07 | CO |
| c12 | MX |
orders
| FKcustomer_id | amount |
|---|---|
| c07 | 24 |
| c12 | 42 |
| c07 | 36 |
features
| customer_id | mean_amount |
|---|---|
| c07 | 30 |
| c12 | 42 |
A featurizer does this calculation for a scikit-learn pipeline. A relational tree can also learn which orders to include in a split, for example only express orders above a certain amount.
Find what you need
/tutorials/Follow a case studyChurn, forecasts with intervals, segments and anomalies, end to end./case-studies/Look up a recipeLoad Parquet tables, tune a pipeline or export a tree./cookbook/API referenceLook up a constructor, method, parameter or plotting display./api/For terminology, read core concepts. If you already work with scikit-learn, use scikit-link with scikit-learn shows pipelines, searches, ensembles and transformers on the tables. If you use Featuretools, start with the migration guide.