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.
| Object | Module | Summary |
|---|---|---|
ColumnSchema | sklink.database | Name and types of one column. |
Database | sklink.database | Immutable, validated relational database used by scikit-link estimators. |
DetachedDatabase | sklink.database | Placeholder left by detach: keeps the schema, holds no data. |
Relationship | sklink.database | A foreign key of a child table that references the primary key of a parent. |
Schema | sklink.database | Immutable, data-free description of a database. |
SemanticType | sklink.database | Semantic type of a column, which decides the primitives that apply to it. |
TableSchema | sklink.database | Columns, primary key and optional time column of one table. |
detach() | sklink.database | Return a copy of a model in which every database keeps only its schema. |
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 | 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 | Decision tree classifier whose questions can aggregate related tables. |
RelationalDecisionTreeRegressor | sklink.tree | Decision tree regressor whose questions can aggregate related tables. |
RelationalTree | sklink.tree | Fitted tree structure as parallel arrays, one entry per node. |
SplitCandidates | sklink.tree | Best questions scored at the split nodes of a tree, the chosen one first. |
RelationalGradientBoostingClassifier | sklink.ensemble | Gradient boosting of relational decision trees for classification. |
RelationalGradientBoostingRegressor | sklink.ensemble | Gradient boosting of relational decision trees for regression. |
RelationalIsolationForest | sklink.ensemble | Isolation forest that finds unusual entities from their related rows. |
RelationalRandomForestClassifier | sklink.ensemble | Random forest of relational decision tree classifiers. |
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 | Clustering tree: clusters of entities defined by relational questions. |
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 | Fit scikit-learn transformers on tables of the database, then an estimator. |
Evaluation
Validation for temporal data.
| Object | Module | Summary |
|---|---|---|
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 | Group the importances of a relational model by table, column or primitive. |
describe_expressions() | sklink.inspection | List what each expression of a fitted model reads from the database. |
explain() | sklink.inspection | Explain the predictions of a relational tree or ensemble for some samples. |
export_dict() | sklink.inspection | Describe a fitted relational tree, forest or boosting model with JSON types. |
export_json() | sklink.inspection | Write export_dict as JSON text. |
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 | Which cutoffs train and which test in each split of a cross-validation. |
ExplanationDisplay | sklink.plotting | Why one sample got its prediction. |
ForestDisplay | sklink.plotting | How a relational random forest or gradient boosting model fitted. |
ImportanceDisplay | sklink.plotting | How the importance of a model flows from tables to columns to primitives. |
LiveFit | sklink.plotting | Draw the progress of fit while it runs, and the model when it ends. |
SchemaDisplay | sklink.plotting | Tables, keys and relationships of a database, as given to a model. |
SearchDisplay | sklink.plotting | The questions a relational tree scored at one node, the chosen one first. |
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 | Load the small shop database bundled with the package. |
make_relational_classification() | sklink.datasets | Generate a relational classification problem with a known rule. |
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 | Extra information a kernel may need besides the rows it aggregates. |
Primitive | sklink.primitives | Description of an aggregation primitive. |
default_primitives() | sklink.primitives | Primitives generated by default for a column of the given semantic type. |
get_kernel() | sklink.primitives | Return the implementation of a primitive for a backend (NumPy fallback). |
get_primitive() | sklink.primitives | Return a registered primitive by name. |
list_primitives() | sklink.primitives | Names of the registered primitives, sorted. |
register_primitive() | sklink.primitives | Register a primitive and its implementation per backend. |
Aggregate | sklink.expressions | A primitive applied to the rows reached through a to_many path. |
Attribute | sklink.expressions | A column of the entity table, or of a table reached with to_one hops. |
Condition | sklink.expressions | Filter on the rows of the last table of a path. Conditions are and-ed. |
Expression | sklink.expressions | Base class of every expression. |
Hop | sklink.expressions | One step along a relationship. |
LeafSum | sklink.expressions | Learned weights of the rows reached through a to_many path, summed. |
Path | sklink.expressions | Sequence of hops starting at the entity table. Empty means the entity itself. |
SampleFeature | sklink.expressions | A column of the population table X itself. |
Window | sklink.expressions | Time window ending at the cutoff: cutoff - duration <= time < cutoff. |
enumerate_expressions() | sklink.expressions | List the default unconditioned expressions for an entity. |
enumerate_lookups() | sklink.expressions | List the lookups that conditions on the rows of path may follow. |
enumerate_paths() | sklink.expressions | List every path from entity allowed by the visibility rules. |
expression_from_dict() | sklink.expressions | Rebuild an expression from to_dict output. |
format_expression() | sklink.expressions | Canonical name of an expression. |
make_hop() | sklink.expressions | Build a hop from current along relationship, deciding its spelling. |
output_type() | sklink.expressions | Semantic type of the value an expression produces. |
parse() | sklink.expressions | Read an expression from its canonical name. |
validate_expression() | sklink.expressions | Check that an expression can be evaluated on a database with schema. |
Backend | sklink.engine | Factory of sessions; registered under a name. |
ChildBlock | sklink.engine | Rows reached through a path, grouped by group in CSR layout. |
FeatureBlock | sklink.engine | Values of several expressions, one row per sample. |
Population | sklink.engine | Samples to evaluate: the entity key of each sample and its optional cutoff. |
ResolvedPopulation | sklink.engine | Samples mapped to distinct (entity row, cutoff) groups. |
Session | sklink.engine | An open evaluation context on one database. |
Visibility | sklink.engine | Which rows a sample may read. |
clear_cache() | sklink.engine | Drop every entry. |
get_backend() | sklink.engine | Return a backend by name; None uses the configured one. |
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 | Temporarily change the configuration inside a with block. |
get_config() | sklink | Return a copy of the current configuration. |
set_config() | sklink | Set resource options for the current thread. |
show_versions() | sklink | Print the versions of scikit-link, its dependencies and the platform. |
BackendError | sklink.exceptions | The evaluation backend is unavailable or failed. |
DetachedDatabaseError | sklink.exceptions | An estimator was used after detach without a new database. |
InconsistentVersionWarning | sklink.exceptions | A model saved with another version of scikit-link was loaded. |
IntegrityError | sklink.exceptions | The data violates a declared key or relationship. |
LeakageWarning | sklink.exceptions | A configuration may leak information between samples or from the future. |
PerformanceWarning | sklink.exceptions | An operation is likely to be slow or memory hungry. |
SchemaError | sklink.exceptions | A table, column, relationship or expression does not match the schema. |
SklinkError | sklink.exceptions | Base class of every exception raised by scikit-link. |
SklinkWarning | sklink.exceptions | Base class of every warning emitted by scikit-link. |
UnknownEntityError | sklink.exceptions | Keys of the population table do not exist in the entity table. |
VisibilityError | sklink.exceptions | A model is evaluated under a visibility policy it was not fitted with. |
ValidatedX | sklink.utils.validation | X split into entity keys, cutoffs and sample feature columns. |
check_database() | sklink.utils.validation | Check that database is a usable Database. |
check_relational_X() | sklink.utils.validation | Validate the population table X of a relational estimator. |
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 | Check that an output is the same alone, in a subset or reordered (LEAK-03). |
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 | With database=None the estimator is a plain tabular one (DATA-07). |
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 | pandas, Polars and positional ndarray inputs give the same (DATA-08). |
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 | One output row per row of X, in order, duplicates kept (DATA-04). |
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 | Check that a second fit discards what the first one learned (SK-03). |
check_relational_estimator() | sklink.utils.estimator_checks | Run every relational check on a configured estimator. |
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 | Without any date column the estimator works and warns nothing (TIME-02). |
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 | Keys missing from the entity table follow handle_unknown_entity (ENG-03). |
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 | Pytest decorator that parametrizes a test over estimators and checks. |
relational_checks() | sklink.utils.estimator_checks | List the relational checks, in a stable order. |