ebaml 0.3.3__tar.gz → 0.4.1__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.
- {ebaml-0.3.3 → ebaml-0.4.1}/PKG-INFO +16 -1
- {ebaml-0.3.3 → ebaml-0.4.1}/README.md +8 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/pyproject.toml +82 -4
- {ebaml-0.3.3 → ebaml-0.4.1}/pyproject.toml.orig +56 -6
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/core/custom_types.py +11 -3
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/local/facts.py +6 -3
- ebaml-0.4.1/src/ebaml/mcp/__init__.py +4 -0
- ebaml-0.4.1/src/ebaml/mcp/explain_tools.py +71 -0
- ebaml-0.4.1/src/ebaml/mcp/llm_tools.py +47 -0
- ebaml-0.4.1/src/ebaml/mcp/model_store.py +178 -0
- ebaml-0.4.1/src/ebaml/mcp/read_tools.py +155 -0
- ebaml-0.4.1/src/ebaml/mcp/server.py +252 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/LICENSE +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/.baml-generator-output-root +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/.baml-generator-output.json +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/.gitignore +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/_baml_sources.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/_function_registry.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/_inlinedbaml.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/_invocation_types.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/_invocation_types.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/_typemap.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/clients/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/clients/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/content/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/content/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/errors/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/errors/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/events/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/events/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/internal/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/internal/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/mcp/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/mcp/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/stream/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/stream/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/tools/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/tools/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/wire/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/ai/wire/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/crypto/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/crypto/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/csv/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/csv/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/env/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/env/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/errors/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/errors/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/fs/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/fs/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/future/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/future/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/glob/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/glob/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/hash/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/hash/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/host/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/host/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/http/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/http/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/io/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/io/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/iter/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/iter/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/json/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/json/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/media/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/media/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/net/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/net/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/ops/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/ops/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/panics/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/panics/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/random/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/random/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/regex/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/regex/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/sap/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/sap/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/spawn/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/spawn/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/sys/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/sys/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/time/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/time/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/toml/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/toml/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/ws/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/ws/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/yaml/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/baml/yaml/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/experimental/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/experimental/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/py.typed +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/reflect/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/reflect/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/reflect/class_/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/reflect/class_/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/reflect/enum/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/reflect/enum/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/reflect/errors/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/reflect/errors/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/reflect/function/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/reflect/function/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/reflect/interface/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/reflect/interface/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/anthropic/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/anthropic/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/anthropic/internal/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/anthropic/internal/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/assert_/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/assert_/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/aws/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/aws/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/aws/internal/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/aws/internal/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/claude_code/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/claude_code/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/claude_code/internal/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/claude_code/internal/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/google/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/google/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/google/internal/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/google/internal/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/openai/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/openai/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/openai/internal/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/openai/internal/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/openai/internal/decisions/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/openai/internal/decisions/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/testing/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/testing/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/trace/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/trace/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/typesafeai/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/typesafeai/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/typesafeai/internal/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/typesafeai/internal/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/vercel/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/vercel/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/vercel/internal/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/baml_sdk/vendor/vercel/internal/__init__.pyi +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/benchmark.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/core/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/core/exceptions.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/graphs/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/graphs/ebm_graph.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/graphs/graph_text.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/graphs/model_kinds.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/graphs/request_text.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/graphs/terms.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/graphs/token_budget.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/graphs/token_weights.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/llm/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/llm/descriptors.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/llm/options.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/llm/provider_errors.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/llm/retry.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/llm/sdk_setup.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/llm/token_learning.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/llm/token_weights.json +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/local/__init__.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/local/audience.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/local/fact_text.py +0 -0
- {ebaml-0.3.3 → ebaml-0.4.1}/src/ebaml/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ebaml
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: BAML for Explainable Boosting Machines: talk to your EBM.
|
|
5
5
|
Keywords: baml,llm,explainable-ai,explainable-boosting-machine,interpretml
|
|
6
6
|
Author: Johnny Godoy
|
|
@@ -17,16 +17,23 @@ Requires-Dist: attrs>=26.1.0
|
|
|
17
17
|
Requires-Dist: baml-bridge>=0.23.0
|
|
18
18
|
Requires-Dist: beartype>=0.23.1
|
|
19
19
|
Requires-Dist: interpret>=0.7.8
|
|
20
|
+
Requires-Dist: narwhals>=2.27.1
|
|
20
21
|
Requires-Dist: numpy>=2.5.4
|
|
21
22
|
Requires-Dist: orjson>=3.13.0
|
|
22
23
|
Requires-Dist: pandas>=3.0.6
|
|
23
24
|
Requires-Dist: scipy>=1.18.1
|
|
24
25
|
Requires-Dist: structlog>=26.1.0
|
|
26
|
+
Requires-Dist: cyclopts>=5.2.0 ; extra == 'mcp'
|
|
27
|
+
Requires-Dist: joblib>=1.5.0 ; extra == 'mcp'
|
|
28
|
+
Requires-Dist: mcp>=1.30.0 ; extra == 'mcp'
|
|
29
|
+
Requires-Dist: polars>=2.0.0 ; extra == 'mcp'
|
|
30
|
+
Requires-Dist: skops>=0.16.0 ; extra == 'mcp'
|
|
25
31
|
Requires-Python: >=3.13
|
|
26
32
|
Project-URL: Documentation, https://johnny-godoy.github.io/EBaMl/
|
|
27
33
|
Project-URL: Source, https://github.com/johnny-godoy/EBaMl
|
|
28
34
|
Project-URL: Issues, https://github.com/johnny-godoy/EBaMl/issues
|
|
29
35
|
Project-URL: Changelog, https://github.com/johnny-godoy/EBaMl/blob/main/CHANGELOG.md
|
|
36
|
+
Provides-Extra: mcp
|
|
30
37
|
Description-Content-Type: text/markdown
|
|
31
38
|
|
|
32
39
|
# EBaMl
|
|
@@ -52,11 +59,13 @@ LLM calls go through [OpenRouter](https://openrouter.ai)'s free router (`openrou
|
|
|
52
59
|
| Model summary (`describe_ebm`) | ✅ | ✅ | ✅ | ⚠️ |
|
|
53
60
|
| Graph text (`EBMGraph`) | ✅ | ✅ | ✅ | ⚠️ |
|
|
54
61
|
| Local explanations (`explain_instance`) | ✅ | ❌ | ❌ | ❌ |
|
|
62
|
+
| MCP server (`ebaml-mcp`) | ✅ | ✅ | ✅ | ⚠️ |
|
|
55
63
|
|
|
56
64
|
✅ supported. ⚠️ partly supported: the main effects are described, and the interaction terms are skipped.
|
|
57
65
|
`describe_graph` and `describe_ebm` log an `interactions_skipped` warning that names them. ❌ not supported yet. Full support is on the
|
|
58
66
|
[roadmap](https://github.com/johnny-godoy/EBaMl/blob/main/ROADMAP.md).
|
|
59
67
|
<!-- --8<-- [end:supported-models] -->
|
|
68
|
+
The MCP server reads every kind of model. Its explain tool works for binary classifiers only.
|
|
60
69
|
## Setup
|
|
61
70
|
|
|
62
71
|
<!-- --8<-- [start:setup] -->
|
|
@@ -342,6 +351,12 @@ graph.
|
|
|
342
351
|
uv run marimo edit notebooks/model_kinds.py
|
|
343
352
|
```
|
|
344
353
|
|
|
354
|
+
## MCP server
|
|
355
|
+
|
|
356
|
+
`ebaml-mcp` serves a fitted EBM to an agent, for example Claude Code. The agent reads the features and the graphs, and
|
|
357
|
+
explains one prediction with the exact local facts. These tools call no LLM, so they need no key. See the
|
|
358
|
+
[MCP server guide](https://johnny-godoy.github.io/EBaMl/mcp/).
|
|
359
|
+
|
|
345
360
|
## Benchmark
|
|
346
361
|
|
|
347
362
|
The benchmark follows [TalkToEBM's benchmark](https://github.com/interpretml/TalkToEBM/tree/main/benchmark) that checks how well a
|
|
@@ -21,11 +21,13 @@ LLM calls go through [OpenRouter](https://openrouter.ai)'s free router (`openrou
|
|
|
21
21
|
| Model summary (`describe_ebm`) | ✅ | ✅ | ✅ | ⚠️ |
|
|
22
22
|
| Graph text (`EBMGraph`) | ✅ | ✅ | ✅ | ⚠️ |
|
|
23
23
|
| Local explanations (`explain_instance`) | ✅ | ❌ | ❌ | ❌ |
|
|
24
|
+
| MCP server (`ebaml-mcp`) | ✅ | ✅ | ✅ | ⚠️ |
|
|
24
25
|
|
|
25
26
|
✅ supported. ⚠️ partly supported: the main effects are described, and the interaction terms are skipped.
|
|
26
27
|
`describe_graph` and `describe_ebm` log an `interactions_skipped` warning that names them. ❌ not supported yet. Full support is on the
|
|
27
28
|
[roadmap](https://github.com/johnny-godoy/EBaMl/blob/main/ROADMAP.md).
|
|
28
29
|
<!-- --8<-- [end:supported-models] -->
|
|
30
|
+
The MCP server reads every kind of model. Its explain tool works for binary classifiers only.
|
|
29
31
|
## Setup
|
|
30
32
|
|
|
31
33
|
<!-- --8<-- [start:setup] -->
|
|
@@ -311,6 +313,12 @@ graph.
|
|
|
311
313
|
uv run marimo edit notebooks/model_kinds.py
|
|
312
314
|
```
|
|
313
315
|
|
|
316
|
+
## MCP server
|
|
317
|
+
|
|
318
|
+
`ebaml-mcp` serves a fitted EBM to an agent, for example Claude Code. The agent reads the features and the graphs, and
|
|
319
|
+
explains one prediction with the exact local facts. These tools call no LLM, so they need no key. See the
|
|
320
|
+
[MCP server guide](https://johnny-godoy.github.io/EBaMl/mcp/).
|
|
321
|
+
|
|
314
322
|
## Benchmark
|
|
315
323
|
|
|
316
324
|
The benchmark follows [TalkToEBM's benchmark](https://github.com/interpretml/TalkToEBM/tree/main/benchmark) that checks how well a
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "ebaml"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.1"
|
|
4
4
|
description = "BAML for Explainable Boosting Machines: talk to your EBM."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -26,6 +26,7 @@ dependencies = [
|
|
|
26
26
|
"baml-bridge>=0.23.0",
|
|
27
27
|
"beartype>=0.23.1",
|
|
28
28
|
"interpret>=0.7.8",
|
|
29
|
+
"narwhals>=2.27.1",
|
|
29
30
|
"numpy>=2.5.4",
|
|
30
31
|
"orjson>=3.13.0",
|
|
31
32
|
"pandas>=3.0.6",
|
|
@@ -37,6 +38,18 @@ dependencies = [
|
|
|
37
38
|
name = "Johnny Godoy"
|
|
38
39
|
email = "johnny.godoy@ing.uchile.cl"
|
|
39
40
|
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
mcp = [
|
|
43
|
+
"cyclopts>=5.2.0",
|
|
44
|
+
"joblib>=1.5.0",
|
|
45
|
+
"mcp>=1.30.0",
|
|
46
|
+
"polars>=2.0.0",
|
|
47
|
+
"skops>=0.16.0",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[project.scripts]
|
|
51
|
+
ebaml-mcp = "ebaml.mcp.server:main"
|
|
52
|
+
|
|
40
53
|
[project.urls]
|
|
41
54
|
Documentation = "https://johnny-godoy.github.io/EBaMl/"
|
|
42
55
|
Source = "https://github.com/johnny-godoy/EBaMl"
|
|
@@ -110,6 +123,36 @@ ignore = ["missing-copyright-notice"]
|
|
|
110
123
|
preview = true
|
|
111
124
|
select = ["ALL"]
|
|
112
125
|
|
|
126
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api.argparse]
|
|
127
|
+
msg = "Use cyclopts. See .claude/rules/libraries.md."
|
|
128
|
+
|
|
129
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api.cloudpickle]
|
|
130
|
+
msg = "Use skops.io. See .claude/rules/libraries.md."
|
|
131
|
+
|
|
132
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api.dataclasses]
|
|
133
|
+
msg = "Use attrs. See .claude/rules/libraries.md."
|
|
134
|
+
|
|
135
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api.dill]
|
|
136
|
+
msg = "Use skops.io. See .claude/rules/libraries.md."
|
|
137
|
+
|
|
138
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api.joblib]
|
|
139
|
+
msg = "Use skops.io. See .claude/rules/libraries.md."
|
|
140
|
+
|
|
141
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api.json]
|
|
142
|
+
msg = "Use orjson. See .claude/rules/libraries.md."
|
|
143
|
+
|
|
144
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api.logging]
|
|
145
|
+
msg = "Use structlog. See .claude/rules/libraries.md."
|
|
146
|
+
|
|
147
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api.pandas]
|
|
148
|
+
msg = "Take a frame with narwhals, or read data with polars. See .claude/rules/libraries.md."
|
|
149
|
+
|
|
150
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api.pickle]
|
|
151
|
+
msg = "Use skops.io. See .claude/rules/libraries.md."
|
|
152
|
+
|
|
153
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api.shelve]
|
|
154
|
+
msg = "Use skops.io. See .claude/rules/libraries.md."
|
|
155
|
+
|
|
113
156
|
[tool.ruff.lint.per-file-ignores]
|
|
114
157
|
"tests/**/*.py" = [
|
|
115
158
|
"undocumented-public-function",
|
|
@@ -128,7 +171,13 @@ select = ["ALL"]
|
|
|
128
171
|
]
|
|
129
172
|
|
|
130
173
|
[tool.vulture]
|
|
131
|
-
ignore_decorators = [
|
|
174
|
+
ignore_decorators = [
|
|
175
|
+
"@pytest.fixture",
|
|
176
|
+
"@server.tool",
|
|
177
|
+
"@server.resource",
|
|
178
|
+
"@app.default",
|
|
179
|
+
"@app.command*",
|
|
180
|
+
]
|
|
132
181
|
ignore_names = [
|
|
133
182
|
"pytestmark",
|
|
134
183
|
"pytest_*",
|
|
@@ -152,9 +201,10 @@ root_package = "ebaml"
|
|
|
152
201
|
include_external_packages = true
|
|
153
202
|
|
|
154
203
|
[[tool.importlinter.contracts]]
|
|
155
|
-
name = "Layers: llm over local over graphs over core"
|
|
204
|
+
name = "Layers: mcp over llm over local over graphs over core"
|
|
156
205
|
type = "layers"
|
|
157
206
|
layers = [
|
|
207
|
+
"ebaml.mcp",
|
|
158
208
|
"ebaml.llm",
|
|
159
209
|
"ebaml.local",
|
|
160
210
|
"ebaml.graphs",
|
|
@@ -175,6 +225,28 @@ forbidden_modules = [
|
|
|
175
225
|
"baml_bridge",
|
|
176
226
|
]
|
|
177
227
|
|
|
228
|
+
[[tool.importlinter.contracts]]
|
|
229
|
+
name = "The MCP layer reaches the BAML SDK only through ebaml.llm"
|
|
230
|
+
type = "forbidden"
|
|
231
|
+
source_modules = ["ebaml.mcp"]
|
|
232
|
+
forbidden_modules = [
|
|
233
|
+
"baml_sdk",
|
|
234
|
+
"baml_bridge",
|
|
235
|
+
]
|
|
236
|
+
allow_indirect_imports = true
|
|
237
|
+
|
|
238
|
+
[[tool.importlinter.contracts]]
|
|
239
|
+
name = "Only ebaml.mcp imports the MCP SDK"
|
|
240
|
+
type = "forbidden"
|
|
241
|
+
source_modules = [
|
|
242
|
+
"ebaml.core",
|
|
243
|
+
"ebaml.graphs",
|
|
244
|
+
"ebaml.local",
|
|
245
|
+
"ebaml.llm",
|
|
246
|
+
"ebaml.benchmark",
|
|
247
|
+
]
|
|
248
|
+
forbidden_modules = ["mcp"]
|
|
249
|
+
|
|
178
250
|
[[tool.importlinter.contracts]]
|
|
179
251
|
name = "Only llm.descriptors imports the BAML SDK"
|
|
180
252
|
type = "forbidden"
|
|
@@ -198,6 +270,7 @@ forbidden_modules = [
|
|
|
198
270
|
"ebaml.graphs",
|
|
199
271
|
"ebaml.local",
|
|
200
272
|
"ebaml.llm",
|
|
273
|
+
"ebaml.mcp",
|
|
201
274
|
]
|
|
202
275
|
|
|
203
276
|
[tool.pyrefly]
|
|
@@ -267,6 +340,7 @@ build-backend = "uv_build"
|
|
|
267
340
|
[dependency-groups]
|
|
268
341
|
dev = [
|
|
269
342
|
"cosmic-ray>=8.7.0",
|
|
343
|
+
"cyclopts>=5.2.0",
|
|
270
344
|
"deptry>=0.25.1",
|
|
271
345
|
"hypothesis>=6.170.1",
|
|
272
346
|
"import-linter>=2.15",
|
|
@@ -281,6 +355,7 @@ dev = [
|
|
|
281
355
|
"ruff>=0.17.0",
|
|
282
356
|
"scipy-stubs>=1.18.1.1",
|
|
283
357
|
"semgrep>=1.181.0",
|
|
358
|
+
"skops>=0.16.0",
|
|
284
359
|
"sybil>=10.1.0",
|
|
285
360
|
"types-pyyaml>=6.0.12.20260906",
|
|
286
361
|
"typst>=0.15.0",
|
|
@@ -292,5 +367,8 @@ docs = [
|
|
|
292
367
|
"mkdocstrings[python]>=1.0.7",
|
|
293
368
|
"zensical>=0.0.71",
|
|
294
369
|
]
|
|
295
|
-
commits = [
|
|
370
|
+
commits = [
|
|
371
|
+
"commitizen>=4.19.2",
|
|
372
|
+
"cyclopts>=5.2.0",
|
|
373
|
+
]
|
|
296
374
|
release = ["scriv>=1.8.0"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "ebaml"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.1"
|
|
4
4
|
description = "BAML for Explainable Boosting Machines: talk to your EBM."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -23,13 +23,30 @@ dependencies = [
|
|
|
23
23
|
"baml-bridge>=0.23.0",
|
|
24
24
|
"beartype>=0.23.1",
|
|
25
25
|
"interpret>=0.7.8",
|
|
26
|
+
"narwhals>=2.27.1",
|
|
26
27
|
"numpy>=2.5.4",
|
|
27
28
|
"orjson>=3.13.0",
|
|
29
|
+
# only ebaml.core.custom_types imports it, for the type of pd.NA
|
|
28
30
|
"pandas>=3.0.6",
|
|
29
31
|
"scipy>=1.18.1",
|
|
30
32
|
"structlog>=26.1.0",
|
|
31
33
|
]
|
|
32
34
|
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
# The server for agents. Only ebaml.mcp imports these packages. The lower bound of mcp matches the override in
|
|
37
|
+
# the uv override list, so the extra keeps the fixed release after the override goes away.
|
|
38
|
+
mcp = [
|
|
39
|
+
"cyclopts>=5.2.0",
|
|
40
|
+
"joblib>=1.5.0",
|
|
41
|
+
"mcp>=1.30.0",
|
|
42
|
+
# ebaml.mcp reads the CSV file of --data with polars
|
|
43
|
+
"polars>=2.0.0",
|
|
44
|
+
"skops>=0.16.0",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[project.scripts]
|
|
48
|
+
ebaml-mcp = "ebaml.mcp.server:main"
|
|
49
|
+
|
|
33
50
|
[project.urls]
|
|
34
51
|
Documentation = "https://johnny-godoy.github.io/EBaMl/"
|
|
35
52
|
Source = "https://github.com/johnny-godoy/EBaMl"
|
|
@@ -116,6 +133,20 @@ ignore = [
|
|
|
116
133
|
preview = true
|
|
117
134
|
select = ["ALL"]
|
|
118
135
|
|
|
136
|
+
# Each banned module names its replacement. Ruff fails in the editor and shows the message; an exception is an inline
|
|
137
|
+
# `# ruff: ignore[banned-api] -- <reason>` on the import.
|
|
138
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
|
|
139
|
+
"argparse".msg = "Use cyclopts. See .claude/rules/libraries.md."
|
|
140
|
+
"cloudpickle".msg = "Use skops.io. See .claude/rules/libraries.md."
|
|
141
|
+
"dataclasses".msg = "Use attrs. See .claude/rules/libraries.md."
|
|
142
|
+
"dill".msg = "Use skops.io. See .claude/rules/libraries.md."
|
|
143
|
+
"joblib".msg = "Use skops.io. See .claude/rules/libraries.md."
|
|
144
|
+
"json".msg = "Use orjson. See .claude/rules/libraries.md."
|
|
145
|
+
"logging".msg = "Use structlog. See .claude/rules/libraries.md."
|
|
146
|
+
"pandas".msg = "Take a frame with narwhals, or read data with polars. See .claude/rules/libraries.md."
|
|
147
|
+
"pickle".msg = "Use skops.io. See .claude/rules/libraries.md."
|
|
148
|
+
"shelve".msg = "Use skops.io. See .claude/rules/libraries.md."
|
|
149
|
+
|
|
119
150
|
[tool.ruff.lint.per-file-ignores]
|
|
120
151
|
# reason: recurring pattern in tests/: pytest tests use bare assert, literal expected values and private members by design,
|
|
121
152
|
# and are not public API, so docstrings are not required.
|
|
@@ -136,6 +167,7 @@ select = ["ALL"]
|
|
|
136
167
|
[dependency-groups]
|
|
137
168
|
dev = [
|
|
138
169
|
"cosmic-ray>=8.7.0",
|
|
170
|
+
"cyclopts>=5.2.0",
|
|
139
171
|
"deptry>=0.25.1",
|
|
140
172
|
"hypothesis>=6.170.1",
|
|
141
173
|
"import-linter>=2.15",
|
|
@@ -150,6 +182,7 @@ dev = [
|
|
|
150
182
|
"ruff>=0.17.0",
|
|
151
183
|
"scipy-stubs>=1.18.1.1",
|
|
152
184
|
"semgrep>=1.181.0",
|
|
185
|
+
"skops>=0.16.0",
|
|
153
186
|
"sybil>=10.1.0",
|
|
154
187
|
"types-pyyaml>=6.0.12.20260906",
|
|
155
188
|
"typst>=0.15.0",
|
|
@@ -164,6 +197,7 @@ docs = [
|
|
|
164
197
|
# the commit-msg hook and the commits workflow install only this group to check commit messages
|
|
165
198
|
commits = [
|
|
166
199
|
"commitizen>=4.19.2",
|
|
200
|
+
"cyclopts>=5.2.0",
|
|
167
201
|
]
|
|
168
202
|
# the release workflow installs only this group to collect the changelog fragments
|
|
169
203
|
release = [
|
|
@@ -171,8 +205,10 @@ release = [
|
|
|
171
205
|
]
|
|
172
206
|
|
|
173
207
|
[tool.vulture]
|
|
174
|
-
# reason: fixtures are used through pytest's name-based injection,
|
|
175
|
-
|
|
208
|
+
# reason: recurring patterns: fixtures are used through pytest's name-based injection, and the functions that
|
|
209
|
+
# @server.tool and @server.resource register are called by the MCP SDK by name, and cyclopts calls the functions that
|
|
210
|
+
# @app.default and @app.command register from the command line. Vulture cannot see any of them.
|
|
211
|
+
ignore_decorators = ["@pytest.fixture", "@server.tool", "@server.resource", "@app.default", "@app.command*"]
|
|
176
212
|
# reason: pytest reads pytestmark and the pytest_* hooks of a conftest.py by name, code never references them, so vulture
|
|
177
213
|
# reports them as unused.
|
|
178
214
|
ignore_names = ["pytestmark", "pytest_*"]
|
|
@@ -197,9 +233,9 @@ root_package = "ebaml"
|
|
|
197
233
|
include_external_packages = true
|
|
198
234
|
|
|
199
235
|
[[tool.importlinter.contracts]]
|
|
200
|
-
name = "Layers: llm over local over graphs over core"
|
|
236
|
+
name = "Layers: mcp over llm over local over graphs over core"
|
|
201
237
|
type = "layers"
|
|
202
|
-
layers = ["ebaml.llm", "ebaml.local", "ebaml.graphs", "ebaml.core"]
|
|
238
|
+
layers = ["ebaml.mcp", "ebaml.llm", "ebaml.local", "ebaml.graphs", "ebaml.core"]
|
|
203
239
|
|
|
204
240
|
[[tool.importlinter.contracts]]
|
|
205
241
|
name = "Domain code does not import the BAML SDK"
|
|
@@ -207,6 +243,20 @@ type = "forbidden"
|
|
|
207
243
|
source_modules = ["ebaml.core", "ebaml.graphs", "ebaml.local", "ebaml.benchmark"]
|
|
208
244
|
forbidden_modules = ["baml_sdk", "baml_bridge"]
|
|
209
245
|
|
|
246
|
+
[[tool.importlinter.contracts]]
|
|
247
|
+
name = "The MCP layer reaches the BAML SDK only through ebaml.llm"
|
|
248
|
+
type = "forbidden"
|
|
249
|
+
source_modules = ["ebaml.mcp"]
|
|
250
|
+
forbidden_modules = ["baml_sdk", "baml_bridge"]
|
|
251
|
+
# reason: ebaml.mcp calls describe_graph and describe_ebm of ebaml.llm, which import the SDK, so only a direct import is wrong.
|
|
252
|
+
allow_indirect_imports = true
|
|
253
|
+
|
|
254
|
+
[[tool.importlinter.contracts]]
|
|
255
|
+
name = "Only ebaml.mcp imports the MCP SDK"
|
|
256
|
+
type = "forbidden"
|
|
257
|
+
source_modules = ["ebaml.core", "ebaml.graphs", "ebaml.local", "ebaml.llm", "ebaml.benchmark"]
|
|
258
|
+
forbidden_modules = ["mcp"]
|
|
259
|
+
|
|
210
260
|
[[tool.importlinter.contracts]]
|
|
211
261
|
name = "Only llm.descriptors imports the BAML SDK"
|
|
212
262
|
type = "forbidden"
|
|
@@ -226,7 +276,7 @@ ignore_imports = [
|
|
|
226
276
|
name = "The benchmark stands alone"
|
|
227
277
|
type = "forbidden"
|
|
228
278
|
source_modules = ["ebaml.benchmark"]
|
|
229
|
-
forbidden_modules = ["ebaml.core", "ebaml.graphs", "ebaml.local", "ebaml.llm"]
|
|
279
|
+
forbidden_modules = ["ebaml.core", "ebaml.graphs", "ebaml.local", "ebaml.llm", "ebaml.mcp"]
|
|
230
280
|
|
|
231
281
|
[tool.pyrefly]
|
|
232
282
|
# The strict preset reports implicit `Any` in parameters, lambdas, attributes, empty containers and type arguments.
|
|
@@ -4,18 +4,25 @@ import enum
|
|
|
4
4
|
from collections.abc import Iterable, Mapping, Sequence
|
|
5
5
|
from collections.abc import Set as AbstractSet
|
|
6
6
|
from decimal import Decimal
|
|
7
|
+
from typing import Any
|
|
7
8
|
|
|
9
|
+
import narwhals as nw
|
|
8
10
|
import numpy as np
|
|
9
11
|
from interpret.glassbox import (
|
|
10
12
|
ExplainableBoostingClassifier, # pyrefly: ignore[implicit-reexport] -- interpret.glassbox has no __all__, so pyrefly reads its public classes as private imports
|
|
11
13
|
ExplainableBoostingRegressor, # pyrefly: ignore[implicit-reexport] -- interpret.glassbox has no __all__, so pyrefly reads its public classes as private imports
|
|
12
14
|
)
|
|
13
|
-
from pandas.api.typing import NAType
|
|
15
|
+
from pandas.api.typing import NAType # ruff: ignore[banned-api] -- pd.NA has a type of its own, and only pandas exports it
|
|
14
16
|
|
|
15
17
|
from ebaml.core.exceptions import InvalidOptionError
|
|
16
18
|
|
|
17
19
|
ExplainableBoostingModel = ExplainableBoostingClassifier | ExplainableBoostingRegressor
|
|
18
20
|
|
|
21
|
+
# The type of pd.NA. This is the only place in ebaml that imports pandas, so the rest of the code stays neutral.
|
|
22
|
+
PANDAS_NA_TYPE: type[NAType] = NAType
|
|
23
|
+
|
|
24
|
+
# A data frame of any library that narwhals supports.
|
|
25
|
+
type Frame = nw.DataFrame[Any]
|
|
19
26
|
# A label of a class, as NumPy's tolist() and item() return it. The numeric tower lets float cover int and bool.
|
|
20
27
|
type ClassLabel = str | float
|
|
21
28
|
# A value of one feature of an instance. A row of a pandas DataFrame gives NumPy scalars, a nullable column gives pd.NA,
|
|
@@ -23,8 +30,9 @@ type ClassLabel = str | float
|
|
|
23
30
|
type FeatureValue = str | float | Decimal | np.generic | NAType | None
|
|
24
31
|
# A JSON value of the texts for the prompts. The abstract containers keep a list[str] or a dict[str, float] assignable,
|
|
25
32
|
# so the hint also accepts a Sequence or a Mapping that orjson cannot write (a range, a MappingProxyType). orjson raises
|
|
26
|
-
# for those when it writes the text.
|
|
27
|
-
type
|
|
33
|
+
# for those when it writes the text. The numeric tower already lets float cover bool, but JSON has true and false as a
|
|
34
|
+
# type of its own, so the hint names bool.
|
|
35
|
+
type JSONValue = str | bool | float | Sequence[JSONValue] | Mapping[str, JSONValue] | None
|
|
28
36
|
|
|
29
37
|
|
|
30
38
|
class Normalization(enum.StrEnum):
|
|
@@ -28,9 +28,8 @@ import attrs
|
|
|
28
28
|
import numpy as np
|
|
29
29
|
import numpy.typing as npt
|
|
30
30
|
from interpret.utils._clean_x import _densify_categorical # ruff: ignore[import-private-name] -- interpret has no public function that writes a value as the text of its category
|
|
31
|
-
from pandas.api.typing import NAType
|
|
32
31
|
|
|
33
|
-
from ebaml.core.custom_types import ClassLabel, ExplainableBoostingModel, FeatureValue
|
|
32
|
+
from ebaml.core.custom_types import PANDAS_NA_TYPE, ClassLabel, ExplainableBoostingModel, FeatureValue
|
|
34
33
|
from ebaml.core.exceptions import InvalidInstanceError, OptionRangeError, UnsupportedModelError
|
|
35
34
|
from ebaml.graphs.ebm_graph import EBMGraph
|
|
36
35
|
from ebaml.graphs.model_kinds import BinaryClassifier, model_kind
|
|
@@ -264,7 +263,11 @@ def _bin_index(ebm: ExplainableBoostingModel, feature_index: int, graph: EBMGrap
|
|
|
264
263
|
|
|
265
264
|
"""
|
|
266
265
|
# the missing markers of a FeatureValue: None, pd.NA, and a NaN of Python or of any NumPy float type
|
|
267
|
-
if
|
|
266
|
+
if (
|
|
267
|
+
value is None
|
|
268
|
+
or isinstance(value, PANDAS_NA_TYPE)
|
|
269
|
+
or (isinstance(value, float | np.floating) and math.isnan(value))
|
|
270
|
+
):
|
|
268
271
|
msg = f"Feature {graph.feature_name!r} is missing; local explanations need every input."
|
|
269
272
|
raise InvalidInstanceError(msg)
|
|
270
273
|
if graph.feature_type == "continuous":
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""The tool that explains one prediction with the exact local facts. It calls no LLM."""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
|
|
5
|
+
import attrs
|
|
6
|
+
|
|
7
|
+
from ebaml.core.custom_types import FeatureValue
|
|
8
|
+
from ebaml.core.exceptions import InvalidInstanceError
|
|
9
|
+
from ebaml.local.audience import resolve_audience
|
|
10
|
+
from ebaml.local.fact_text import FactTexts, facts_to_texts
|
|
11
|
+
from ebaml.local.facts import LocalFacts, LocalOptions, compute_local_facts
|
|
12
|
+
from ebaml.mcp.model_store import ModelStore
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@attrs.frozen
|
|
16
|
+
class PredictionExplanation:
|
|
17
|
+
"""The facts of one prediction and their texts.
|
|
18
|
+
|
|
19
|
+
Attributes
|
|
20
|
+
----------
|
|
21
|
+
facts: LocalFacts
|
|
22
|
+
The prediction, the contributions and the three local explanations.
|
|
23
|
+
texts: FactTexts
|
|
24
|
+
The facts as the JSON texts that the prompts read, for the audience of the call.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
facts: LocalFacts
|
|
29
|
+
texts: FactTexts
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def explain_prediction(
|
|
33
|
+
store: ModelStore,
|
|
34
|
+
*,
|
|
35
|
+
instance: Mapping[str, FeatureValue] | None = None,
|
|
36
|
+
row: int | None = None,
|
|
37
|
+
confidence_level: float = 0.95,
|
|
38
|
+
audience: str = "layperson",
|
|
39
|
+
) -> PredictionExplanation:
|
|
40
|
+
"""Compute the local facts of one prediction.
|
|
41
|
+
|
|
42
|
+
Parameters
|
|
43
|
+
----------
|
|
44
|
+
store: ModelStore
|
|
45
|
+
The session.
|
|
46
|
+
instance: Mapping[str, FeatureValue], optional
|
|
47
|
+
The value of every feature, by feature name.
|
|
48
|
+
row: int, optional
|
|
49
|
+
The position of a row of the data of ``--data``. Give exactly one of ``instance`` and ``row``.
|
|
50
|
+
confidence_level: float, default=0.95
|
|
51
|
+
See ``LocalOptions.confidence_level``.
|
|
52
|
+
audience: str, default="layperson"
|
|
53
|
+
The name of a built-in audience. It decides the keys of the texts.
|
|
54
|
+
|
|
55
|
+
Returns
|
|
56
|
+
-------
|
|
57
|
+
PredictionExplanation
|
|
58
|
+
The facts and their texts.
|
|
59
|
+
|
|
60
|
+
Raises
|
|
61
|
+
------
|
|
62
|
+
InvalidInstanceError
|
|
63
|
+
If the call gives both or none of ``instance`` and ``row``.
|
|
64
|
+
|
|
65
|
+
"""
|
|
66
|
+
if (instance is None) == (row is None):
|
|
67
|
+
msg = "Give exactly one of instance and row."
|
|
68
|
+
raise InvalidInstanceError(msg)
|
|
69
|
+
values = store.row_instance(row) if row is not None else dict(instance or {})
|
|
70
|
+
facts = compute_local_facts(store.ebm, values, LocalOptions(confidence_level=confidence_level))
|
|
71
|
+
return PredictionExplanation(facts=facts, texts=facts_to_texts(facts, resolve_audience(audience)))
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""The tools that ask the LLM to describe the model. The server registers them only when the user gives ``--llm``."""
|
|
2
|
+
|
|
3
|
+
from ebaml.llm.descriptors import describe_ebm, describe_graph
|
|
4
|
+
from ebaml.llm.options import ModelOptions
|
|
5
|
+
from ebaml.mcp.model_store import ModelStore
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def describe_feature(store: ModelStore, llm: ModelOptions, feature: str) -> str:
|
|
9
|
+
"""Ask the LLM to describe the graph of one feature.
|
|
10
|
+
|
|
11
|
+
Parameters
|
|
12
|
+
----------
|
|
13
|
+
store: ModelStore
|
|
14
|
+
The session.
|
|
15
|
+
llm: ModelOptions
|
|
16
|
+
The LLM.
|
|
17
|
+
feature: str
|
|
18
|
+
The name of the feature.
|
|
19
|
+
|
|
20
|
+
Returns
|
|
21
|
+
-------
|
|
22
|
+
str
|
|
23
|
+
The output of ``describe_graph``.
|
|
24
|
+
|
|
25
|
+
"""
|
|
26
|
+
return describe_graph(store.ebm, store.feature_index(feature), model=llm)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def describe_model(store: ModelStore, llm: ModelOptions) -> str:
|
|
30
|
+
"""Ask the LLM to describe the whole model. The first call computes the text and the next calls reuse it.
|
|
31
|
+
|
|
32
|
+
Parameters
|
|
33
|
+
----------
|
|
34
|
+
store: ModelStore
|
|
35
|
+
The session.
|
|
36
|
+
llm: ModelOptions
|
|
37
|
+
The LLM.
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
-------
|
|
41
|
+
str
|
|
42
|
+
The output of ``describe_ebm``.
|
|
43
|
+
|
|
44
|
+
"""
|
|
45
|
+
if store.model_description is None:
|
|
46
|
+
store.model_description = describe_ebm(store.ebm, model=llm)
|
|
47
|
+
return store.model_description
|