scikit-link 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. scikit_link-0.1.0/.gitignore +246 -0
  2. scikit_link-0.1.0/CITATION.cff +24 -0
  3. scikit_link-0.1.0/LICENSE +21 -0
  4. scikit_link-0.1.0/PKG-INFO +272 -0
  5. scikit_link-0.1.0/README.md +229 -0
  6. scikit_link-0.1.0/pyproject.toml +490 -0
  7. scikit_link-0.1.0/src/sklink/__init__.py +19 -0
  8. scikit_link-0.1.0/src/sklink/_base.py +535 -0
  9. scikit_link-0.1.0/src/sklink/_compat.py +63 -0
  10. scikit_link-0.1.0/src/sklink/_config.py +190 -0
  11. scikit_link-0.1.0/src/sklink/_metadata.py +14 -0
  12. scikit_link-0.1.0/src/sklink/_numba.py +69 -0
  13. scikit_link-0.1.0/src/sklink/_show_versions.py +46 -0
  14. scikit_link-0.1.0/src/sklink/cluster/__init__.py +11 -0
  15. scikit_link-0.1.0/src/sklink/cluster/_common.py +87 -0
  16. scikit_link-0.1.0/src/sklink/cluster/_embedding.py +202 -0
  17. scikit_link-0.1.0/src/sklink/cluster/_kmeans.py +405 -0
  18. scikit_link-0.1.0/src/sklink/cluster/_tree.py +485 -0
  19. scikit_link-0.1.0/src/sklink/compose/__init__.py +10 -0
  20. scikit_link-0.1.0/src/sklink/compose/_tables.py +1141 -0
  21. scikit_link-0.1.0/src/sklink/database/__init__.py +23 -0
  22. scikit_link-0.1.0/src/sklink/database/_binding.py +214 -0
  23. scikit_link-0.1.0/src/sklink/database/_columns.py +747 -0
  24. scikit_link-0.1.0/src/sklink/database/_database.py +1022 -0
  25. scikit_link-0.1.0/src/sklink/database/_keys.py +104 -0
  26. scikit_link-0.1.0/src/sklink/database/_schema.py +368 -0
  27. scikit_link-0.1.0/src/sklink/datasets/__init__.py +17 -0
  28. scikit_link-0.1.0/src/sklink/datasets/_shop.py +148 -0
  29. scikit_link-0.1.0/src/sklink/datasets/_synthetic.py +1323 -0
  30. scikit_link-0.1.0/src/sklink/datasets/data/customers.parquet +0 -0
  31. scikit_link-0.1.0/src/sklink/datasets/data/order_items.parquet +0 -0
  32. scikit_link-0.1.0/src/sklink/datasets/data/orders.parquet +0 -0
  33. scikit_link-0.1.0/src/sklink/datasets/data/products.parquet +0 -0
  34. scikit_link-0.1.0/src/sklink/datasets/data/target.parquet +0 -0
  35. scikit_link-0.1.0/src/sklink/engine/__init__.py +62 -0
  36. scikit_link-0.1.0/src/sklink/engine/_cache.py +60 -0
  37. scikit_link-0.1.0/src/sklink/engine/_leafsum.py +65 -0
  38. scikit_link-0.1.0/src/sklink/engine/_numpy.py +795 -0
  39. scikit_link-0.1.0/src/sklink/engine/_protocol.py +210 -0
  40. scikit_link-0.1.0/src/sklink/ensemble/__init__.py +19 -0
  41. scikit_link-0.1.0/src/sklink/ensemble/_forest.py +1343 -0
  42. scikit_link-0.1.0/src/sklink/ensemble/_gb.py +1805 -0
  43. scikit_link-0.1.0/src/sklink/ensemble/_iforest.py +329 -0
  44. scikit_link-0.1.0/src/sklink/exceptions.py +123 -0
  45. scikit_link-0.1.0/src/sklink/expressions/__init__.py +48 -0
  46. scikit_link-0.1.0/src/sklink/expressions/_ast.py +562 -0
  47. scikit_link-0.1.0/src/sklink/expressions/_enumerate.py +236 -0
  48. scikit_link-0.1.0/src/sklink/expressions/_naming.py +508 -0
  49. scikit_link-0.1.0/src/sklink/expressions/_validate.py +130 -0
  50. scikit_link-0.1.0/src/sklink/feature_extraction/__init__.py +5 -0
  51. scikit_link-0.1.0/src/sklink/feature_extraction/_featurizer.py +613 -0
  52. scikit_link-0.1.0/src/sklink/inspection/__init__.py +34 -0
  53. scikit_link-0.1.0/src/sklink/inspection/_common.py +247 -0
  54. scikit_link-0.1.0/src/sklink/inspection/_explain.py +361 -0
  55. scikit_link-0.1.0/src/sklink/inspection/_export.py +519 -0
  56. scikit_link-0.1.0/src/sklink/inspection/_importances.py +560 -0
  57. scikit_link-0.1.0/src/sklink/model_selection/__init__.py +10 -0
  58. scikit_link-0.1.0/src/sklink/model_selection/_split.py +437 -0
  59. scikit_link-0.1.0/src/sklink/plotting/__init__.py +51 -0
  60. scikit_link-0.1.0/src/sklink/plotting/_common.py +125 -0
  61. scikit_link-0.1.0/src/sklink/plotting/_cutoff.py +931 -0
  62. scikit_link-0.1.0/src/sklink/plotting/_display.py +337 -0
  63. scikit_link-0.1.0/src/sklink/plotting/_environment.py +28 -0
  64. scikit_link-0.1.0/src/sklink/plotting/_explanation.py +593 -0
  65. scikit_link-0.1.0/src/sklink/plotting/_forest.py +1074 -0
  66. scikit_link-0.1.0/src/sklink/plotting/_importance.py +448 -0
  67. scikit_link-0.1.0/src/sklink/plotting/_live.py +789 -0
  68. scikit_link-0.1.0/src/sklink/plotting/_schema.py +964 -0
  69. scikit_link-0.1.0/src/sklink/plotting/_search.py +546 -0
  70. scikit_link-0.1.0/src/sklink/plotting/_static/plotting.js +85 -0
  71. scikit_link-0.1.0/src/sklink/plotting/_svg.py +195 -0
  72. scikit_link-0.1.0/src/sklink/plotting/_theme.py +89 -0
  73. scikit_link-0.1.0/src/sklink/plotting/_tree.py +991 -0
  74. scikit_link-0.1.0/src/sklink/primitives/__init__.py +22 -0
  75. scikit_link-0.1.0/src/sklink/primitives/_kernels.py +461 -0
  76. scikit_link-0.1.0/src/sklink/primitives/_registry.py +201 -0
  77. scikit_link-0.1.0/src/sklink/py.typed +0 -0
  78. scikit_link-0.1.0/src/sklink/tree/__init__.py +14 -0
  79. scikit_link-0.1.0/src/sklink/tree/_binning.py +114 -0
  80. scikit_link-0.1.0/src/sklink/tree/_builder.py +2861 -0
  81. scikit_link-0.1.0/src/sklink/tree/_classes.py +1369 -0
  82. scikit_link-0.1.0/src/sklink/tree/_criteria.py +167 -0
  83. scikit_link-0.1.0/src/sklink/tree/_data.py +957 -0
  84. scikit_link-0.1.0/src/sklink/tree/_leafsum.py +210 -0
  85. scikit_link-0.1.0/src/sklink/tree/_numba_kernels.py +603 -0
  86. scikit_link-0.1.0/src/sklink/tree/_splitter.py +857 -0
  87. scikit_link-0.1.0/src/sklink/utils/__init__.py +9 -0
  88. scikit_link-0.1.0/src/sklink/utils/_dates.py +188 -0
  89. scikit_link-0.1.0/src/sklink/utils/_output.py +35 -0
  90. scikit_link-0.1.0/src/sklink/utils/_testing.py +628 -0
  91. scikit_link-0.1.0/src/sklink/utils/estimator_checks.py +1034 -0
  92. scikit_link-0.1.0/src/sklink/utils/validation.py +432 -0
  93. scikit_link-0.1.0/tests/README.md +25 -0
  94. scikit_link-0.1.0/tests/conftest.py +388 -0
  95. scikit_link-0.1.0/tests/contract/test_interoperability.py +346 -0
  96. scikit_link-0.1.0/tests/contract/test_relational_checks.py +398 -0
  97. scikit_link-0.1.0/tests/contract/test_sklearn_checks.py +190 -0
  98. scikit_link-0.1.0/tests/e2e/test_anomaly_detection.py +64 -0
  99. scikit_link-0.1.0/tests/e2e/test_clustering.py +177 -0
  100. scikit_link-0.1.0/tests/e2e/test_featurizer.py +298 -0
  101. scikit_link-0.1.0/tests/e2e/test_featurizer_imports.py +58 -0
  102. scikit_link-0.1.0/tests/e2e/test_package.py +18 -0
  103. scikit_link-0.1.0/tests/e2e/test_plotting_browser.py +447 -0
  104. scikit_link-0.1.0/tests/e2e/test_relational_models.py +687 -0
  105. scikit_link-0.1.0/tests/integration/test_base_warnings.py +118 -0
  106. scikit_link-0.1.0/tests/integration/test_callbacks.py +380 -0
  107. scikit_link-0.1.0/tests/integration/test_catalog.py +292 -0
  108. scikit_link-0.1.0/tests/integration/test_compose.py +455 -0
  109. scikit_link-0.1.0/tests/integration/test_config.py +177 -0
  110. scikit_link-0.1.0/tests/integration/test_database.py +1003 -0
  111. scikit_link-0.1.0/tests/integration/test_database_persistence.py +263 -0
  112. scikit_link-0.1.0/tests/integration/test_datasets.py +616 -0
  113. scikit_link-0.1.0/tests/integration/test_engine_invariance.py +239 -0
  114. scikit_link-0.1.0/tests/integration/test_engine_leakage.py +410 -0
  115. scikit_link-0.1.0/tests/integration/test_engine_names.py +136 -0
  116. scikit_link-0.1.0/tests/integration/test_engine_oracle.py +460 -0
  117. scikit_link-0.1.0/tests/integration/test_featurizer.py +367 -0
  118. scikit_link-0.1.0/tests/integration/test_forest.py +614 -0
  119. scikit_link-0.1.0/tests/integration/test_inspection.py +1061 -0
  120. scikit_link-0.1.0/tests/integration/test_plotting.py +869 -0
  121. scikit_link-0.1.0/tests/integration/test_plotting_fit.py +1263 -0
  122. scikit_link-0.1.0/tests/integration/test_temporal_cutoff_split.py +519 -0
  123. scikit_link-0.1.0/tests/integration/test_tree.py +1257 -0
  124. scikit_link-0.1.0/tests/integration/test_unit_test_guard.py +50 -0
  125. scikit_link-0.1.0/tests/integration/test_utils_validation.py +192 -0
  126. scikit_link-0.1.0/tests/unit/test_canonical_names.py +367 -0
  127. scikit_link-0.1.0/tests/unit/test_schema_json.py +111 -0
  128. scikit_link-0.1.0/tools/check_unit_test_justification.py +73 -0
  129. scikit_link-0.1.0/tools/make_shop.py +104 -0
