---
url: /glossary.md
description: >-
  Definitions of relational machine learning terms: entity, foreign key, hop,
  aggregation, propositionalization, deep feature synthesis, cutoff time and
  more.
---

# Glossary of relational machine learning

**Short definitions of the terms used when a model learns from several
related tables, with how scikit-link names each one.** Terms are grouped by
topic; each has a stable link you can cite.

## Data

### Relational data {#relational-data}

Data split across several tables linked by keys, such as customers, their
orders and the products in each order. Each table stores one kind of thing
once, and keys say which rows belong together.

### Primary key {#primary-key}

The column, or set of columns, that identifies one row of a table, such as
`customer_id` in `customers`. In scikit-link, `Database(primary_keys=...)`.

### Foreign key {#foreign-key}

A column whose values are the primary key of another table, such as
`orders.customer_id`. The table that holds it is the **child**, the table it
points to the **parent**. In scikit-link a foreign key is a
**relationship**, written child first: `("orders.customer_id", "customers.customer_id")`.

### Orphan row {#orphan-row}

A child row whose foreign key matches no parent, such as an order of a deleted
customer. scikit-link refuses orphans by default and can keep them with
`orphans="warn"` or `"ignore"`.

### Entity {#entity}

The table whose rows you make predictions for, such as `customers` when you
predict churn per customer. In scikit-link, `entity="customers"`.

### Sample and population table {#population-table}

A **sample** is one prediction: an entity, and optionally a date. The
**population table**, `X` in scikit-learn terms, holds one row per sample with
the entity's key. The same customer can appear several times, once per
prediction date.

## Features from related rows

### Propositionalization {#propositionalization}

Turning relational data into one flat table with a row per sample, so that an
ordinary model can learn from it, usually by aggregating each sample's related
rows. Featuretools, getML's FastProp and scikit-link's `RelationalFeaturizer`
all propositionalize.

### Aggregation and primitive {#aggregation}

An **aggregation** summarizes the related rows of a sample in one value, such
as the number of orders or their mean amount. The function it applies is the
**primitive**: `count`, `mean`, `max`, `mode`, `last`, `trend`,
`time_since_last` and so on.

### Path and hop {#hop}

A **path** is the chain of relationships followed from the entity to the rows
being aggregated, such as `orders.order_items`. Each relationship followed is
one **hop**; scikit-link's `max_relationship_depth` caps the hops of a path.

### Lookup {#lookup}

A step from an aggregated row to the one parent row it points to, such as from
an order line to its product, to read a column there. It never adds rows to
the aggregate. scikit-link writes it inside a condition, as in
`count(orders.order_items[products.category == 'toys'])`, or in the
aggregated path, as in `mean(orders.order_items.products.price)`.

### Condition {#condition}

A filter on the rows an aggregate reads, such as express orders only:
`count(orders[type == 'express'])`. A **conditional aggregate** combines a
condition with an aggregation.

### Expression and canonical name {#canonical-name}

An **expression** is one computed value per sample, such as
`mean(orders.amount[type == 'express'])`. Its **canonical name** is that text:
it says exactly how the value is computed and parses back to the same
expression. See [how to read one](https://scikit-link.rodrigo-arenas.com/stable/getting-started/concepts#expressions-and-canonical-names).

### Deep Feature Synthesis {#deep-feature-synthesis}

The method popularized by Featuretools: stack aggregations and
transformations along relationships, up to a maximum depth, to generate many
candidate features automatically. See
[scikit-link as a Featuretools alternative](./compare/featuretools).

## Models

### Relational decision tree {#relational-decision-tree}

A decision tree whose questions are about related rows, such as "more than two
express orders above 100?". At each node it searches paths, aggregations and
conditions and keeps the question that best separates the labels, instead of
choosing from features computed in advance.
[Relational decision trees, explained](./blog/relational-decision-trees).

### Relational random forest {#relational-random-forest}

Many relational decision trees, each fitted on a bootstrap sample of `X` with
a random subset of candidate questions at each node, whose predictions are
averaged.

### Relational gradient boosting {#relational-gradient-boosting}

Shallow relational decision trees added one after another, each fitted to
correct the errors the previous trees left on the training samples. In
scikit-link, `RelationalGradientBoostingClassifier` and `Regressor`, which
take the parameters and losses of scikit-learn's `GradientBoosting*` and by
default grow Newton trees, which use the gradient and the Hessian of the loss
as XGBoost and LightGBM do.

### Relational clustering {#relational-clustering}

Grouping entities by their related rows, without a label. scikit-link's
`RelationalKMeans` runs k-means on aggregates of those rows;
`RelationalClusteringTree` asks relational questions chosen to make each
cluster tight, so every cluster is a rule such as `count(orders) > 2.5`.

### Relational anomaly detection {#relational-anomaly-detection}

Finding the entities whose related rows look unlike anyone else's, such as
a customer with a few very large orders, without a label.
scikit-link's `RelationalIsolationForest` runs scikit-learn's isolation
forest on aggregates of those rows.

### Relational deep learning {#relational-deep-learning}

Neural networks, usually graph neural networks, that learn from the rows and
links of a relational database directly. They lead benchmarks such as
RelBench and usually need a GPU.

## Time and leakage

### Cutoff time {#cutoff-time}

The moment a prediction is made. Only rows dated before it are visible to the
features. In scikit-link, a column of `X` named with `time=`.

### Label horizon {#label-horizon}

The window after the cutoff over which the label is measured, such as "no
order in the next 60 days". `TemporalCutoffSplit(label_horizon="60D")` keeps
training labels from overlapping the test period.

### Window {#window}

A period just before the cutoff that an aggregate is limited to, such as the
last 30 days: `windows=["30D"]` in `RelationalFeaturizer`.

### Data leakage {#data-leakage}

Information in training that would not be available at prediction time. In
multi-table data it comes from two places: rows dated after the cutoff, and
feature choices, such as frequent categories, learned on the test rows. See
[data leakage in multi-table features](./blog/leakage-multi-table-features).

### Temporal cross-validation {#temporal-cross-validation}

Cross-validation that trains on earlier cutoffs and tests on later ones, so
that every score measures predictions of the future. In scikit-link,
`TemporalCutoffSplit`.
