outerproduct 0.2.2__tar.gz → 0.2.3__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.
- {outerproduct-0.2.2 → outerproduct-0.2.3}/PKG-INFO +1 -1
- {outerproduct-0.2.2 → outerproduct-0.2.3}/pyproject.toml +1 -1
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/reasoning/pattern_tracker.py +18 -57
- {outerproduct-0.2.2 → outerproduct-0.2.3}/.gitignore +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/LICENSE +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/README.md +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/__init__.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/agentic/__init__.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/agentic/documents.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/client/__init__.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/client/_http.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/client/apis.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/client/client.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/client/endpoints.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/client/exceptions.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/connector.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/dataset.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/job.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/model.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/py.typed +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/reasoning/__init__.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/trainer.py +0 -0
- {outerproduct-0.2.2 → outerproduct-0.2.3}/src/outerproduct/utils.py +0 -0
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
"""PatternTracker — aggregate a :class:`ReasoningModel`'s
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
The fit dispatches to a one-shot Modal CPU function on the API server: it
|
|
5
|
-
loads the cloudpickled ReasoningModel, materializes X from the supplied
|
|
6
|
-
:class:`~outerproduct.dataset.Dataset` (inline / pre-uploaded /
|
|
7
|
-
connector-backed — same routing as :func:`outerproduct.reasoning.fit`),
|
|
8
|
-
runs ``predict`` + ``explain_prediction`` + ``build_patterns`` end-to-end,
|
|
9
|
-
and persists the result. The SDK polls a single GET endpoint and returns
|
|
10
|
-
the populated :class:`PatternTracker`.
|
|
1
|
+
"""PatternTracker — aggregate a :class:`ReasoningModel`'s explanations on
|
|
2
|
+
a target prediction band into a small, frozen set of labeled filter
|
|
3
|
+
patterns.
|
|
11
4
|
|
|
12
5
|
Quickstart
|
|
13
6
|
----------
|
|
@@ -17,7 +10,7 @@ Quickstart
|
|
|
17
10
|
|
|
18
11
|
op.init(api_key="...")
|
|
19
12
|
ds = op.FileUploadConnector().upload("data.csv")
|
|
20
|
-
rm = op.reasoning.fit(ds)
|
|
13
|
+
rm = op.reasoning.fit(ds, label_column="churn", task_type="binclass")
|
|
21
14
|
pt = op.reasoning.pattern_tracker.fit(rm, ds, target_range=(0.5, None))
|
|
22
15
|
|
|
23
16
|
pt.patterns # tuple[FilterPattern, ...]
|
|
@@ -44,12 +37,10 @@ if TYPE_CHECKING:
|
|
|
44
37
|
|
|
45
38
|
@dataclass(frozen=True)
|
|
46
39
|
class Predicate:
|
|
47
|
-
"""One literal of a
|
|
40
|
+
"""One literal of a filter: ``feature <op> value``.
|
|
48
41
|
|
|
49
|
-
|
|
50
|
-
``
|
|
51
|
-
``"<="`` or ``">="`` for continuous features (numeric ``value``) or
|
|
52
|
-
``"=="`` for categoricals.
|
|
42
|
+
``op`` is ``"<="`` or ``">="`` for continuous features (numeric
|
|
43
|
+
``value``) or ``"=="`` for categoricals.
|
|
53
44
|
"""
|
|
54
45
|
|
|
55
46
|
feature: str
|
|
@@ -70,7 +61,7 @@ class Predicate:
|
|
|
70
61
|
|
|
71
62
|
@dataclass(frozen=True)
|
|
72
63
|
class FilterPattern:
|
|
73
|
-
"""One executable
|
|
64
|
+
"""One executable filter with coverage stats and a label."""
|
|
74
65
|
|
|
75
66
|
predicates: tuple[Predicate, ...]
|
|
76
67
|
label: str
|
|
@@ -183,66 +174,36 @@ def fit(
|
|
|
183
174
|
dataset: Dataset,
|
|
184
175
|
*,
|
|
185
176
|
target_range: tuple[float | None, float | None],
|
|
186
|
-
mode: str = "discovery",
|
|
187
177
|
max_patterns: int = 25,
|
|
188
|
-
coverage_target: float = 0.95,
|
|
189
|
-
min_pattern_support: float = 0.005,
|
|
190
|
-
min_precision: float = 0.5,
|
|
191
|
-
max_pattern_size: int = 3,
|
|
192
|
-
threshold_n_bins: int = 10,
|
|
193
|
-
ensure_coverage: bool = True,
|
|
194
|
-
min_wracc: float = 0.0,
|
|
195
|
-
diversity_threshold: float = 0.5,
|
|
196
|
-
drop_redundant: bool = True,
|
|
197
|
-
child_overlap_threshold: float = 0.9,
|
|
198
|
-
explained_lift_threshold: float = 1.1,
|
|
199
|
-
rule_kwargs: dict[str, Any] | None = None,
|
|
200
178
|
non_blocking: bool = False,
|
|
201
179
|
poll_interval: float = 2.0,
|
|
202
180
|
poll_timeout: float = 3600.0,
|
|
203
181
|
) -> "PatternTracker | PatternTrackerJob":
|
|
204
|
-
"""Fit a :class:`PatternTracker` against ``reasoning_model``
|
|
205
|
-
``dataset
|
|
182
|
+
"""Fit a :class:`PatternTracker` against ``reasoning_model`` on
|
|
183
|
+
``dataset``.
|
|
206
184
|
|
|
207
185
|
Parameters
|
|
208
186
|
----------
|
|
209
187
|
reasoning_model : :class:`~outerproduct.model.ReasoningModel`
|
|
210
|
-
The model whose
|
|
188
|
+
The model whose target-band rows drive the aggregation.
|
|
211
189
|
dataset : :class:`~outerproduct.dataset.Dataset`
|
|
212
|
-
|
|
213
|
-
connector-backed datasets are all supported (same routing as
|
|
214
|
-
:func:`outerproduct.reasoning.fit`).
|
|
190
|
+
Data to score and aggregate over.
|
|
215
191
|
target_range : (lo, hi) tuple
|
|
216
|
-
Inclusive prediction band that defines
|
|
217
|
-
side may be ``None`` for an open bound; at least one
|
|
192
|
+
Inclusive prediction band that defines the target cohort.
|
|
193
|
+
Either side may be ``None`` for an open bound; at least one
|
|
194
|
+
must be set.
|
|
195
|
+
max_patterns : int, default 25
|
|
196
|
+
Cap on the number of returned patterns.
|
|
218
197
|
non_blocking : bool, default False
|
|
219
198
|
If ``True``, return a :class:`PatternTrackerJob` immediately;
|
|
220
|
-
otherwise block until the fit completes
|
|
221
|
-
tracker.
|
|
222
|
-
|
|
223
|
-
All remaining keyword arguments mirror the server-side fit
|
|
224
|
-
hyperparameters; see ``outerproduct_reasoning.PatternTracker.fit``
|
|
225
|
-
for their semantics.
|
|
199
|
+
otherwise block until the fit completes.
|
|
226
200
|
"""
|
|
227
201
|
from outerproduct_http_types import PatternTrackerFitRequest
|
|
228
202
|
|
|
229
203
|
dataset_payload = dataset._to_dataset_payload()
|
|
230
204
|
payload: dict[str, Any] = {
|
|
231
205
|
"target_range": target_range,
|
|
232
|
-
"mode": mode,
|
|
233
206
|
"max_patterns": max_patterns,
|
|
234
|
-
"coverage_target": coverage_target,
|
|
235
|
-
"min_pattern_support": min_pattern_support,
|
|
236
|
-
"min_precision": min_precision,
|
|
237
|
-
"max_pattern_size": max_pattern_size,
|
|
238
|
-
"threshold_n_bins": threshold_n_bins,
|
|
239
|
-
"ensure_coverage": ensure_coverage,
|
|
240
|
-
"min_wracc": min_wracc,
|
|
241
|
-
"diversity_threshold": diversity_threshold,
|
|
242
|
-
"drop_redundant": drop_redundant,
|
|
243
|
-
"child_overlap_threshold": child_overlap_threshold,
|
|
244
|
-
"explained_lift_threshold": explained_lift_threshold,
|
|
245
|
-
"rule_kwargs": rule_kwargs,
|
|
246
207
|
}
|
|
247
208
|
payload.update(dataset_payload)
|
|
248
209
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|