proxyml 0.1.5__tar.gz → 0.1.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: proxyml
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: Python SDK for calling the ProxyML API
5
5
  Author-email: ProxyML <contact@proxyml.ai>
6
6
  License: Apache License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "proxyml"
7
- version = "0.1.5"
7
+ version = "0.1.6"
8
8
  description = "Python SDK for calling the ProxyML API"
9
9
  readme = "README.md"
10
10
  license = {file = "LICENSE"}
@@ -17,6 +17,7 @@ from proxyml.client import (
17
17
  delete_model,
18
18
  get_usage,
19
19
  rotate_key,
20
+ explain_local,
20
21
  )
21
22
  from proxyml.schema import (
22
23
  get_schema,
@@ -44,6 +45,7 @@ __all__ = [
44
45
  "delete_model",
45
46
  "get_usage",
46
47
  "rotate_key",
48
+ "explain_local",
47
49
  "get_schema",
48
50
  "gen_continuous_schema",
49
51
  "gen_categorical_schema",
@@ -399,6 +399,27 @@ def list_models() -> list[dict] | None:
399
399
  return None
400
400
 
401
401
 
402
+ def explain_local(instance: list, version: str | None = None) -> dict | None:
403
+ """Per-feature contribution breakdown for a single instance.
404
+
405
+ Returns a dict with ``prediction``, ``feature_contributions`` (sorted by
406
+ abs_contribution descending), ``intercept``, optional ``probabilities``
407
+ (classification), and optional ``per_class_contributions`` (multiclass).
408
+ """
409
+ payload: dict = {"instance": instance}
410
+ if version is not None:
411
+ payload["version"] = version
412
+ r = post(endpoint="/explain/local", payload=payload)
413
+ if r.status_code == 200:
414
+ return r.json()
415
+ logger.error(
416
+ "Local explanation failed with status %s: %s",
417
+ r.status_code,
418
+ r.text,
419
+ )
420
+ return None
421
+
422
+
402
423
  def delete_model(model_id: str) -> bool:
403
424
  """Delete a surrogate model by its UUID. Returns True on success, False if not found."""
404
425
  r = delete(endpoint=f'/surrogate/models/{model_id}')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: proxyml
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: Python SDK for calling the ProxyML API
5
5
  Author-email: ProxyML <contact@proxyml.ai>
6
6
  License: Apache License
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes