codadapt 1.0.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 (76) hide show
  1. codadapt-1.0.0/.github/workflows/publish-pypi.yml +26 -0
  2. codadapt-1.0.0/.github/workflows/publish-testpypi.yml +28 -0
  3. codadapt-1.0.0/.github/workflows/release-qualification.yml +121 -0
  4. codadapt-1.0.0/.github/workflows/tests.yml +134 -0
  5. codadapt-1.0.0/BENCHMARKS.md +594 -0
  6. codadapt-1.0.0/CHANGELOG.md +161 -0
  7. codadapt-1.0.0/CONTRIBUTING.md +32 -0
  8. codadapt-1.0.0/LICENSE +21 -0
  9. codadapt-1.0.0/MANIFEST.in +11 -0
  10. codadapt-1.0.0/PKG-INFO +566 -0
  11. codadapt-1.0.0/README.md +525 -0
  12. codadapt-1.0.0/RELEASE_NOTES.md +68 -0
  13. codadapt-1.0.0/SECURITY.md +28 -0
  14. codadapt-1.0.0/benchmarks/reproducibility/benchmark_codadapt_cv.py +262 -0
  15. codadapt-1.0.0/benchmarks/run_benchmarks.py +148 -0
  16. codadapt-1.0.0/docs/ALGORITHM.md +96 -0
  17. codadapt-1.0.0/docs/API.md +234 -0
  18. codadapt-1.0.0/docs/EBM_COMPILER.md +137 -0
  19. codadapt-1.0.0/docs/LARGE_DATASETS.md +104 -0
  20. codadapt-1.0.0/docs/PYTHON_COMPATIBILITY.md +49 -0
  21. codadapt-1.0.0/docs/RELEASING.md +53 -0
  22. codadapt-1.0.0/docs/SAFE_BLEND_EXPERIMENTAL.md +155 -0
  23. codadapt-1.0.0/docs/STABILITY.md +70 -0
  24. codadapt-1.0.0/examples/basic_classification.py +51 -0
  25. codadapt-1.0.0/examples/basic_multiclass.py +27 -0
  26. codadapt-1.0.0/examples/basic_regression.py +46 -0
  27. codadapt-1.0.0/examples/kaggle_quickstart.ipynb +369 -0
  28. codadapt-1.0.0/examples/release_smoke.py +113 -0
  29. codadapt-1.0.0/pyproject.toml +54 -0
  30. codadapt-1.0.0/setup.cfg +4 -0
  31. codadapt-1.0.0/src/codadapt/__init__.py +8 -0
  32. codadapt-1.0.0/src/codadapt/_base.py +380 -0
  33. codadapt-1.0.0/src/codadapt/_core.py +70 -0
  34. codadapt-1.0.0/src/codadapt/_multiclass.py +229 -0
  35. codadapt-1.0.0/src/codadapt/_multiclass_artifact.py +75 -0
  36. codadapt-1.0.0/src/codadapt/_multiclass_packing.py +165 -0
  37. codadapt-1.0.0/src/codadapt/_training.py +370 -0
  38. codadapt-1.0.0/src/codadapt/_version.py +1 -0
  39. codadapt-1.0.0/src/codadapt/classifier.py +117 -0
  40. codadapt-1.0.0/src/codadapt/experimental/__init__.py +13 -0
  41. codadapt-1.0.0/src/codadapt/experimental/_compiler.py +166 -0
  42. codadapt-1.0.0/src/codadapt/experimental/_model.py +174 -0
  43. codadapt-1.0.0/src/codadapt/experimental/_rational.py +133 -0
  44. codadapt-1.0.0/src/codadapt/experimental/_safe_blend.py +215 -0
  45. codadapt-1.0.0/src/codadapt/preprocessing.py +435 -0
  46. codadapt-1.0.0/src/codadapt/regressor.py +15 -0
  47. codadapt-1.0.0/src/codadapt.egg-info/PKG-INFO +566 -0
  48. codadapt-1.0.0/src/codadapt.egg-info/SOURCES.txt +74 -0
  49. codadapt-1.0.0/src/codadapt.egg-info/dependency_links.txt +1 -0
  50. codadapt-1.0.0/src/codadapt.egg-info/requires.txt +20 -0
  51. codadapt-1.0.0/src/codadapt.egg-info/top_level.txt +1 -0
  52. codadapt-1.0.0/tests/_binary_reference.py +35 -0
  53. codadapt-1.0.0/tests/_multiclass_helpers.py +85 -0
  54. codadapt-1.0.0/tests/conftest.py +17 -0
  55. codadapt-1.0.0/tests/test_adaptive_levels.py +61 -0
  56. codadapt-1.0.0/tests/test_addressing.py +50 -0
  57. codadapt-1.0.0/tests/test_classifier.py +146 -0
  58. codadapt-1.0.0/tests/test_classifier_training.py +75 -0
  59. codadapt-1.0.0/tests/test_coded_memory.py +64 -0
  60. codadapt-1.0.0/tests/test_default_api.py +102 -0
  61. codadapt-1.0.0/tests/test_ebm_compiler.py +224 -0
  62. codadapt-1.0.0/tests/test_incremental_gain.py +146 -0
  63. codadapt-1.0.0/tests/test_independence.py +45 -0
  64. codadapt-1.0.0/tests/test_memory_budget.py +152 -0
  65. codadapt-1.0.0/tests/test_multiclass.py +334 -0
  66. codadapt-1.0.0/tests/test_no_leakage.py +140 -0
  67. codadapt-1.0.0/tests/test_packaging.py +200 -0
  68. codadapt-1.0.0/tests/test_persistence.py +101 -0
  69. codadapt-1.0.0/tests/test_pre_rc_api.py +113 -0
  70. codadapt-1.0.0/tests/test_preprocessing.py +291 -0
  71. codadapt-1.0.0/tests/test_rational_callback.py +137 -0
  72. codadapt-1.0.0/tests/test_regressor.py +108 -0
  73. codadapt-1.0.0/tests/test_release_contracts.py +127 -0
  74. codadapt-1.0.0/tests/test_safe_blend.py +289 -0
  75. codadapt-1.0.0/tests/test_shared_encoder.py +65 -0
  76. codadapt-1.0.0/tests/test_sklearn_compat.py +106 -0
