---
url: /dev/api.md
description: >-
  Every public class and function of scikit-link, grouped by what you use it
  for, with links to the reference generated from docstrings.
---

# API reference

**Look up parameters, return values and examples by class or function.**
To fit your first model, follow the
[shop quickstart](../getting-started/quickstart).
If you already have a fitted model, [inspect its rules](#inspection) or
[plot a prediction](#plotting).

## Data

Describe tables, keys and relationships.

| Object | Module | Summary |
| --- | --- | --- |
| [`ColumnSchema`](./sklink.database#sklink.database.ColumnSchema) | `sklink.database` | Name and types of one column. |
| [`Database`](./sklink.database#sklink.database.Database) | `sklink.database` | Immutable, validated relational database used by scikit-link estimators. |
| [`DetachedDatabase`](./sklink.database#sklink.database.DetachedDatabase) | `sklink.database` | Placeholder left by `detach`: keeps the schema, holds no data. |
| [`Relationship`](./sklink.database#sklink.database.Relationship) | `sklink.database` | A foreign key of a child table that references the primary key of a parent. |
| [`Schema`](./sklink.database#sklink.database.Schema) | `sklink.database` | Immutable, data-free description of a database. |
| [`SemanticType`](./sklink.database#sklink.database.SemanticType) | `sklink.database` | Semantic type of a column, which decides the primitives that apply to it. |
| [`TableSchema`](./sklink.database#sklink.database.TableSchema) | `sklink.database` | Columns, primary key and optional time column of one table. |
| [`detach()`](./sklink.database#sklink.database.detach) | `sklink.database` | Return a copy of a model in which every database keeps only its schema. |
| [`rebind()`](./sklink.database#sklink.database.rebind) | `sklink.database` | Return a copy of a model that uses `database` instead of its current one. |

## Features

Turn related tables into columns for any estimator.

| Object | Module | Summary |
| --- | --- | --- |
| [`RelationalFeaturizer`](./sklink.feature_extraction#sklink.feature_extraction.RelationalFeaturizer) | `sklink.feature_extraction` | Turn a population table into a flat matrix of relational features. |

## Models

Trees, forests, gradient boosting and isolation forests on related tables.

| Object | Module | Summary |
| --- | --- | --- |
| [`RelationalDecisionTreeClassifier`](./sklink.tree#sklink.tree.RelationalDecisionTreeClassifier) | `sklink.tree` | Decision tree classifier whose questions can aggregate related tables. |
| [`RelationalDecisionTreeRegressor`](./sklink.tree#sklink.tree.RelationalDecisionTreeRegressor) | `sklink.tree` | Decision tree regressor whose questions can aggregate related tables. |
| [`RelationalTree`](./sklink.tree#sklink.tree.RelationalTree) | `sklink.tree` | Fitted tree structure as parallel arrays, one entry per node. |
| [`SplitCandidates`](./sklink.tree#sklink.tree.SplitCandidates) | `sklink.tree` | Best questions scored at the split nodes of a tree, the chosen one first. |
| [`RelationalGradientBoostingClassifier`](./sklink.ensemble#sklink.ensemble.RelationalGradientBoostingClassifier) | `sklink.ensemble` | Gradient boosting of relational decision trees for classification. |
| [`RelationalGradientBoostingRegressor`](./sklink.ensemble#sklink.ensemble.RelationalGradientBoostingRegressor) | `sklink.ensemble` | Gradient boosting of relational decision trees for regression. |
| [`RelationalIsolationForest`](./sklink.ensemble#sklink.ensemble.RelationalIsolationForest) | `sklink.ensemble` | Isolation forest that finds unusual entities from their related rows. |
| [`RelationalRandomForestClassifier`](./sklink.ensemble#sklink.ensemble.RelationalRandomForestClassifier) | `sklink.ensemble` | Random forest of relational decision tree classifiers. |
| [`RelationalRandomForestRegressor`](./sklink.ensemble#sklink.ensemble.RelationalRandomForestRegressor) | `sklink.ensemble` | Random forest of relational decision tree regressors. |

## Clustering

Group entities by their related rows, without labels.

| Object | Module | Summary |
| --- | --- | --- |
| [`RelationalClusteringTree`](./sklink.cluster#sklink.cluster.RelationalClusteringTree) | `sklink.cluster` | Clustering tree: clusters of entities defined by relational questions. |
| [`RelationalKMeans`](./sklink.cluster#sklink.cluster.RelationalKMeans) | `sklink.cluster` | K-means clustering of the entities of a multi-table database. |

## Composition

Fit scikit-learn transformers on the tables of a database.

| Object | Module | Summary |
| --- | --- | --- |
| [`TransformedTablesEstimator`](./sklink.compose#sklink.compose.TransformedTablesEstimator) | `sklink.compose` | Fit scikit-learn transformers on tables of the database, then an estimator. |

## Evaluation

Validation for temporal data.

| Object | Module | Summary |
| --- | --- | --- |
| [`TemporalCutoffSplit`](./sklink.model_selection#sklink.model_selection.TemporalCutoffSplit) | `sklink.model_selection` | Time-ordered cross-validation over the cutoff column of `X`. |

## Inspection

Read, explain and export fitted models.

| Object | Module | Summary |
| --- | --- | --- |
| [`aggregate_importances()`](./sklink.inspection#sklink.inspection.aggregate_importances) | `sklink.inspection` | Group the importances of a relational model by table, column or primitive. |
| [`describe_expressions()`](./sklink.inspection#sklink.inspection.describe_expressions) | `sklink.inspection` | List what each expression of a fitted model reads from the database. |
| [`explain()`](./sklink.inspection#sklink.inspection.explain) | `sklink.inspection` | Explain the predictions of a relational tree or ensemble for some samples. |
| [`export_dict()`](./sklink.inspection#sklink.inspection.export_dict) | `sklink.inspection` | Describe a fitted relational tree, forest or boosting model with JSON types. |
| [`export_json()`](./sklink.inspection#sklink.inspection.export_json) | `sklink.inspection` | Write `export_dict` as JSON text. |
| [`export_text()`](./sklink.inspection#sklink.inspection.export_text) | `sklink.inspection` | Build a text report of the rules of a fitted relational tree. |

## Plotting

Draw a schema, a fitted model or one prediction.

| Object | Module | Summary |
| --- | --- | --- |
| [`CutoffSplitDisplay`](./sklink.plotting#sklink.plotting.CutoffSplitDisplay) | `sklink.plotting` | Which cutoffs train and which test in each split of a cross-validation. |
| [`ExplanationDisplay`](./sklink.plotting#sklink.plotting.ExplanationDisplay) | `sklink.plotting` | Why one sample got its prediction. |
| [`ForestDisplay`](./sklink.plotting#sklink.plotting.ForestDisplay) | `sklink.plotting` | How a relational random forest or gradient boosting model fitted. |
| [`ImportanceDisplay`](./sklink.plotting#sklink.plotting.ImportanceDisplay) | `sklink.plotting` | How the importance of a model flows from tables to columns to primitives. |
| [`LiveFit`](./sklink.plotting#sklink.plotting.LiveFit) | `sklink.plotting` | Draw the progress of `fit` while it runs, and the model when it ends. |
| [`SchemaDisplay`](./sklink.plotting#sklink.plotting.SchemaDisplay) | `sklink.plotting` | Tables, keys and relationships of a database, as given to a model. |
| [`SearchDisplay`](./sklink.plotting#sklink.plotting.SearchDisplay) | `sklink.plotting` | The questions a relational tree scored at one node, the chosen one first. |
| [`TreeDisplay`](./sklink.plotting#sklink.plotting.TreeDisplay) | `sklink.plotting` | Relational decision tree, drawn from `export_dict`. |

## Datasets

Synthetic problems with known rules and a small example database.

| Object | Module | Summary |
| --- | --- | --- |
| [`load_shop()`](./sklink.datasets#sklink.datasets.load_shop) | `sklink.datasets` | Load the small shop database bundled with the package. |
| [`make_relational_classification()`](./sklink.datasets#sklink.datasets.make_relational_classification) | `sklink.datasets` | Generate a relational classification problem with a known rule. |
| [`make_relational_regression()`](./sklink.datasets#sklink.datasets.make_relational_regression) | `sklink.datasets` | Generate a relational regression problem with a known target formula. |

## Extending

Primitives, expressions and the evaluation engine.

| Object | Module | Summary |
| --- | --- | --- |
| [`KernelContext`](./sklink.primitives#sklink.primitives.KernelContext) | `sklink.primitives` | Extra information a kernel may need besides the rows it aggregates. |
| [`Primitive`](./sklink.primitives#sklink.primitives.Primitive) | `sklink.primitives` | Description of an aggregation primitive. |
| [`default_primitives()`](./sklink.primitives#sklink.primitives.default_primitives) | `sklink.primitives` | Primitives generated by default for a column of the given semantic type. |
| [`get_kernel()`](./sklink.primitives#sklink.primitives.get_kernel) | `sklink.primitives` | Return the implementation of a primitive for a backend (NumPy fallback). |
| [`get_primitive()`](./sklink.primitives#sklink.primitives.get_primitive) | `sklink.primitives` | Return a registered primitive by name. |
| [`list_primitives()`](./sklink.primitives#sklink.primitives.list_primitives) | `sklink.primitives` | Names of the registered primitives, sorted. |
| [`register_primitive()`](./sklink.primitives#sklink.primitives.register_primitive) | `sklink.primitives` | Register a primitive and its implementation per backend. |
| [`Aggregate`](./sklink.expressions#sklink.expressions.Aggregate) | `sklink.expressions` | A primitive applied to the rows reached through a `to_many` path. |
| [`Attribute`](./sklink.expressions#sklink.expressions.Attribute) | `sklink.expressions` | A column of the entity table, or of a table reached with `to_one` hops. |
| [`Condition`](./sklink.expressions#sklink.expressions.Condition) | `sklink.expressions` | Filter on the rows of the last table of a path. Conditions are and-ed. |
| [`Expression`](./sklink.expressions#sklink.expressions.Expression) | `sklink.expressions` | Base class of every expression. |
| [`Hop`](./sklink.expressions#sklink.expressions.Hop) | `sklink.expressions` | One step along a relationship. |
| [`LeafSum`](./sklink.expressions#sklink.expressions.LeafSum) | `sklink.expressions` | Learned weights of the rows reached through a `to_many` path, summed. |
| [`Path`](./sklink.expressions#sklink.expressions.Path) | `sklink.expressions` | Sequence of hops starting at the entity table. Empty means the entity itself. |
| [`SampleFeature`](./sklink.expressions#sklink.expressions.SampleFeature) | `sklink.expressions` | A column of the population table `X` itself. |
| [`Window`](./sklink.expressions#sklink.expressions.Window) | `sklink.expressions` | Time window ending at the cutoff: `cutoff - duration <= time < cutoff`. |
| [`enumerate_expressions()`](./sklink.expressions#sklink.expressions.enumerate_expressions) | `sklink.expressions` | List the default unconditioned expressions for an entity. |
| [`enumerate_lookups()`](./sklink.expressions#sklink.expressions.enumerate_lookups) | `sklink.expressions` | List the lookups that conditions on the rows of `path` may follow. |
| [`enumerate_paths()`](./sklink.expressions#sklink.expressions.enumerate_paths) | `sklink.expressions` | List every path from `entity` allowed by the visibility rules. |
| [`expression_from_dict()`](./sklink.expressions#sklink.expressions.expression_from_dict) | `sklink.expressions` | Rebuild an expression from `to_dict` output. |
| [`format_expression()`](./sklink.expressions#sklink.expressions.format_expression) | `sklink.expressions` | Canonical name of an expression. |
| [`make_hop()`](./sklink.expressions#sklink.expressions.make_hop) | `sklink.expressions` | Build a hop from `current` along `relationship`, deciding its spelling. |
| [`output_type()`](./sklink.expressions#sklink.expressions.output_type) | `sklink.expressions` | Semantic type of the value an expression produces. |
| [`parse()`](./sklink.expressions#sklink.expressions.parse) | `sklink.expressions` | Read an expression from its canonical name. |
| [`validate_expression()`](./sklink.expressions#sklink.expressions.validate_expression) | `sklink.expressions` | Check that an expression can be evaluated on a database with `schema`. |
| [`Backend`](./sklink.engine#sklink.engine.Backend) | `sklink.engine` | Factory of sessions; registered under a name. |
| [`ChildBlock`](./sklink.engine#sklink.engine.ChildBlock) | `sklink.engine` | Rows reached through a path, grouped by group in CSR layout. |
| [`FeatureBlock`](./sklink.engine#sklink.engine.FeatureBlock) | `sklink.engine` | Values of several expressions, one row per sample. |
| [`Population`](./sklink.engine#sklink.engine.Population) | `sklink.engine` | Samples to evaluate: the entity key of each sample and its optional cutoff. |
| [`ResolvedPopulation`](./sklink.engine#sklink.engine.ResolvedPopulation) | `sklink.engine` | Samples mapped to distinct (entity row, cutoff) groups. |
| [`Session`](./sklink.engine#sklink.engine.Session) | `sklink.engine` | An open evaluation context on one database. |
| [`Visibility`](./sklink.engine#sklink.engine.Visibility) | `sklink.engine` | Which rows a sample may read. |
| [`clear_cache()`](./sklink.engine#sklink.engine.clear_cache) | `sklink.engine` | Drop every entry. |
| [`get_backend()`](./sklink.engine#sklink.engine.get_backend) | `sklink.engine` | Return a backend by name; `None` uses the configured one. |
| [`list_backends()`](./sklink.engine#sklink.engine.list_backends) | `sklink.engine` | Names of the available backends. |

## Utilities

Configuration, versions, errors, warnings and checks for estimator authors.

| Object | Module | Summary |
| --- | --- | --- |
| [`config_context()`](./sklink#sklink.config_context) | `sklink` | Temporarily change the configuration inside a `with` block. |
| [`get_config()`](./sklink#sklink.get_config) | `sklink` | Return a copy of the current configuration. |
| [`set_config()`](./sklink#sklink.set_config) | `sklink` | Set resource options for the current thread. |
| [`show_versions()`](./sklink#sklink.show_versions) | `sklink` | Print the versions of scikit-link, its dependencies and the platform. |
| [`BackendError`](./sklink.exceptions#sklink.exceptions.BackendError) | `sklink.exceptions` | The evaluation backend is unavailable or failed. |
| [`DetachedDatabaseError`](./sklink.exceptions#sklink.exceptions.DetachedDatabaseError) | `sklink.exceptions` | An estimator was used after `detach` without a new database. |
| [`InconsistentVersionWarning`](./sklink.exceptions#sklink.exceptions.InconsistentVersionWarning) | `sklink.exceptions` | A model saved with another version of scikit-link was loaded. |
| [`IntegrityError`](./sklink.exceptions#sklink.exceptions.IntegrityError) | `sklink.exceptions` | The data violates a declared key or relationship. |
| [`LeakageWarning`](./sklink.exceptions#sklink.exceptions.LeakageWarning) | `sklink.exceptions` | A configuration may leak information between samples or from the future. |
| [`PerformanceWarning`](./sklink.exceptions#sklink.exceptions.PerformanceWarning) | `sklink.exceptions` | An operation is likely to be slow or memory hungry. |
| [`SchemaError`](./sklink.exceptions#sklink.exceptions.SchemaError) | `sklink.exceptions` | A table, column, relationship or expression does not match the schema. |
| [`SklinkError`](./sklink.exceptions#sklink.exceptions.SklinkError) | `sklink.exceptions` | Base class of every exception raised by scikit-link. |
| [`SklinkWarning`](./sklink.exceptions#sklink.exceptions.SklinkWarning) | `sklink.exceptions` | Base class of every warning emitted by scikit-link. |
| [`UnknownEntityError`](./sklink.exceptions#sklink.exceptions.UnknownEntityError) | `sklink.exceptions` | Keys of the population table do not exist in the entity table. |
| [`VisibilityError`](./sklink.exceptions#sklink.exceptions.VisibilityError) | `sklink.exceptions` | A model is evaluated under a visibility policy it was not fitted with. |
| [`ValidatedX`](./sklink.utils.validation#sklink.utils.validation.ValidatedX) | `sklink.utils.validation` | `X` split into entity keys, cutoffs and sample feature columns. |
| [`check_database()`](./sklink.utils.validation#sklink.utils.validation.check_database) | `sklink.utils.validation` | Check that `database` is a usable `Database`. |
| [`check_relational_X()`](./sklink.utils.validation#sklink.utils.validation.check_relational_X) | `sklink.utils.validation` | Validate the population table `X` of a relational estimator. |
| [`check_temporal_setup()`](./sklink.utils.validation#sklink.utils.validation.check_temporal_setup) | `sklink.utils.validation` | Warn when a validation set-up does not match the time mode of a model. |
| [`check_batch_independence()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_batch_independence) | `sklink.utils.estimator_checks` | Check that an output is the same alone, in a subset or reordered (LEAK-03). |
| [`check_clone_shares_database()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_clone_shares_database) | `sklink.utils.estimator_checks` | `clone`, `copy` and `deepcopy` keep the same `Database` (DB-14). |
| [`check_flat_mode()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_flat_mode) | `sklink.utils.estimator_checks` | With `database=None` the estimator is a plain tabular one (DATA-07). |
| [`check_future_rows_ignored()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_future_rows_ignored) | `sklink.utils.estimator_checks` | Rows after every cutoff change nothing in temporal mode (VIS-03). |
| [`check_input_equivalence()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_input_equivalence) | `sklink.utils.estimator_checks` | pandas, Polars and positional `ndarray` inputs give the same (DATA-08). |
| [`check_no_data_in_errors()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_no_data_in_errors) | `sklink.utils.estimator_checks` | Error messages name tables and columns, never data values (API-07). |
| [`check_one_prediction_per_row()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_one_prediction_per_row) | `sklink.utils.estimator_checks` | One output row per row of `X`, in order, duplicates kept (DATA-04). |
| [`check_pickle_detach_rebind()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_pickle_detach_rebind) | `sklink.utils.estimator_checks` | Pickle, `detach` and `rebind` keep outputs identical (DB-18 to DB-20). |
| [`check_refit_resets_state()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_refit_resets_state) | `sklink.utils.estimator_checks` | Check that a second `fit` discards what the first one learned (SK-03). |
| [`check_relational_estimator()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_relational_estimator) | `sklink.utils.estimator_checks` | Run every relational check on a configured estimator. |
| [`check_row_order_invariance()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_row_order_invariance) | `sklink.utils.estimator_checks` | Shuffling the rows of every table changes nothing (DET-02). |
| [`check_static_database()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_static_database) | `sklink.utils.estimator_checks` | Without any date column the estimator works and warns nothing (TIME-02). |
| [`check_threadsafe_predict()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_threadsafe_predict) | `sklink.utils.estimator_checks` | Check that a fitted estimator evaluates concurrently from 8 threads (PAR-02). |
| [`check_unknown_entity()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_unknown_entity) | `sklink.utils.estimator_checks` | Keys missing from the entity table follow `handle_unknown_entity` (ENG-03). |
| [`check_unreachable_rows_ignored()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.check_unreachable_rows_ignored) | `sklink.utils.estimator_checks` | Rows unreachable from the training samples change nothing (LEAK-01). |
| [`parametrize_with_relational_checks()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.parametrize_with_relational_checks) | `sklink.utils.estimator_checks` | Pytest decorator that parametrizes a test over estimators and checks. |
| [`relational_checks()`](./sklink.utils.estimator_checks#sklink.utils.estimator_checks.relational_checks) | `sklink.utils.estimator_checks` | List the relational checks, in a stable order. |
