Skip to content

API reference ​

Look up parameters, return values and examples by class or function. To fit your first model, follow the shop quickstart. If you already have a fitted model, inspect its rules or plot a prediction.

Data ​

Describe tables, keys and relationships.

ObjectModuleSummary
ColumnSchemasklink.databaseName and types of one column.
Databasesklink.databaseImmutable, validated relational database used by scikit-link estimators.
DetachedDatabasesklink.databasePlaceholder left by detach: keeps the schema, holds no data.
Relationshipsklink.databaseA foreign key of a child table that references the primary key of a parent.
Schemasklink.databaseImmutable, data-free description of a database.
SemanticTypesklink.databaseSemantic type of a column, which decides the primitives that apply to it.
TableSchemasklink.databaseColumns, primary key and optional time column of one table.
detach()sklink.databaseReturn a copy of a model in which every database keeps only its schema.
rebind()sklink.databaseReturn a copy of a model that uses database instead of its current one.

Features ​

Turn related tables into columns for any estimator.

ObjectModuleSummary
RelationalFeaturizersklink.feature_extractionTurn a population table into a flat matrix of relational features.

Models ​

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

ObjectModuleSummary
RelationalDecisionTreeClassifiersklink.treeDecision tree classifier whose questions can aggregate related tables.
RelationalDecisionTreeRegressorsklink.treeDecision tree regressor whose questions can aggregate related tables.
RelationalTreesklink.treeFitted tree structure as parallel arrays, one entry per node.
SplitCandidatessklink.treeBest questions scored at the split nodes of a tree, the chosen one first.
RelationalGradientBoostingClassifiersklink.ensembleGradient boosting of relational decision trees for classification.
RelationalGradientBoostingRegressorsklink.ensembleGradient boosting of relational decision trees for regression.
RelationalIsolationForestsklink.ensembleIsolation forest that finds unusual entities from their related rows.
RelationalRandomForestClassifiersklink.ensembleRandom forest of relational decision tree classifiers.
RelationalRandomForestRegressorsklink.ensembleRandom forest of relational decision tree regressors.

Clustering ​

Group entities by their related rows, without labels.

ObjectModuleSummary
RelationalClusteringTreesklink.clusterClustering tree: clusters of entities defined by relational questions.
RelationalKMeanssklink.clusterK-means clustering of the entities of a multi-table database.

Composition ​

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

ObjectModuleSummary
TransformedTablesEstimatorsklink.composeFit scikit-learn transformers on tables of the database, then an estimator.

Evaluation ​

Validation for temporal data.

ObjectModuleSummary
TemporalCutoffSplitsklink.model_selectionTime-ordered cross-validation over the cutoff column of X.

Inspection ​

Read, explain and export fitted models.

ObjectModuleSummary
aggregate_importances()sklink.inspectionGroup the importances of a relational model by table, column or primitive.
describe_expressions()sklink.inspectionList what each expression of a fitted model reads from the database.
explain()sklink.inspectionExplain the predictions of a relational tree or ensemble for some samples.
export_dict()sklink.inspectionDescribe a fitted relational tree, forest or boosting model with JSON types.
export_json()sklink.inspectionWrite export_dict as JSON text.
export_text()sklink.inspectionBuild a text report of the rules of a fitted relational tree.

Plotting ​

Draw a schema, a fitted model or one prediction.

ObjectModuleSummary
CutoffSplitDisplaysklink.plottingWhich cutoffs train and which test in each split of a cross-validation.
ExplanationDisplaysklink.plottingWhy one sample got its prediction.
ForestDisplaysklink.plottingHow a relational random forest or gradient boosting model fitted.
ImportanceDisplaysklink.plottingHow the importance of a model flows from tables to columns to primitives.
LiveFitsklink.plottingDraw the progress of fit while it runs, and the model when it ends.
SchemaDisplaysklink.plottingTables, keys and relationships of a database, as given to a model.
SearchDisplaysklink.plottingThe questions a relational tree scored at one node, the chosen one first.
TreeDisplaysklink.plottingRelational decision tree, drawn from export_dict.

Datasets ​

Synthetic problems with known rules and a small example database.

ObjectModuleSummary
load_shop()sklink.datasetsLoad the small shop database bundled with the package.
make_relational_classification()sklink.datasetsGenerate a relational classification problem with a known rule.
make_relational_regression()sklink.datasetsGenerate a relational regression problem with a known target formula.

Extending ​

Primitives, expressions and the evaluation engine.