@@ -0,0 +1,246 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ *.lcov
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ # Pipfile.lock
97
+
98
+ # uv
99
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # uv.lock
103
+
104
+ # poetry
105
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
107
+ # commonly ignored for libraries.
108
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109
+ # poetry.lock
110
+ # poetry.toml
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
115
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
116
+ # pdm.lock
117
+ # pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # pixi
122
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
123
+ # pixi.lock
124
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
125
+ # in the .venv directory. It is recommended not to include this directory in version control.
126
+ .pixi/*
127
+ !.pixi/config.toml
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule*
134
+ celerybeat.pid
135
+
136
+ # Redis
137
+ *.rdb
138
+ *.aof
139
+ *.pid
140
+
141
+ # RabbitMQ
142
+ mnesia/
143
+ rabbitmq/
144
+ rabbitmq-data/
145
+
146
+ # ActiveMQ
147
+ activemq-data/
148
+
149
+ # SageMath parsed files
150
+ *.sage.py
151
+
152
+ # Environments
153
+ .env
154
+ .envrc
155
+ .venv
156
+ env/
157
+ venv/
158
+ ENV/
159
+ env.bak/
160
+ venv.bak/
161
+
162
+ # Conda environments
163
+ conda-meta/
164
+
165
+ # Spyder project settings
166
+ .spyderproject
167
+ .spyproject
168
+
169
+ # Rope project settings
170
+ .ropeproject
171
+
172
+ # mkdocs/Zensical documentation
173
+ /site
174
+
175
+ # mypy
176
+ .mypy_cache/
177
+ .dmypy.json
178
+ dmypy.json
179
+
180
+ # Pyre type checker
181
+ .pyre/
182
+
183
+ # pytype static type analyzer
184
+ .pytype/
185
+
186
+ # Cython debug symbols
187
+ cython_debug/
188
+
189
+ # PyCharm
190
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
191
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
192
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
193
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
194
+ # .idea/
195
+
196
+ # Abstra
197
+ # Abstra is an AI-powered process automation framework.
198
+ # Ignore directories containing user credentials, local state, and settings.
199
+ # Learn more at https://abstra.io/docs
200
+ .abstra/
201
+
202
+ # Visual Studio Code
203
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore that
204
+ # can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
205
+ # and can be added to the global gitignore or merged into this file. However, if you prefer, you
206
+ # could uncomment the following to ignore the entire vscode folder
207
+ # .vscode/
208
+ # Temporary file for partial code execution
209
+ tempCodeRunnerFile.py
210
+
211
+ # Ruff stuff:
212
+ .ruff_cache/
213
+
214
+ # PyPI configuration file
215
+ .pypirc
216
+
217
+ # Marimo
218
+ marimo/_static/
219
+ marimo/_lsp/
220
+ __marimo__/
221
+
222
+ # Streamlit
223
+ .streamlit/secrets.toml
224
+
225
+ # scikit-link: local working specifications (not published)
226
+ specs/
227
+
228
+ # Version file generated by hatch-vcs at build time
229
+
230
+ # Documentation site (VitePress)
231
+ node_modules/
232
+ docs/.vitepress/dist/
233
+ docs/.vitepress/cache/
234
+
235
+ # IDEs
236
+ .idea/
237
+ .vscode/
238
+
239
+ # Generated before each documentation build
240
+ docs/content/api/*.md
241
+ docs/site/public/brand/
242
+ docs/site/public/versions.json
243
+ docs/site/public/robots.txt
244
+
245
+ # RelBench leaderboard prediction tables (python -m benchmarks.leaderboard)
246
+ benchmarks/predictions/
@@ -0,0 +1,24 @@
1
+ cff-version: 1.2.0
2
+ message: If you use scikit-link in your work, please cite it using this metadata.
3
+ title: "scikit-link: Machine learning on multiple related tables, with the scikit-learn API"
4
+ type: software
5
+ authors:
6
+ - given-names: Rodrigo
7
+ family-names: Arenas
8
+ abstract: >-
9
+ scikit-link is a Python library for machine learning on several tables linked
10
+ by keys, with the scikit-learn API. It computes relational features for any
11
+ scikit-learn estimator, and fits relational decision trees, random forests,
12
+ gradient boosting, clustering and anomaly detection models that learn
13
+ aggregates and conditions on the related rows, with per-sample cutoff dates
14
+ that prevent leakage from future rows.
15
+ repository-code: https://github.com/rodrigo-arenas/scikit-link
16
+ url: https://scikit-link.rodrigo-arenas.com/
17
+ license: MIT
18
+ keywords:
19
+ - machine learning
20
+ - relational learning
21
+ - multi-table data
22
+ - relational decision trees
23
+ - feature engineering
24
+ - scikit-learn
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rodrigo Arenas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,272 @@
1
+ Metadata-Version: 2.5
2
+ Name: scikit-link
3
+ Version: 0.1.0
4
+ Summary: Machine learning on multiple related tables, with the scikit-learn API: relational features, decision trees, random forests, gradient boosting and clustering
5
+ Project-URL: Homepage, https://scikit-link.rodrigo-arenas.com/
6
+ Project-URL: Documentation, https://scikit-link.rodrigo-arenas.com/stable/
7
+ Project-URL: Source, https://github.com/rodrigo-arenas/scikit-link
8
+ Project-URL: Issues, https://github.com/rodrigo-arenas/scikit-link/issues
9
+ Project-URL: Changelog, https://scikit-link.rodrigo-arenas.com/stable/release-notes
10
+ Author-email: Rodrigo Arenas <rodrigo.arenas456@gmail.com>
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: automated feature engineering,deep feature synthesis,feature engineering,featuretools,machine learning,multi-table,propositionalization,random forest,relational database,relational decision tree,relational learning,scikit-learn,tabular data
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Programming Language :: Python :: 3.15
24
+ Classifier: Topic :: Database
25
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
26
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Classifier: Typing :: Typed
29
+ Requires-Python: >=3.12
30
+ Requires-Dist: duckdb>=1.4
31
+ Requires-Dist: narwhals>=2.0
32
+ Requires-Dist: numba>=0.61; (sys_platform != 'darwin' or platform_machine == 'arm64') and python_version < '3.16'
33
+ Requires-Dist: numpy>=2.0
34
+ Requires-Dist: scikit-learn>=1.8
35
+ Requires-Dist: scipy>=1.13
36
+ Provides-Extra: pandas
37
+ Requires-Dist: pandas>=2.2; extra == 'pandas'
38
+ Provides-Extra: polars
39
+ Requires-Dist: polars>=1.30; extra == 'polars'
40
+ Provides-Extra: pyarrow
41
+ Requires-Dist: pyarrow>=18; extra == 'pyarrow'
42
+ Description-Content-Type: text/markdown
43
+
44
+ <h1 align="center">
45
+ <picture><img src="https://raw.githubusercontent.com/rodrigo-arenas/scikit-link/main/docs/content/public/brand/atlas-latente.svg" width="36%" align="middle" alt=""></picture>
46
+ <picture><img src="https://raw.githubusercontent.com/rodrigo-arenas/scikit-link/main/docs/content/public/brand/scikit-link-wordmark.svg" width="45%" align="middle" alt="scikit-link"></picture>
47
+ </h1>
48
+
49
+ <p align="center">
50
+ <a href="https://pypi.org/project/scikit-link/"><img src="https://img.shields.io/pypi/v/scikit-link?color=e8704e" alt="PyPI version"></a>
51
+ <a href="https://pypi.org/project/scikit-link/"><img src="https://img.shields.io/pypi/pyversions/scikit-link" alt="Python versions"></a>
52
+ <a href="https://github.com/rodrigo-arenas/scikit-link/actions/workflows/ci.yml"><img src="https://github.com/rodrigo-arenas/scikit-link/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI"></a>
53
+ <a href="https://scikit-link.rodrigo-arenas.com/stable/"><img src="https://img.shields.io/badge/docs-stable-2f6f5e" alt="Documentation"></a>
54
+ <a href="LICENSE"><img src="https://img.shields.io/pypi/l/scikit-link" alt="License: MIT"></a>
55
+ <a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff"></a>
56
+ </p>
57
+
58
+ <p align="center"><strong>Machine learning on multiple related tables, with the scikit-learn API.</strong></p>
59
+
60
+ Plenty of data lives in several tables: a customer and their orders, a
61
+ patient and their visits, a machine and its sensor readings, an account and
62
+ its transactions. scikit-link learns from those related rows directly. Put
63
+ one entity key per row in `X`, describe the tables and their keys in a
64
+ `Database`, and fit estimators that follow the keys inside ordinary
65
+ scikit-learn pipelines and cross-validation.
66
+
67
+ <p align="center">
68
+ <a href="https://scikit-link.rodrigo-arenas.com/relational-machine-learning"><img src="https://raw.githubusercontent.com/rodrigo-arenas/scikit-link/main/docs/assets/readme/how-it-works.svg" width="100%" alt="Drawn with sklink.plotting: a database of customers, orders, order items and products linked by keys, and a relational decision tree of depth two that first asks about each customer's express orders, then follows the orders to their products and asks about the share of items that are toys."></a>
69
+ </p>
70
+
71
+ <p align="center">
72
+ <a href="https://scikit-link.rodrigo-arenas.com/">Website</a> ·
73
+ <a href="https://scikit-link.rodrigo-arenas.com/stable/getting-started/quickstart">Quickstart</a> ·
74
+ <a href="https://scikit-link.rodrigo-arenas.com/stable/">Documentation</a> ·
75
+ <a href="https://scikit-link.rodrigo-arenas.com/stable/case-studies/">Case studies</a> ·
76
+ <a href="https://scikit-link.rodrigo-arenas.com/benchmarks">Benchmarks</a> ·
77
+ <a href="https://scikit-link.rodrigo-arenas.com/compare/">Comparison</a> ·
78
+ <a href="https://scikit-link.rodrigo-arenas.com/roadmap">Roadmap</a>
79
+ </p>
80
+
81
+ ## Why scikit-link
82
+
83
+ - **No hand-written joins and group-bys.** The estimators compute aggregates
84
+ of the related rows themselves, such as `count(orders[type == 'express'])`,
85
+ and relational trees learn which rows to count and with which conditions.
86
+ - **No leakage.** Every fold of a cross-validation learns its features from
87
+ its own training rows, and a cutoff date per row of `X` hides the rows that
88
+ happened after it.
89
+ - **Rules you can read.** A relational tree prints its splits as questions
90
+ about the related tables, and `explain` shows what one prediction used.
91
+ - **Everything you know from scikit-learn.** `fit`, `predict`, `Pipeline`,
92
+ `GridSearchCV`, ensembles and threshold tuning work as usual, and
93
+ `RelationalFeaturizer` feeds any scikit-learn model, XGBoost or LightGBM.
94
+
95
+ ## Install
96
+
97
+ scikit-link requires Python 3.12 or later. Install it from PyPI:
98
+
99
+ ```bash
100
+ pip install "scikit-link[pandas]"
101
+ ```
102
+
103
+ The extra installs pandas, which the examples use; `[polars]` and `[pyarrow]`
104
+ are the other table formats. Numba installs with the package and compiles the
105
+ tree loops, with the same models. The distribution is called `scikit-link` and
106
+ the import is `sklink`.
107
+
108
+ ## Quickstart
109
+
110
+ [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/rodrigo-arenas/scikit-link/blob/main/examples/quickstart.ipynb)
111
+
112
+ ```python
113
+ from sklearn.ensemble import HistGradientBoostingClassifier
114
+ from sklearn.model_selection import cross_val_score
115
+ from sklearn.pipeline import make_pipeline
116
+ from sklink.datasets import make_relational_classification
117
+ from sklink.feature_extraction import RelationalFeaturizer
118
+ from sklink.inspection import export_text
119
+ from sklink.tree import RelationalDecisionTreeClassifier
120
+
121
+ # A Database of customers, orders, order items and products, and X with one
122
+ # row per customer. Build your own with sklink.Database(tables=...,
123
+ # primary_keys=..., relationships=[("orders.customer_id", "customers.customer_id")]).
124
+ db, X, likes_toys = make_relational_classification(
125
+ 1000, signal="multihop", random_state=0
126
+ )
127
+
128
+ # The label hides a rule across tables: customers who buy toys (order items
129
+ # and their products) and placed an express order above 100 (orders).
130
+ orders = db.table("orders")
131
+ big_express = orders.query("type == 'express' and amount > 100")["customer_id"]
132
+ y = (likes_toys & X["customer_id"].isin(big_express)).astype(int)
133
+
134
+ # 1. Relational features for any scikit-learn estimator.
135
+ pipe = make_pipeline(
136
+ RelationalFeaturizer(db, entity="customers", key="customer_id"),
137
+ HistGradientBoostingClassifier(),
138
+ )
139
+ print(f"accuracy {cross_val_score(pipe, X, y, cv=5).mean():.3f}")
140
+
141
+ # 2. A decision tree that learns conditions across tables.
142
+ tree = RelationalDecisionTreeClassifier(
143
+ db, entity="customers", key="customer_id", max_depth=2, min_impurity_decrease=0.01
144
+ )
145
+ print(export_text(tree.fit(X, y)))
146
+ ```
147
+
148
+ <!-- output -->
149
+ ```text
150
+ accuracy 0.959
151
+ |--- exists(orders[amount > 100.55 & type == 'express']) <= 0.500
152
+ | |--- class: 0
153
+ |--- exists(orders[amount > 100.55 & type == 'express']) > 0.500
154
+ | |--- proportion(orders.order_items[products.category == 'toys']) <= 0.100
155
+ | | |--- class: 0
156
+ | |--- proportion(orders.order_items[products.category == 'toys']) > 0.100
157
+ | | |--- class: 1
158
+ ```
159
+
160
+ ## What you can do
161
+
162
+ | Task | How it works |
163
+ |---|---|
164
+ | Turn related rows into features for any estimator | `RelationalFeaturizer` aggregates the related rows of each entity into columns, such as the number of visits or the mean transaction amount, one row per sample, for any scikit-learn model. |
165
+ | Classify or regress directly on related tables | Relational decision trees, random forests and gradient boosting learn which related rows to aggregate while they fit. A split can ask whether an entity has any related row above a learned threshold within a learned category. |
166
+ | Cluster entities or find anomalies, without labels | `RelationalKMeans` and `RelationalClusteringTree` group entities by their related rows; `RelationalIsolationForest` ranks the entities whose related rows look unlike anyone else's. |
167
+ | Prepare the tables with scikit-learn | `TransformedTablesEstimator` fits scikit-learn transformers, such as a text embedding or a scaler, on the related rows that the training samples reach, and the model learns from the transformed tables. |
168
+ | Predict at a point in time without leakage | Give each sample a cutoff date so only earlier rows are used, and validate on later periods with `TemporalCutoffSplit`. Every fold learns its categories and thresholds from its training samples only. |
169
+ | Explain a prediction | `sklink.inspection` traces the decision path of one sample, groups feature importances by table or column, and exports fitted rules as text or JSON. |
170
+ | Plot the schema and the model | `sklink.plotting` draws the tables and keys, a fitted tree, importances and the path of one prediction, as in the gallery below. |
171
+ | Use the tables you already have | A `Database` takes pandas, Polars or PyArrow tables, dictionaries of NumPy columns, or Parquet file paths, read a few columns at a time to keep memory low on large tables. Composite keys, several levels of relationships and dated rows are supported. |
172
+ | Add your own aggregations | Register a custom primitive, such as the spread between the largest and smallest value, and request it by name. |
173
+ | Save and deploy a model | `sklink.detach` drops the tables before pickling, and `sklink.rebind` attaches fresh tables to score new entities. |
174
+ | Fit faster | The tree loops are compiled with Numba, which installs with the package, and `n_jobs` grows forest trees in parallel, with the same fitted model. |
175
+
176
+ The examples use a small shop, with customers, orders, order items and
177
+ products, because it is easy to follow; the same code applies to any tables
178
+ linked by keys.
179
+
180
+ ## Plot gallery
181
+
182
+ These four `sklink.plotting` displays use the customers and orders from
183
+ `sklink.datasets.load_shop()`. The target marks customers who placed at least
184
+ three orders. Select a figure for the full-size view or see how to create it
185
+ in the [plotting reference](https://scikit-link.rodrigo-arenas.com/stable/api/sklink.plotting).
186
+
187
+ <table>
188
+ <tr>
189
+ <td width="50%" valign="top">
190
+ <a href="https://raw.githubusercontent.com/rodrigo-arenas/scikit-link/main/docs/assets/readme/schema.png"><picture><img src="https://raw.githubusercontent.com/rodrigo-arenas/scikit-link/main/docs/assets/readme/schema.png" width="100%" alt="The customer primary key links 24 customers to 56 orders."></picture></a><br>
191
+ <strong>Database schema</strong>
192
+ </td>
193
+ <td width="50%" valign="top">
194
+ <a href="https://raw.githubusercontent.com/rodrigo-arenas/scikit-link/main/docs/assets/readme/tree.png"><picture><img src="https://raw.githubusercontent.com/rodrigo-arenas/scikit-link/main/docs/assets/readme/tree.png" width="100%" alt="The selected customer follows the branch for more than 2.5 orders."></picture></a><br>
195
+ <strong>Decision tree</strong>
196
+ </td>
197
+ </tr>
198
+ <tr>
199
+ <td width="50%" valign="top">
200
+ <a href="https://raw.githubusercontent.com/rodrigo-arenas/scikit-link/main/docs/assets/readme/importance.png"><picture><img src="https://raw.githubusercontent.com/rodrigo-arenas/scikit-link/main/docs/assets/readme/importance.png" width="100%" alt="A flow diagram breaks down forest importance by table, column and aggregation."></picture></a><br>
201
+ <strong>Feature importance</strong>
202
+ </td>
203
+ <td width="50%" valign="top">
204
+ <a href="https://raw.githubusercontent.com/rodrigo-arenas/scikit-link/main/docs/assets/readme/explanation.png"><picture><img src="https://raw.githubusercontent.com/rodrigo-arenas/scikit-link/main/docs/assets/readme/explanation.png" width="100%" alt="Order count occurs on 10 of the 16 decision paths for this customer."></picture></a><br>
205
+ <strong>One prediction</strong>
206
+ </td>
207
+ </tr>
208
+ </table>
209
+
210
+ ## Learn by example
211
+
212
+ - [Churn from raw tables to a deployed model](https://scikit-link.rodrigo-arenas.com/stable/case-studies/subscription-churn):
213
+ monthly cutoffs, temporal cross-validation, explanations and deployment.
214
+ - [scikit-learn ensembles and cost-based thresholds](https://scikit-link.rodrigo-arenas.com/stable/case-studies/scikit-learn-toolbox)
215
+ on relational models.
216
+ - [Forecasts with calibrated prediction intervals](https://scikit-link.rodrigo-arenas.com/stable/case-studies/machine-condition-intervals)
217
+ from sensor readings and repair logs.
218
+ - [Segments and anomalies without labels](https://scikit-link.rodrigo-arenas.com/stable/case-studies/segment-and-flag-accounts)
219
+ from bank transactions.
220
+ - [Migrate from Featuretools](https://scikit-link.rodrigo-arenas.com/stable/guides/migrate-from-featuretools) if you
221
+ use deep feature synthesis today.
222
+
223
+ ## How it compares
224
+
225
+ | | scikit-link | Featuretools | getML community | skrub |
226
+ |---|---|---|---|---|
227
+ | scikit-learn estimator API | Yes | Partial | No | Yes |
228
+ | Learns conditions inside aggregations | Yes | No | No | No |
229
+ | Native trees, forests and gradient boosting on related tables | Yes | No | No | No |
230
+ | Install on Windows and macOS without Docker | Yes | Yes | No | Yes |
231
+
232
+ skrub and scikit-link are meant to work together. The
233
+ [comparison page](https://scikit-link.rodrigo-arenas.com/compare/) explains when
234
+ to use each one, and the [benchmarks](https://scikit-link.rodrigo-arenas.com/benchmarks)
235
+ compare scikit-link with gradient boosting on hand-built features, on the same
236
+ splits and tuning budget.
237
+
238
+ ## Contribute
239
+
240
+ scikit-link is young, and contributions of every size help:
241
+
242
+ - **Share your schema.** Tell us about your tables and task in
243
+ [Discussions](https://github.com/rodrigo-arenas/scikit-link/discussions);
244
+ real use cases decide what comes next.
245
+ - **Report a bug or ask for a feature** in
246
+ [Issues](https://github.com/rodrigo-arenas/scikit-link/issues).
247
+ - **Add an aggregation.** A new primitive is a small, self-contained first
248
+ pull request; see [custom primitives](https://scikit-link.rodrigo-arenas.com/stable/tutorials/custom-primitives).
249
+ - **Add a benchmark** dataset or a documentation example.
250
+
251
+ [CONTRIBUTING.md](CONTRIBUTING.md) covers the development setup, the checks
252
+ and the testing policy. Security reports follow [SECURITY.md](SECURITY.md).
253
+ If scikit-link is useful to you, a star on GitHub helps others find it.
254
+
255
+ ## Citing
256
+
257
+ If scikit-link helps your research, please cite it. GitHub's "Cite this
258
+ repository" button reads [CITATION.cff](CITATION.cff); in BibTeX:
259
+
260
+ ```bibtex
261
+ @software{arenas_scikit_link,
262
+ author = {Arenas, Rodrigo},
263
+ title = {scikit-link: Machine learning on multiple related tables, with the scikit-learn API},
264
+ year = {2026},
265
+ url = {https://github.com/rodrigo-arenas/scikit-link},
266
+ license = {MIT}
267
+ }
268
+ ```
269
+
270
+ ## License
271
+
272
+ [MIT](LICENSE)