@@ -0,0 +1,26 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ permissions:
7
+ contents: read
8
+ id-token: write
9
+
10
+ jobs:
11
+ publish:
12
+ runs-on: ubuntu-latest
13
+ environment: pypi
14
+ steps:
15
+ - uses: actions/checkout@v7
16
+ with:
17
+ persist-credentials: false
18
+ - uses: actions/setup-python@v7
19
+ with:
20
+ python-version: "3.12"
21
+ - name: Install build
22
+ run: python -m pip install build
23
+ - name: Build wheel and sdist
24
+ run: python -m build
25
+ - name: Publish to PyPI
26
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,28 @@
1
+ name: Publish to TestPyPI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ permissions:
7
+ contents: read
8
+ id-token: write
9
+
10
+ jobs:
11
+ publish:
12
+ runs-on: ubuntu-latest
13
+ environment: testpypi
14
+ steps:
15
+ - uses: actions/checkout@v7
16
+ with:
17
+ persist-credentials: false
18
+ - uses: actions/setup-python@v7
19
+ with:
20
+ python-version: "3.12"
21
+ - name: Install build
22
+ run: python -m pip install build
23
+ - name: Build wheel and sdist
24
+ run: python -m build
25
+ - name: Publish to TestPyPI
26
+ uses: pypa/gh-action-pypi-publish@release/v1
27
+ with:
28
+ repository-url: https://test.pypi.org/legacy/
@@ -0,0 +1,121 @@
1
+ {
2
+ "name": "Manual release qualification (no publishing)",
3
+ "on": {
4
+ "workflow_dispatch": {}
5
+ },
6
+ "permissions": {
7
+ "contents": "read"
8
+ },
9
+ "env": {
10
+ "OMP_NUM_THREADS": "1",
11
+ "OPENBLAS_NUM_THREADS": "1",
12
+ "MKL_NUM_THREADS": "1",
13
+ "NUMEXPR_NUM_THREADS": "1"
14
+ },
15
+ "jobs": {
16
+ "native-artifacts": {
17
+ "runs-on": "${{ matrix.os }}",
18
+ "timeout-minutes": 30,
19
+ "strategy": {
20
+ "fail-fast": false,
21
+ "matrix": {
22
+ "os": [
23
+ "ubuntu-latest",
24
+ "windows-latest",
25
+ "macos-latest"
26
+ ],
27
+ "python": [
28
+ "3.10",
29
+ "3.11",
30
+ "3.12",
31
+ "3.13",
32
+ "3.14"
33
+ ]
34
+ }
35
+ },
36
+ "steps": [
37
+ {
38
+ "uses": "actions/checkout@v7",
39
+ "with": {
40
+ "persist-credentials": false
41
+ }
42
+ },
43
+ {
44
+ "uses": "actions/setup-python@v7",
45
+ "with": {
46
+ "python-version": "${{ matrix.python }}"
47
+ }
48
+ },
49
+ {
50
+ "name": "Install release tools",
51
+ "run": "python -m pip install \".[dev]\""
52
+ },
53
+ {
54
+ "name": "Lint, build and validate archives",
55
+ "run": "python -m ruff check .\npython -m ruff format --check .\npython -m build\npython -m twine check dist/*"
56
+ },
57
+ {
58
+ "name": "Fresh wheel and sdist qualification",
59
+ "shell": "bash",
60
+ "run": "set -euo pipefail\npython -m venv \"$RUNNER_TEMP/wheel-env\"\npython -m venv \"$RUNNER_TEMP/sdist-env\"\nif [ \"$RUNNER_OS\" = Windows ]; then exe=Scripts/python.exe; else exe=bin/python; fi\nw=\"$RUNNER_TEMP/wheel-env/$exe\"\ns=\"$RUNNER_TEMP/sdist-env/$exe\"\n\"$w\" -m pip install dist/*.whl pytest\n\"$s\" -m pip install dist/*.tar.gz\nfor p in \"$w\" \"$s\"; do\n \"$p\" -m pip check\n \"$p\" -I -c \"import numpy,scipy,scipy.linalg,pandas,sklearn; scipy.linalg.cholesky(numpy.eye(3)); import codadapt,sys; from pathlib import Path; from importlib.metadata import version; assert Path(codadapt.__file__).resolve().is_relative_to(Path(sys.prefix).resolve()); assert codadapt.__version__==version('codadapt'); print(sys.version,codadapt.__file__)\"\n \"$p\" -I -c \"import importlib.util as u; assert all(u.find_spec(n) is None for n in ['interpret','lightgbm','xgboost','catboost'])\"\ndone\n\"$w\" -I -m pytest -p no:cacheprovider --basetemp=\"$RUNNER_TEMP/pytest-wheel\" --junitxml=wheel-tests.xml\nfor pair in \"wheel:$w\" \"sdist:$s\"; do\n label=\"${pair%%:*}\"; p=\"${pair#*:}\"\n \"$p\" -I examples/release_smoke.py \"$RUNNER_TEMP/probe-$label\" fit\n \"$p\" -I examples/release_smoke.py \"$RUNNER_TEMP/probe-$label\" load\n \"$p\" -I examples/basic_classification.py\n \"$p\" -I examples/basic_multiclass.py\n \"$p\" -I examples/basic_regression.py\ndone\n"
61
+ },
62
+ {
63
+ "uses": "actions/upload-artifact@v7",
64
+ "if": "always()",
65
+ "with": {
66
+ "name": "qualification-${{ matrix.os }}-${{ matrix.python }}",
67
+ "path": "wheel-tests.xml\ndist/*",
68
+ "if-no-files-found": "error"
69
+ }
70
+ }
71
+ ]
72
+ },
73
+ "optional-ebm": {
74
+ "runs-on": "ubuntu-latest",
75
+ "timeout-minutes": 30,
76
+ "strategy": {
77
+ "fail-fast": false,
78
+ "matrix": {
79
+ "python": [
80
+ "3.10",
81
+ "3.11",
82
+ "3.12",
83
+ "3.13",
84
+ "3.14"
85
+ ]
86
+ }
87
+ },
88
+ "steps": [
89
+ {
90
+ "uses": "actions/checkout@v7",
91
+ "with": {
92
+ "persist-credentials": false
93
+ }
94
+ },
95
+ {
96
+ "uses": "actions/setup-python@v7",
97
+ "with": {
98
+ "python-version": "${{ matrix.python }}"
99
+ }
100
+ },
101
+ {
102
+ "name": "Install optional compiler",
103
+ "run": "python -m pip install \".[dev,ebm]\"\npython -m pip check"
104
+ },
105
+ {
106
+ "name": "Build and test installed optional package",
107
+ "run": "python -m build\npython -m twine check dist/*\npython -I -m pytest -p no:cacheprovider --junitxml=ebm-tests.xml"
108
+ },
109
+ {
110
+ "uses": "actions/upload-artifact@v7",
111
+ "if": "always()",
112
+ "with": {
113
+ "name": "optional-ebm-${{ matrix.python }}",
114
+ "path": "ebm-tests.xml",
115
+ "if-no-files-found": "error"
116
+ }
117
+ }
118
+ ]
119
+ }
120
+ }
121
+ }
@@ -0,0 +1,134 @@
1
+ name: Tests and distributions
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ env:
12
+ OMP_NUM_THREADS: "1"
13
+ OPENBLAS_NUM_THREADS: "1"
14
+ MKL_NUM_THREADS: "1"
15
+ NUMEXPR_NUM_THREADS: "1"
16
+
17
+ jobs:
18
+ test:
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ fail-fast: false
22
+ matrix:
23
+ include:
24
+ - python: "3.10"
25
+ dependencies: minimum
26
+ - python: "3.14"
27
+ dependencies: modern
28
+ steps:
29
+ - uses: actions/checkout@v7
30
+ with:
31
+ persist-credentials: false
32
+ - uses: actions/setup-python@v7
33
+ with:
34
+ python-version: ${{ matrix.python }}
35
+ cache: pip
36
+ cache-dependency-path: pyproject.toml
37
+ - name: Freeze the selected core numerical stack
38
+ shell: bash
39
+ run: |
40
+ case "${{ matrix.dependencies }}" in
41
+ minimum) pins="numpy==1.24.0 pandas==2.0.0 scikit-learn==1.4.0 scipy==1.8.0" ;;
42
+ recent) pins="numpy==2.3.5 pandas==2.2.3 scikit-learn==1.8.0 scipy==1.16.2" ;;
43
+ modern) pins="numpy==2.5.3 pandas==2.3.3 scikit-learn==1.9.0 scipy==1.18.1" ;;
44
+ *) exit 1 ;;
45
+ esac
46
+ printf '%s\n' $pins > "$RUNNER_TEMP/codadapt-core-constraints.txt"
47
+ echo "PIP_CONSTRAINT=$RUNNER_TEMP/codadapt-core-constraints.txt" >> "$GITHUB_ENV"
48
+ - name: Install minimum dependencies
49
+ if: matrix.dependencies == 'minimum'
50
+ run: python -m pip install -c "$PIP_CONSTRAINT" -e ".[dev]"
51
+ - name: Install recent verified dependency versions
52
+ if: matrix.dependencies == 'recent'
53
+ run: python -m pip install -c "$PIP_CONSTRAINT" -e ".[dev]"
54
+ - name: Install the modern numerical stack verified locally
55
+ if: matrix.dependencies == 'modern'
56
+ run: python -m pip install -c "$PIP_CONSTRAINT" -e ".[dev]"
57
+ - name: Record core dependency versions
58
+ run: |
59
+ python -m pip check
60
+ python -c "import sys,numpy,scipy,pandas,sklearn; print(sys.version); print(numpy.__version__,scipy.__version__,pandas.__version__,sklearn.__version__)"
61
+ - name: Lint and format
62
+ run: |
63
+ python -m ruff check .
64
+ python -m ruff format --check .
65
+ - name: Verify native installation has no external learners
66
+ run: python -c "import importlib.util as u; assert all(u.find_spec(n) is None for n in ['lightgbm','interpret','xgboost','catboost'])"
67
+ - name: Tests
68
+ run: python -m pytest
69
+ - name: Build and validate distributions
70
+ run: |
71
+ python -m build
72
+ python -m twine check dist/*
73
+ python -m pytest tests/test_packaging.py
74
+ - name: Install wheel in a clean environment and run examples
75
+ run: |
76
+ python -m venv "$RUNNER_TEMP/codadapt-wheel"
77
+ "$RUNNER_TEMP/codadapt-wheel/bin/python" -m pip install dist/codadapt-*-py3-none-any.whl
78
+ mkdir -p "$RUNNER_TEMP/codadapt-smoke"
79
+ cp examples/basic_classification.py examples/basic_multiclass.py examples/basic_regression.py "$RUNNER_TEMP/codadapt-smoke/"
80
+ cd "$RUNNER_TEMP/codadapt-smoke"
81
+ "$RUNNER_TEMP/codadapt-wheel/bin/python" -c "import codadapt; from importlib.metadata import version; print(codadapt.__version__, codadapt.__file__); assert codadapt.__version__ == version('codadapt')"
82
+ "$RUNNER_TEMP/codadapt-wheel/bin/python" basic_classification.py
83
+ "$RUNNER_TEMP/codadapt-wheel/bin/python" basic_multiclass.py
84
+ "$RUNNER_TEMP/codadapt-wheel/bin/python" basic_regression.py
85
+ - name: Execute example notebook against installed wheel
86
+ if: matrix.python == '3.14'
87
+ run: |
88
+ "$RUNNER_TEMP/codadapt-wheel/bin/python" -m pip install nbformat nbclient ipykernel
89
+ "$RUNNER_TEMP/codadapt-wheel/bin/python" -m ipykernel install --prefix "$RUNNER_TEMP/codadapt-wheel" --name codadapt-wheel
90
+ cp examples/kaggle_quickstart.ipynb "$RUNNER_TEMP/codadapt-smoke/"
91
+ cd "$RUNNER_TEMP/codadapt-smoke"
92
+ "$RUNNER_TEMP/codadapt-wheel/bin/python" -c "import nbformat; from nbclient import NotebookClient; n=nbformat.read('kaggle_quickstart.ipynb', as_version=4); NotebookClient(n, timeout=600, kernel_name='codadapt-wheel').execute(); nbformat.write(n, 'kaggle_quickstart.executed.ipynb')"
93
+ - uses: actions/upload-artifact@v7
94
+ if: matrix.python == '3.14'
95
+ with:
96
+ name: codadapt-distributions
97
+ path: dist/*
98
+ if-no-files-found: error
99
+
100
+ experimental-ebm:
101
+ runs-on: ubuntu-latest
102
+ strategy:
103
+ matrix:
104
+ include:
105
+ - python: "3.12"
106
+ numpy: "2.5.3"
107
+ pandas: "2.3.3"
108
+ sklearn: "1.9.0"
109
+ scipy: "1.18.1"
110
+ steps:
111
+ - uses: actions/checkout@v7
112
+ with:
113
+ persist-credentials: false
114
+ - uses: actions/setup-python@v7
115
+ with:
116
+ python-version: ${{ matrix.python }}
117
+ - name: Freeze EBM numerical dependencies
118
+ run: |
119
+ cat > "$RUNNER_TEMP/ebm-constraints.txt" <<'EOF'
120
+ numpy==${{ matrix.numpy }}
121
+ pandas==${{ matrix.pandas }}
122
+ scikit-learn==${{ matrix.sklearn }}
123
+ scipy==${{ matrix.scipy }}
124
+ interpret-core==0.7.8
125
+ EOF
126
+ echo "PIP_CONSTRAINT=$RUNNER_TEMP/ebm-constraints.txt" >> "$GITHUB_ENV"
127
+ - run: |
128
+ python -m pip install -c "$PIP_CONSTRAINT" ".[dev,ebm]"
129
+ python -m pip install --no-deps -e .
130
+ python -m pip check
131
+ python -c "import sys,importlib.metadata as m; print(sys.version); print({n:m.version(n) for n in ['numpy','scipy','pandas','scikit-learn','interpret-core']})"
132
+ - run: python -m build
133
+ - run: python -m pytest
134
+