ObjectModuleSummary
KernelContextsklink.primitivesExtra information a kernel may need besides the rows it aggregates.
Primitivesklink.primitivesDescription of an aggregation primitive.
default_primitives()sklink.primitivesPrimitives generated by default for a column of the given semantic type.
get_kernel()sklink.primitivesReturn the implementation of a primitive for a backend (NumPy fallback).
get_primitive()sklink.primitivesReturn a registered primitive by name.
list_primitives()sklink.primitivesNames of the registered primitives, sorted.
register_primitive()sklink.primitivesRegister a primitive and its implementation per backend.
Aggregatesklink.expressionsA primitive applied to the rows reached through a to_many path.
Attributesklink.expressionsA column of the entity table, or of a table reached with to_one hops.
Conditionsklink.expressionsFilter on the rows of the last table of a path. Conditions are and-ed.
Expressionsklink.expressionsBase class of every expression.
Hopsklink.expressionsOne step along a relationship.
LeafSumsklink.expressionsLearned weights of the rows reached through a to_many path, summed.
Pathsklink.expressionsSequence of hops starting at the entity table. Empty means the entity itself.
SampleFeaturesklink.expressionsA column of the population table X itself.
Windowsklink.expressionsTime window ending at the cutoff: cutoff - duration <= time < cutoff.
enumerate_expressions()sklink.expressionsList the default unconditioned expressions for an entity.
enumerate_lookups()sklink.expressionsList the lookups that conditions on the rows of path may follow.
enumerate_paths()sklink.expressionsList every path from entity allowed by the visibility rules.
expression_from_dict()sklink.expressionsRebuild an expression from to_dict output.
format_expression()sklink.expressionsCanonical name of an expression.
make_hop()sklink.expressionsBuild a hop from current along relationship, deciding its spelling.
output_type()sklink.expressionsSemantic type of the value an expression produces.
parse()sklink.expressionsRead an expression from its canonical name.
validate_expression()sklink.expressionsCheck that an expression can be evaluated on a database with schema.
Backendsklink.engineFactory of sessions; registered under a name.
ChildBlocksklink.engineRows reached through a path, grouped by group in CSR layout.
FeatureBlocksklink.engineValues of several expressions, one row per sample.
Populationsklink.engineSamples to evaluate: the entity key of each sample and its optional cutoff.
ResolvedPopulationsklink.engineSamples mapped to distinct (entity row, cutoff) groups.
Sessionsklink.engineAn open evaluation context on one database.
Visibilitysklink.engineWhich rows a sample may read.
clear_cache()sklink.engineDrop every entry.
get_backend()sklink.engineReturn a backend by name; None uses the configured one.
list_backends()sklink.engineNames of the available backends.

Utilities ​

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

ObjectModuleSummary
config_context()sklinkTemporarily change the configuration inside a with block.
get_config()sklinkReturn a copy of the current configuration.
set_config()sklinkSet resource options for the current thread.
show_versions()sklinkPrint the versions of scikit-link, its dependencies and the platform.
BackendErrorsklink.exceptionsThe evaluation backend is unavailable or failed.
DetachedDatabaseErrorsklink.exceptionsAn estimator was used after detach without a new database.
InconsistentVersionWarningsklink.exceptionsA model saved with another version of scikit-link was loaded.
IntegrityErrorsklink.exceptionsThe data violates a declared key or relationship.
LeakageWarningsklink.exceptionsA configuration may leak information between samples or from the future.
PerformanceWarningsklink.exceptionsAn operation is likely to be slow or memory hungry.
SchemaErrorsklink.exceptionsA table, column, relationship or expression does not match the schema.
SklinkErrorsklink.exceptionsBase class of every exception raised by scikit-link.
SklinkWarningsklink.exceptionsBase class of every warning emitted by scikit-link.
UnknownEntityErrorsklink.exceptionsKeys of the population table do not exist in the entity table.
VisibilityErrorsklink.exceptionsA model is evaluated under a visibility policy it was not fitted with.
ValidatedXsklink.utils.validationX split into entity keys, cutoffs and sample feature columns.
check_database()sklink.utils.validationCheck that database is a usable Database.
check_relational_X()sklink.utils.validationValidate the population table X of a relational estimator.
check_temporal_setup()sklink.utils.validationWarn when a validation set-up does not match the time mode of a model.
check_batch_independence()sklink.utils.estimator_checksCheck that an output is the same alone, in a subset or reordered (LEAK-03).
check_clone_shares_database()sklink.utils.estimator_checksclone, copy and deepcopy keep the same Database (DB-14).
check_flat_mode()sklink.utils.estimator_checksWith database=None the estimator is a plain tabular one (DATA-07).
check_future_rows_ignored()sklink.utils.estimator_checksRows after every cutoff change nothing in temporal mode (VIS-03).
check_input_equivalence()sklink.utils.estimator_checkspandas, Polars and positional ndarray inputs give the same (DATA-08).
check_no_data_in_errors()sklink.utils.estimator_checksError messages name tables and columns, never data values (API-07).
check_one_prediction_per_row()sklink.utils.estimator_checksOne output row per row of X, in order, duplicates kept (DATA-04).
check_pickle_detach_rebind()sklink.utils.estimator_checksPickle, detach and rebind keep outputs identical (DB-18 to DB-20).
check_refit_resets_state()sklink.utils.estimator_checksCheck that a second fit discards what the first one learned (SK-03).
check_relational_estimator()sklink.utils.estimator_checksRun every relational check on a configured estimator.
check_row_order_invariance()sklink.utils.estimator_checksShuffling the rows of every table changes nothing (DET-02).
check_static_database()sklink.utils.estimator_checksWithout any date column the estimator works and warns nothing (TIME-02).
check_threadsafe_predict()sklink.utils.estimator_checksCheck that a fitted estimator evaluates concurrently from 8 threads (PAR-02).
check_unknown_entity()sklink.utils.estimator_checksKeys missing from the entity table follow handle_unknown_entity (ENG-03).
check_unreachable_rows_ignored()sklink.utils.estimator_checksRows unreachable from the training samples change nothing (LEAK-01).
parametrize_with_relational_checks()sklink.utils.estimator_checksPytest decorator that parametrizes a test over estimators and checks.
relational_checks()sklink.utils.estimator_checksList the relational checks, in a stable order.

Released under the MIT License.