proxyml-core 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,45 @@
1
+ from proxyml_core._version import (
2
+ EXPORT_SCHEMA_VERSION,
3
+ IncompatibleExportVersionError,
4
+ check_compatible,
5
+ )
6
+ from proxyml_core.export import (
7
+ ExportError,
8
+ FeatureExportEntry,
9
+ PerClassCoefficients,
10
+ PerClassIntercept,
11
+ SurrogateExport,
12
+ predict_from_export,
13
+ score_export,
14
+ )
15
+ from proxyml_core.schema import (
16
+ CategoricalFeature,
17
+ CategoricalOrdinalFeature,
18
+ ContinuousFeature,
19
+ CountFeature,
20
+ Feature,
21
+ FeatureSchema,
22
+ FeatureValidationError,
23
+ NumericOrdinalFeature,
24
+ )
25
+
26
+ __all__ = [
27
+ "Feature",
28
+ "FeatureSchema",
29
+ "FeatureValidationError",
30
+ "ContinuousFeature",
31
+ "CategoricalFeature",
32
+ "CategoricalOrdinalFeature",
33
+ "NumericOrdinalFeature",
34
+ "CountFeature",
35
+ "SurrogateExport",
36
+ "FeatureExportEntry",
37
+ "PerClassCoefficients",
38
+ "PerClassIntercept",
39
+ "ExportError",
40
+ "score_export",
41
+ "predict_from_export",
42
+ "EXPORT_SCHEMA_VERSION",
43
+ "IncompatibleExportVersionError",
44
+ "check_compatible",
45
+ ]
@@ -0,0 +1,21 @@
1
+ """Export-format versioning.
2
+
3
+ The export JSON is a versioned contract: every artifact produced by
4
+ ``extract_export_data``/``SurrogateExport.to_dict`` is stamped with
5
+ ``EXPORT_SCHEMA_VERSION``, and loaders check compatibility before trusting
6
+ the payload shape. This is what lets a client and server built against
7
+ different versions of this library still register/diff/score models: as
8
+ long as a loader's version is >= the payload's stamped version, it knows
9
+ how to read that (older) shape.
10
+ """
11
+
12
+ EXPORT_SCHEMA_VERSION = 1
13
+
14
+
15
+ class IncompatibleExportVersionError(ValueError):
16
+ """Raised when an export payload is newer than this library understands."""
17
+
18
+
19
+ def check_compatible(payload_version: int) -> bool:
20
+ """Return True if this library can read a payload stamped with ``payload_version``."""
21
+ return payload_version <= EXPORT_SCHEMA_VERSION
proxyml_core/export.py ADDED
@@ -0,0 +1,238 @@
1
+ """The export JSON contract and its arithmetic scorer.
2
+
3
+ Pure: stdlib + numpy only. ``extract_export_data`` (in
4
+ ``proxyml_core.modeling.extract``, which requires sklearn) *produces* a
5
+ ``SurrogateExport``; everything in this module — reading, serializing, and
6
+ scoring one — needs nothing beyond arithmetic. That's deliberate: it's the
7
+ "your model is yours" scorer — a user can reconstruct predictions with zero
8
+ sklearn, the same arithmetic on the same JSON, whether the artifact came
9
+ from a server-trained surrogate or a locally-trained challenger.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import math
15
+ from dataclasses import asdict, dataclass
16
+ from typing import Any, Mapping
17
+
18
+ from proxyml_core._version import (
19
+ EXPORT_SCHEMA_VERSION,
20
+ IncompatibleExportVersionError,
21
+ check_compatible,
22
+ )
23
+
24
+ SCORING_NOTE = (
25
+ "Coefficients are in the preprocessed feature space. "
26
+ "Continuous: x_scaled = (x - scaler_mean) / scaler_scale. "
27
+ "Count: x_scaled = (log1p(x) - scaler_mean) / scaler_scale. "
28
+ "Categorical: one-hot encoded — ohe_categories[i] is the category for coefficient[i]. "
29
+ "Ordinal: encoded as rank (0-based) per ordinal_categories order. "
30
+ "score = dot(preprocessed_x, coefficients) + intercept. "
31
+ "For binary classification score is a logit (sigmoid for probability). "
32
+ "For multiclass, compute one score per class and take the argmax."
33
+ )
34
+
35
+
36
+ class ExportError(ValueError):
37
+ """Raised for malformed export payloads or scoring inputs."""
38
+
39
+
40
+ @dataclass(kw_only=True)
41
+ class PerClassCoefficients:
42
+ class_label: str
43
+ coefficient: float | None = None
44
+ category_coefficients: list[float] | None = None
45
+
46
+ def to_dict(self) -> dict[str, Any]:
47
+ return asdict(self)
48
+
49
+ @classmethod
50
+ def from_dict(cls, d: dict[str, Any]) -> "PerClassCoefficients":
51
+ return cls(**d)
52
+
53
+
54
+ @dataclass(kw_only=True)
55
+ class FeatureExportEntry:
56
+ name: str
57
+ type: str
58
+ scaler_mean: float | None = None
59
+ scaler_scale: float | None = None
60
+ ohe_categories: list[str] | None = None
61
+ ordinal_categories: list[str] | None = None
62
+ coefficient: float | None = None
63
+ category_coefficients: list[float] | None = None
64
+ per_class_coefficients: list[PerClassCoefficients] | None = None
65
+
66
+ def to_dict(self) -> dict[str, Any]:
67
+ d = asdict(self)
68
+ if self.per_class_coefficients is not None:
69
+ d["per_class_coefficients"] = [c.to_dict() for c in self.per_class_coefficients]
70
+ return d
71
+
72
+ @classmethod
73
+ def from_dict(cls, d: dict[str, Any]) -> "FeatureExportEntry":
74
+ d = dict(d)
75
+ per_class = d.get("per_class_coefficients")
76
+ if per_class is not None:
77
+ d["per_class_coefficients"] = [PerClassCoefficients.from_dict(c) for c in per_class]
78
+ return cls(**d)
79
+
80
+
81
+ @dataclass(kw_only=True)
82
+ class PerClassIntercept:
83
+ class_label: str
84
+ intercept: float
85
+
86
+ def to_dict(self) -> dict[str, Any]:
87
+ return asdict(self)
88
+
89
+ @classmethod
90
+ def from_dict(cls, d: dict[str, Any]) -> "PerClassIntercept":
91
+ return cls(**d)
92
+
93
+
94
+ @dataclass(kw_only=True)
95
+ class SurrogateExport:
96
+ """The full export contract.
97
+
98
+ ``extract_export_data`` populates only the scoring-relevant fields
99
+ (``task``, ``classes``, ``intercept``, ``per_class_intercepts``,
100
+ ``features``) — a caller with run metadata (version, trained_at, etc.,
101
+ e.g. a backend endpoint) fills in the rest via ``dataclasses.replace``.
102
+ """
103
+
104
+ task: str
105
+ features: list[FeatureExportEntry]
106
+ classes: list[str] | None = None
107
+ intercept: float | None = None
108
+ per_class_intercepts: list[PerClassIntercept] | None = None
109
+
110
+ version: str | None = None
111
+ trained_at: str | None = None
112
+ schema_name: str | None = None
113
+ name: str | None = None
114
+ comments: str | None = None
115
+ metrics: dict[str, float] | None = None
116
+ hyperparameters: dict | None = None
117
+ run_id: str | None = None
118
+ schema_definition: list[dict] | None = None
119
+ schema_warning: str | None = None
120
+ note: str = SCORING_NOTE
121
+ export_schema_version: int = EXPORT_SCHEMA_VERSION
122
+
123
+ def to_dict(self) -> dict[str, Any]:
124
+ d = asdict(self)
125
+ d["features"] = [f.to_dict() for f in self.features]
126
+ if self.per_class_intercepts is not None:
127
+ d["per_class_intercepts"] = [p.to_dict() for p in self.per_class_intercepts]
128
+ return d
129
+
130
+ @classmethod
131
+ def from_dict(cls, d: dict[str, Any]) -> "SurrogateExport":
132
+ payload_version = d.get("export_schema_version", 1)
133
+ if not check_compatible(payload_version):
134
+ raise IncompatibleExportVersionError(
135
+ f"Export payload is at version {payload_version}, but this copy of "
136
+ f"proxyml-core only understands up to version {EXPORT_SCHEMA_VERSION}. "
137
+ "Upgrade proxyml-core to read it."
138
+ )
139
+ d = dict(d)
140
+ d["features"] = [FeatureExportEntry.from_dict(f) for f in d["features"]]
141
+ per_class_intercepts = d.get("per_class_intercepts")
142
+ if per_class_intercepts is not None:
143
+ d["per_class_intercepts"] = [PerClassIntercept.from_dict(p) for p in per_class_intercepts]
144
+ return cls(**d)
145
+
146
+
147
+ def _feature_value(sample: Mapping[str, Any], name: str, strict: bool) -> Any:
148
+ if name not in sample:
149
+ if strict:
150
+ raise ExportError(f"Missing value for feature {name!r}")
151
+ return None
152
+ return sample[name]
153
+
154
+
155
+ def _contribution(entry: FeatureExportEntry, value: Any, class_index: int | None) -> float:
156
+ if entry.type in ("continuous", "count"):
157
+ x = float(value)
158
+ if entry.type == "count":
159
+ x = math.log1p(x)
160
+ x_scaled = (x - entry.scaler_mean) / entry.scaler_scale
161
+ coef = (
162
+ entry.per_class_coefficients[class_index].coefficient
163
+ if class_index is not None
164
+ else entry.coefficient
165
+ )
166
+ return coef * x_scaled
167
+ if entry.type == "categorical":
168
+ categories = entry.ohe_categories or []
169
+ try:
170
+ idx = categories.index(str(value))
171
+ except ValueError:
172
+ return 0.0 # unknown category -> all-zero OHE row, matches handle_unknown="ignore"
173
+ coefs = (
174
+ entry.per_class_coefficients[class_index].category_coefficients
175
+ if class_index is not None
176
+ else entry.category_coefficients
177
+ )
178
+ return coefs[idx]
179
+ if entry.type in ("categorical_ordinal", "numeric_ordinal"):
180
+ categories = entry.ordinal_categories or []
181
+ try:
182
+ rank = categories.index(str(value))
183
+ except ValueError:
184
+ rank = -1 # unknown -> OrdinalEncoder(unknown_value=-1)
185
+ coef = (
186
+ entry.per_class_coefficients[class_index].coefficient
187
+ if class_index is not None
188
+ else entry.coefficient
189
+ )
190
+ return coef * rank
191
+ raise ExportError(f"Unknown feature type: {entry.type!r}")
192
+
193
+
194
+ def score_export(
195
+ export: SurrogateExport, sample: Mapping[str, Any], *, strict: bool = True
196
+ ) -> float | dict[str, float]:
197
+ """Compute the raw linear score(s) for ``sample`` against ``export``.
198
+
199
+ Regression / binary classification return a single float (a logit, in
200
+ the binary case). Multiclass returns a ``{class_label: score}`` dict.
201
+ Missing feature values raise by default (``strict=True``); pass
202
+ ``strict=False`` to silently skip them (their contribution is treated
203
+ as 0), e.g. when intentionally scoring on a reduced feature subset.
204
+ """
205
+ is_multiclass = export.per_class_intercepts is not None
206
+ if is_multiclass:
207
+ scores: dict[str, float] = {}
208
+ for i, pci in enumerate(export.per_class_intercepts):
209
+ total = pci.intercept
210
+ for entry in export.features:
211
+ value = _feature_value(sample, entry.name, strict)
212
+ if value is None:
213
+ continue
214
+ total += _contribution(entry, value, i)
215
+ scores[pci.class_label] = total
216
+ return scores
217
+
218
+ total = export.intercept or 0.0
219
+ for entry in export.features:
220
+ value = _feature_value(sample, entry.name, strict)
221
+ if value is None:
222
+ continue
223
+ total += _contribution(entry, value, None)
224
+ return total
225
+
226
+
227
+ def predict_from_export(
228
+ export: SurrogateExport, sample: Mapping[str, Any], *, strict: bool = True
229
+ ) -> float | str:
230
+ """Reconstruct the prediction ``/surrogate/predict`` would return, purely from the export."""
231
+ score = score_export(export, sample, strict=strict)
232
+ if export.task == "regression":
233
+ return score
234
+ if isinstance(score, dict):
235
+ return max(score, key=score.get)
236
+ prob = 1.0 / (1.0 + math.exp(-score))
237
+ classes = export.classes or ["0", "1"]
238
+ return classes[1] if prob >= 0.5 else classes[0]
@@ -0,0 +1,21 @@
1
+ from proxyml_core.modeling.estimators import (
2
+ binarize_if_probabilities,
3
+ extract_hyperparameters,
4
+ get_default_classifier,
5
+ get_default_regressor,
6
+ is_classification,
7
+ to_json_safe,
8
+ )
9
+ from proxyml_core.modeling.extract import extract_export_data
10
+ from proxyml_core.modeling.preprocess import build_preprocessor
11
+
12
+ __all__ = [
13
+ "build_preprocessor",
14
+ "get_default_classifier",
15
+ "get_default_regressor",
16
+ "is_classification",
17
+ "binarize_if_probabilities",
18
+ "extract_hyperparameters",
19
+ "to_json_safe",
20
+ "extract_export_data",
21
+ ]
@@ -0,0 +1,68 @@
1
+ """Default estimators and task-type inference. Requires ``proxyml-core[modeling]``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import numpy as np
6
+ from sklearn.base import BaseEstimator
7
+ from sklearn.linear_model import LogisticRegressionCV, RidgeCV
8
+
9
+
10
+ def to_json_safe(v):
11
+ if isinstance(v, np.ndarray):
12
+ return v.tolist()
13
+ if isinstance(v, np.generic):
14
+ return v.item()
15
+ if isinstance(v, (list, tuple)):
16
+ return [to_json_safe(x) for x in v]
17
+ return v
18
+
19
+
20
+ def extract_hyperparameters(estimator: BaseEstimator) -> dict:
21
+ """Return configured and CV-selected hyperparameters from a fitted estimator."""
22
+ params = {k: to_json_safe(v) for k, v in estimator.get_params().items()}
23
+ for attr in ("alpha_", "C_", "l1_ratio_"):
24
+ if hasattr(estimator, attr):
25
+ params[attr] = to_json_safe(getattr(estimator, attr))
26
+ return params
27
+
28
+
29
+ def is_classification(predictions: np.ndarray) -> bool:
30
+ """Infer task type from predictions.
31
+
32
+ Cardinality is the only signal available — there's no way to distinguish a
33
+ classifier's probability outputs from a genuine continuous regression target
34
+ by value inspection alone, so callers should let users override this guess.
35
+ """
36
+ return predictions.dtype == object or len(np.unique(predictions)) <= 20
37
+
38
+
39
+ def binarize_if_probabilities(predictions: np.ndarray) -> np.ndarray:
40
+ """Threshold probability outputs into hard 0/1 labels for classification.
41
+
42
+ A classifier needs discrete labels — if a caller submits raw probabilities
43
+ (e.g. predict_proba output) for a binary task, every unique probability would
44
+ otherwise be treated as its own class. Treat >=0.5 as the positive class.
45
+ Already-discrete labels (ints, or non-numeric class names) pass through unchanged.
46
+ """
47
+ if predictions.dtype.kind not in "iuf": # not int/uint/float — already discrete labels
48
+ return predictions
49
+ as_float = predictions.astype(float)
50
+ if np.all(as_float == as_float.astype(int)):
51
+ return predictions
52
+ return (as_float >= 0.5).astype(int)
53
+
54
+
55
+ def get_default_classifier() -> BaseEstimator:
56
+ return LogisticRegressionCV(
57
+ solver="lbfgs",
58
+ l1_ratios=(0,),
59
+ class_weight="balanced",
60
+ max_iter=500,
61
+ cv=5,
62
+ n_jobs=-1,
63
+ use_legacy_attributes=False,
64
+ )
65
+
66
+
67
+ def get_default_regressor() -> BaseEstimator:
68
+ return RidgeCV(alphas=np.logspace(-3, 4, 15), cv=5)
@@ -0,0 +1,120 @@
1
+ """Extract the export contract from a fitted pipeline. Requires ``proxyml-core[modeling]``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import numpy as np
6
+ from sklearn.pipeline import Pipeline
7
+
8
+ from proxyml_core.export import FeatureExportEntry, PerClassCoefficients, PerClassIntercept, SurrogateExport
9
+ from proxyml_core.schema import Feature
10
+
11
+
12
+ def extract_export_data(pipeline: Pipeline, features: list[Feature], task: str) -> SurrogateExport:
13
+ """Extract everything needed to reconstruct scoring outside the API.
14
+
15
+ Returns a ``SurrogateExport`` with only the scoring-relevant fields
16
+ populated (``task``, ``classes``, ``intercept``, ``per_class_intercepts``,
17
+ ``features``); a caller with run metadata (version, trained_at, etc.)
18
+ should fill in the rest via ``dataclasses.replace``.
19
+ """
20
+ preprocessor = pipeline.named_steps["preprocessor"]
21
+ estimator = pipeline.named_steps["estimator"]
22
+
23
+ coef = np.atleast_2d(np.asarray(estimator.coef_))
24
+ intercepts = np.atleast_1d(estimator.intercept_)
25
+
26
+ is_multiclass = task == "classification" and coef.shape[0] > 1
27
+ classes = [str(c) for c in estimator.classes_] if task == "classification" else None
28
+
29
+ # Walk the ColumnTransformer in output order to build per-feature segments.
30
+ segments: list[dict] = []
31
+ for t_name, t_obj, col_indices in preprocessor.transformers_:
32
+ if t_name == "remainder":
33
+ continue
34
+ if t_name == "cat":
35
+ encoder = t_obj.named_steps["encoder"]
36
+ for local_i, global_i in enumerate(col_indices):
37
+ segments.append({
38
+ "feature": features[global_i],
39
+ "n_cols": len(encoder.categories_[local_i]),
40
+ "ohe_categories": [str(c) for c in encoder.categories_[local_i]],
41
+ "scaler_mean": None,
42
+ "scaler_scale": None,
43
+ "ordinal_categories": None,
44
+ })
45
+ elif t_name in ("num", "count"):
46
+ scaler = t_obj.named_steps["scaler"]
47
+ for local_i, global_i in enumerate(col_indices):
48
+ segments.append({
49
+ "feature": features[global_i],
50
+ "n_cols": 1,
51
+ "ohe_categories": None,
52
+ "scaler_mean": float(scaler.mean_[local_i]),
53
+ "scaler_scale": float(scaler.scale_[local_i]),
54
+ "ordinal_categories": None,
55
+ })
56
+ elif t_name == "ord":
57
+ encoder = t_obj.named_steps["encoder"]
58
+ for local_i, global_i in enumerate(col_indices):
59
+ segments.append({
60
+ "feature": features[global_i],
61
+ "n_cols": 1,
62
+ "ohe_categories": None,
63
+ "scaler_mean": None,
64
+ "scaler_scale": None,
65
+ "ordinal_categories": [str(c) for c in encoder.categories_[local_i]],
66
+ })
67
+
68
+ feature_entries: list[FeatureExportEntry] = []
69
+ pos = 0
70
+ for seg in segments:
71
+ n_cols = seg["n_cols"]
72
+ feat = seg["feature"]
73
+ entry_kwargs: dict = {
74
+ "name": feat.name,
75
+ "type": feat.type,
76
+ "scaler_mean": seg["scaler_mean"],
77
+ "scaler_scale": seg["scaler_scale"],
78
+ "ohe_categories": seg["ohe_categories"],
79
+ "ordinal_categories": seg["ordinal_categories"],
80
+ }
81
+ if is_multiclass:
82
+ entry_kwargs["coefficient"] = None
83
+ entry_kwargs["category_coefficients"] = None
84
+ entry_kwargs["per_class_coefficients"] = [
85
+ PerClassCoefficients(
86
+ class_label=classes[i],
87
+ coefficient=float(coef[i, pos]) if n_cols == 1 else None,
88
+ category_coefficients=coef[i, pos:pos + n_cols].tolist() if n_cols > 1 else None,
89
+ )
90
+ for i in range(len(classes))
91
+ ]
92
+ else:
93
+ chunk = coef[0, pos:pos + n_cols]
94
+ entry_kwargs["per_class_coefficients"] = None
95
+ if n_cols == 1:
96
+ entry_kwargs["coefficient"] = float(chunk[0])
97
+ entry_kwargs["category_coefficients"] = None
98
+ else:
99
+ entry_kwargs["coefficient"] = None
100
+ entry_kwargs["category_coefficients"] = chunk.tolist()
101
+ feature_entries.append(FeatureExportEntry(**entry_kwargs))
102
+ pos += n_cols
103
+
104
+ if is_multiclass:
105
+ intercept = None
106
+ per_class_intercepts = [
107
+ PerClassIntercept(class_label=classes[i], intercept=float(intercepts[i]))
108
+ for i in range(len(classes))
109
+ ]
110
+ else:
111
+ intercept = float(intercepts[0])
112
+ per_class_intercepts = None
113
+
114
+ return SurrogateExport(
115
+ task=task,
116
+ classes=classes,
117
+ intercept=intercept,
118
+ per_class_intercepts=per_class_intercepts,
119
+ features=feature_entries,
120
+ )
@@ -0,0 +1,75 @@
1
+ """Build the sklearn ColumnTransformer for a feature schema.
2
+
3
+ Requires ``proxyml-core[modeling]``.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from sklearn.compose import ColumnTransformer
9
+ from sklearn.impute import SimpleImputer
10
+ from sklearn.pipeline import Pipeline
11
+ from sklearn.preprocessing import (
12
+ FunctionTransformer,
13
+ OneHotEncoder,
14
+ OrdinalEncoder,
15
+ StandardScaler,
16
+ )
17
+ import numpy as np
18
+
19
+ from proxyml_core.schema import (
20
+ CategoricalFeature,
21
+ CategoricalOrdinalFeature,
22
+ ContinuousFeature,
23
+ CountFeature,
24
+ Feature,
25
+ NumericOrdinalFeature,
26
+ )
27
+
28
+
29
+ def build_preprocessor(features: list[Feature]) -> ColumnTransformer:
30
+ numeric_indices = [i for i, f in enumerate(features) if isinstance(f, ContinuousFeature)]
31
+ categorical_indices = [i for i, f in enumerate(features) if isinstance(f, CategoricalFeature)]
32
+ ordinal_indices = [
33
+ i for i, f in enumerate(features)
34
+ if isinstance(f, (CategoricalOrdinalFeature, NumericOrdinalFeature))
35
+ ]
36
+ count_indices = [i for i, f in enumerate(features) if isinstance(f, CountFeature)]
37
+
38
+ transformers = []
39
+
40
+ if numeric_indices:
41
+ numeric_transformer = Pipeline(steps=[
42
+ ("imputer", SimpleImputer(strategy="median")),
43
+ ("scaler", StandardScaler())
44
+ ])
45
+ transformers.append(("num", numeric_transformer, numeric_indices))
46
+
47
+ if categorical_indices:
48
+ categorical_transformer = Pipeline(steps=[
49
+ ("encoder", OneHotEncoder(handle_unknown="ignore", sparse_output=False))
50
+ ])
51
+ transformers.append(("cat", categorical_transformer, categorical_indices))
52
+
53
+ if ordinal_indices:
54
+ ordinal_features = [
55
+ f for f in features if isinstance(f, (CategoricalOrdinalFeature, NumericOrdinalFeature))
56
+ ]
57
+ categories = [f.categories for f in ordinal_features]
58
+ ordinal_transformer = Pipeline(steps=[
59
+ ("encoder", OrdinalEncoder(
60
+ categories=categories,
61
+ handle_unknown="use_encoded_value",
62
+ unknown_value=-1
63
+ ))
64
+ ])
65
+ transformers.append(("ord", ordinal_transformer, ordinal_indices))
66
+
67
+ if count_indices:
68
+ count_transformer = Pipeline(steps=[
69
+ ("imputer", SimpleImputer(strategy="median")),
70
+ ("log", FunctionTransformer(np.log1p)), # log1p handles zeros safely
71
+ ("scaler", StandardScaler())
72
+ ])
73
+ transformers.append(("count", count_transformer, count_indices))
74
+
75
+ return ColumnTransformer(transformers=transformers)
proxyml_core/schema.py ADDED
@@ -0,0 +1,206 @@
1
+ """Feature schema types.
2
+
3
+ Pure: stdlib + numpy only. These are plain dataclasses rather than pydantic
4
+ models so that a REST-only ``proxyml`` install never pulls in a compiled
5
+ validation dependency. Validation that pydantic gave for free (probabilities
6
+ summing to 1, matching lengths, etc.) is replicated by hand in
7
+ ``__post_init__``.
8
+
9
+ All dataclasses are keyword-only (``kw_only=True``) so that subclasses can
10
+ add required fields after the base class's defaulted ``immutable`` field
11
+ without Python's dataclass field-ordering constraint forcing spurious
12
+ defaults onto otherwise-required fields.
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ from dataclasses import dataclass, field, fields
18
+ from typing import Any, ClassVar
19
+
20
+ import numpy as np
21
+
22
+
23
+ class FeatureValidationError(ValueError):
24
+ """Raised when a Feature or FeatureSchema fails validation."""
25
+
26
+
27
+ @dataclass(kw_only=True)
28
+ class Feature:
29
+ """Base type for a single feature in a schema.
30
+
31
+ ``type`` is a class-level discriminator (not a constructor field) so
32
+ every instance carries its wire-format tag without it participating in
33
+ equality/repr/construction.
34
+ """
35
+
36
+ name: str
37
+ immutable: bool = False
38
+
39
+ type: ClassVar[str] = "feature"
40
+
41
+ def sample(self, size: int = 1) -> np.ndarray:
42
+ raise NotImplementedError
43
+
44
+ def to_dict(self) -> dict[str, Any]:
45
+ d: dict[str, Any] = {"type": self.type}
46
+ for f in fields(self):
47
+ d[f.name] = getattr(self, f.name)
48
+ return d
49
+
50
+ @classmethod
51
+ def from_dict(cls, d: dict[str, Any]) -> "Feature":
52
+ ftype = d.get("type")
53
+ subclass = _FEATURE_TYPES.get(ftype)
54
+ if subclass is None:
55
+ raise FeatureValidationError(f"Unknown feature type: {ftype!r}")
56
+ return subclass._from_dict_fields(d)
57
+
58
+ @classmethod
59
+ def _from_dict_fields(cls, d: dict[str, Any]) -> "Feature":
60
+ kwargs = {f.name: d[f.name] for f in fields(cls) if f.name in d}
61
+ return cls(**kwargs)
62
+
63
+
64
+ @dataclass(kw_only=True)
65
+ class ContinuousFeature(Feature):
66
+ mean: float
67
+ std: float
68
+ min: float
69
+ max: float
70
+
71
+ type: ClassVar[str] = "continuous"
72
+
73
+ def sample(self, size: int = 1) -> np.ndarray:
74
+ samples = np.random.normal(loc=self.mean, scale=self.std, size=size)
75
+ return np.clip(samples, self.min, self.max)
76
+
77
+
78
+ @dataclass(kw_only=True)
79
+ class CategoricalFeature(Feature):
80
+ valid_categories: dict[str, float]
81
+
82
+ type: ClassVar[str] = "categorical"
83
+
84
+ def __post_init__(self) -> None:
85
+ total = sum(self.valid_categories.values())
86
+ if not np.isclose(total, 1.0):
87
+ raise FeatureValidationError(
88
+ f"Category probabilities must sum to 1.0, got {total}"
89
+ )
90
+
91
+ def sample(self, size: int = 1) -> np.ndarray:
92
+ return np.random.choice(
93
+ a=list(self.valid_categories.keys()),
94
+ p=list(self.valid_categories.values()),
95
+ size=size,
96
+ )
97
+
98
+
99
+ @dataclass(kw_only=True)
100
+ class CategoricalOrdinalFeature(Feature):
101
+ categories: list[str | int]
102
+ probabilities: list[float]
103
+
104
+ type: ClassVar[str] = "categorical_ordinal"
105
+
106
+ def __post_init__(self) -> None:
107
+ if len(self.categories) != len(self.probabilities):
108
+ raise FeatureValidationError(
109
+ "categories and probabilities must be same length"
110
+ )
111
+ if not np.isclose(sum(self.probabilities), 1.0):
112
+ raise FeatureValidationError("probabilities must sum to 1.0")
113
+
114
+ def sample(self, size: int = 1) -> np.ndarray:
115
+ return np.random.choice(a=self.categories, p=self.probabilities, size=size)
116
+
117
+
118
+ @dataclass(kw_only=True)
119
+ class NumericOrdinalFeature(Feature):
120
+ categories: list[int]
121
+ mean: float
122
+ std: float
123
+
124
+ type: ClassVar[str] = "numeric_ordinal"
125
+
126
+ def sample(self, size: int = 1) -> np.ndarray:
127
+ continuous = np.random.normal(loc=self.mean, scale=self.std, size=size)
128
+ categories = np.array(self.categories)
129
+ indices = np.argmin(
130
+ np.abs(continuous[:, None] - categories[None, :]), axis=1
131
+ )
132
+ return categories[indices]
133
+
134
+
135
+ @dataclass(kw_only=True)
136
+ class CountFeature(Feature):
137
+ lambda_: float
138
+ max: int | None = None
139
+
140
+ type: ClassVar[str] = "count"
141
+
142
+ def sample(self, size: int = 1) -> np.ndarray:
143
+ samples = np.random.poisson(lam=self.lambda_, size=size)
144
+ if self.max is not None:
145
+ samples = np.clip(samples, 0, self.max)
146
+ return samples
147
+
148
+ def to_dict(self) -> dict[str, Any]:
149
+ return {
150
+ "type": self.type,
151
+ "name": self.name,
152
+ "immutable": self.immutable,
153
+ "lambda": self.lambda_,
154
+ "max": self.max,
155
+ }
156
+
157
+ @classmethod
158
+ def _from_dict_fields(cls, d: dict[str, Any]) -> "CountFeature":
159
+ return cls(
160
+ name=d["name"],
161
+ immutable=d.get("immutable", False),
162
+ lambda_=d["lambda"],
163
+ max=d.get("max"),
164
+ )
165
+
166
+
167
+ _FEATURE_TYPES: dict[str, type[Feature]] = {
168
+ ContinuousFeature.type: ContinuousFeature,
169
+ CategoricalFeature.type: CategoricalFeature,
170
+ CategoricalOrdinalFeature.type: CategoricalOrdinalFeature,
171
+ NumericOrdinalFeature.type: NumericOrdinalFeature,
172
+ CountFeature.type: CountFeature,
173
+ }
174
+
175
+
176
+ @dataclass
177
+ class FeatureSchema:
178
+ features: list[Feature]
179
+ covariance_matrix: np.ndarray | None = None
180
+
181
+ def __post_init__(self) -> None:
182
+ if self.covariance_matrix is not None:
183
+ n_continuous = sum(1 for f in self.features if isinstance(f, ContinuousFeature))
184
+ if self.covariance_matrix.shape != (n_continuous, n_continuous):
185
+ raise FeatureValidationError(
186
+ f"Covariance matrix must be ({n_continuous}, {n_continuous}), "
187
+ f"got {self.covariance_matrix.shape}"
188
+ )
189
+ if not np.allclose(self.covariance_matrix, self.covariance_matrix.T):
190
+ raise FeatureValidationError("Covariance matrix must be symmetric")
191
+ if not np.all(np.linalg.eigvals(self.covariance_matrix) >= 0):
192
+ raise FeatureValidationError("Covariance matrix must be positive semi-definite")
193
+
194
+ def to_dict(self) -> dict[str, Any]:
195
+ d: dict[str, Any] = {"features": [f.to_dict() for f in self.features]}
196
+ if self.covariance_matrix is not None:
197
+ d["covariance_matrix"] = self.covariance_matrix.tolist()
198
+ return d
199
+
200
+ @classmethod
201
+ def from_dict(cls, d: dict[str, Any]) -> "FeatureSchema":
202
+ features = [Feature.from_dict(f) for f in d["features"]]
203
+ covariance_matrix = d.get("covariance_matrix")
204
+ if covariance_matrix is not None:
205
+ covariance_matrix = np.asarray(covariance_matrix)
206
+ return cls(features=features, covariance_matrix=covariance_matrix)
@@ -0,0 +1,239 @@
1
+ Metadata-Version: 2.4
2
+ Name: proxyml-core
3
+ Version: 0.1.0
4
+ Summary: Shared schema types, export contract, and modeling code for proxyml and its backend.
5
+ Author-email: ProxyML <contact@proxyml.ai>
6
+ License: Apache License
7
+ Version 2.0, January 2004
8
+ http://www.apache.org/licenses/
9
+
10
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
+
12
+ 1. Definitions.
13
+
14
+ "License" shall mean the terms and conditions for use, reproduction,
15
+ and distribution as defined by Sections 1 through 9 of this document.
16
+
17
+ "Licensor" shall mean the copyright owner or entity authorized by
18
+ the copyright owner that is granting the License.
19
+
20
+ "Legal Entity" shall mean the union of the acting entity and all
21
+ other entities that control, are controlled by, or are under common
22
+ control with that entity. For the purposes of this definition,
23
+ "control" means (i) the power, direct or indirect, to cause the
24
+ direction or management of such entity, whether by contract or
25
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
26
+ outstanding shares, or (iii) beneficial ownership of such entity.
27
+
28
+ "You" (or "Your") shall mean an individual or Legal Entity
29
+ exercising permissions granted by this License.
30
+
31
+ "Source" form shall mean the preferred form for making modifications,
32
+ including but not limited to software source code, documentation
33
+ source, and configuration files.
34
+
35
+ "Object" form shall mean any form resulting from mechanical
36
+ transformation or translation of a Source form, including but
37
+ not limited to compiled object code, generated documentation,
38
+ and conversions to other media types.
39
+
40
+ "Work" shall mean the work of authorship made available under
41
+ the License, as indicated by a copyright notice that is included in
42
+ or attached to the work (an example is provided in the Appendix below).
43
+
44
+ "Derivative Works" shall mean any work, whether in Source or Object
45
+ form, that is based on (or derived from) the Work and for which the
46
+ editorial revisions, annotations, elaborations, or other modifications
47
+ represent, as a whole, an original work of authorship. For the purposes
48
+ of this License, Derivative Works shall not include works that remain
49
+ separable from, or merely link (or bind by name) to the interfaces of,
50
+ the Work and Derivative Works thereof.
51
+
52
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
53
+ in the Work by the copyright owner or by an individual or Legal Entity
54
+ authorized to submit on behalf of the copyright owner. For the purposes
55
+ of this definition, "submitted" means any form of electronic, verbal,
56
+ or written communication sent to the Licensor or its representatives,
57
+ including but not limited to communication on electronic mailing lists,
58
+ source code control systems, and issue tracking systems that are managed
59
+ by, or on behalf of, the Licensor for the purpose of developing and
60
+ discussing the Work, but excluding communication that is conspicuously
61
+ marked or designated in writing by the copyright owner as "Not a
62
+ Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
65
+ whom a Contribution has been received by the Licensor and included
66
+ within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by the combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a cross-claim
85
+ or counterclaim in a lawsuit) alleging that the Work or any other
86
+ Contribution incorporated within the Work constitutes patent or
87
+ contributory patent infringement, then any patent licenses granted to
88
+ You under this License for that Work shall terminate as of the date
89
+ such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or Derivative
97
+ Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, You must include a readable copy of the
110
+ attribution notices contained within such NOTICE file, in
111
+ at least one of the following places: within a NOTICE text
112
+ file distributed as part of the Derivative Works; within
113
+ the Source form or documentation, if provided along with the
114
+ Derivative Works; or, within a display generated by the
115
+ Derivative Works, if and wherever such third-party notices
116
+ normally appear. The contents of the NOTICE file are for
117
+ informational purposes only and do not modify the License.
118
+ You may add Your own attribution notices within Derivative
119
+ Works that You distribute, alongside or in addition to the
120
+ NOTICE text from the Work, provided that such additional
121
+ attribution notices cannot be construed as modifying the License.
122
+
123
+ You may add Your own license statement for Your modifications and
124
+ may provide additional grant of rights to use, copy, modify, merge,
125
+ publish, distribute, sublicense, and/or sell copies of the
126
+ Contribution and such Derivative Works.
127
+
128
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
129
+ any Contribution intentionally submitted for inclusion in the Work
130
+ by You to the Licensor shall be under the terms and conditions of
131
+ this License, without any additional terms or conditions.
132
+ Notwithstanding the above, nothing herein shall supersede or modify
133
+ the terms of any separate license agreement you may have executed
134
+ with Licensor regarding such Contributions.
135
+
136
+ 6. Trademarks. This License does not grant permission to use the trade
137
+ names, trademarks, service marks, or product names of the Licensor,
138
+ except as required for reasonable and customary use in describing the
139
+ origin of the Work and reproducing the content of the NOTICE file.
140
+
141
+ 7. Disclaimer of Warranty. Unless required by applicable law or
142
+ agreed to in writing, Licensor provides the Work (and each
143
+ Contributor provides its Contributions) on an "AS IS" BASIS,
144
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
145
+ implied, including, without limitation, any conditions of TITLE,
146
+ NONINFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
147
+ PURPOSE. You are solely responsible for determining the
148
+ appropriateness of using or reproducing the Work and assume any
149
+ risks associated with Your exercise of permissions under this License.
150
+
151
+ 8. Limitation of Liability. In no event and under no legal theory,
152
+ whether in tort (including negligence), contract, or otherwise,
153
+ unless required by applicable law (such as deliberate and grossly
154
+ negligent acts) or agreed to in writing, shall any Contributor be
155
+ liable to You for damages, including any direct, indirect, special,
156
+ incidental, or exemplary damages of any character arising as a
157
+ result of this License or out of the use or inability to use the
158
+ Work (including but not limited to damages for loss of goodwill,
159
+ work stoppage, computer failure or malfunction, or all other
160
+ commercial damages or losses), even if such Contributor has been
161
+ advised of the possibility of such damages.
162
+
163
+ 9. Accepting Warranty or Additional Liability. While redistributing
164
+ the Work or Derivative Works thereof, You may choose to offer,
165
+ and charge a fee for, acceptance of support, warranty, indemnity,
166
+ or other liability obligations and/or rights consistent with this
167
+ License. However, in accepting such obligations, You may charge only
168
+ on Your own behalf and on Your sole responsibility, not on behalf of
169
+ any other Contributor, and only if You agree to indemnify, defend,
170
+ and hold each Contributor harmless for any liability incurred by,
171
+ or claims asserted against, such Contributor by reason of your
172
+ accepting any warranty or additional liability.
173
+
174
+ END OF TERMS AND CONDITIONS
175
+
176
+ Copyright 2026 ProxyML
177
+
178
+ Licensed under the Apache License, Version 2.0 (the "License");
179
+ you may not use this file except in compliance with the License.
180
+ You may obtain a copy of the License at
181
+
182
+ http://www.apache.org/licenses/LICENSE-2.0
183
+
184
+ Unless required by applicable law or agreed to in writing, software
185
+ distributed under the License is distributed on an "AS IS" BASIS,
186
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
187
+ See the License for the specific language governing permissions and
188
+ limitations under the License.
189
+
190
+ Project-URL: Homepage, https://proxyml.ai
191
+ Project-URL: Repository, https://github.com/proxyml/proxyml-core
192
+ Project-URL: Bug Tracker, https://github.com/proxyml/proxyml-core/issues
193
+ Keywords: machine learning,surrogate models,explainability
194
+ Classifier: Development Status :: 3 - Alpha
195
+ Classifier: Intended Audience :: Developers
196
+ Classifier: Intended Audience :: Science/Research
197
+ Classifier: License :: OSI Approved :: Apache Software License
198
+ Classifier: Programming Language :: Python :: 3
199
+ Classifier: Programming Language :: Python :: 3.10
200
+ Classifier: Programming Language :: Python :: 3.11
201
+ Classifier: Programming Language :: Python :: 3.12
202
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
203
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
204
+ Requires-Python: >=3.10
205
+ Description-Content-Type: text/markdown
206
+ License-File: LICENSE
207
+ Requires-Dist: numpy>=1.24
208
+ Provides-Extra: modeling
209
+ Requires-Dist: scikit-learn>=1.4; extra == "modeling"
210
+ Requires-Dist: scipy>=1.10; extra == "modeling"
211
+ Provides-Extra: dev
212
+ Requires-Dist: pytest; extra == "dev"
213
+ Requires-Dist: ruff; extra == "dev"
214
+ Dynamic: license-file
215
+
216
+ # proxyml-core
217
+
218
+ Shared library for [proxyml](https://proxyml.ai) — schema types, the export
219
+ JSON contract, and (behind the `modeling` extra) the sklearn-based training
220
+ and preprocessing code used by both the proxyml backend and the `proxyml`
221
+ SDK's local challenger training.
222
+
223
+ ## Layout
224
+
225
+ - `proxyml_core.schema` — pure. `Feature` hierarchy, `FeatureSchema`.
226
+ - `proxyml_core.export` — pure. Export dataclasses, `EXPORT_SCHEMA_VERSION`,
227
+ `predict_from_export()`.
228
+ - `proxyml_core.modeling` — requires `proxyml-core[modeling]` (scikit-learn,
229
+ scipy). Preprocessing, default estimators, export extraction.
230
+
231
+ The pure base (`schema`, `export`, `_version`) depends only on `numpy`, so a
232
+ REST-only `proxyml` install never needs scikit-learn.
233
+
234
+ ## Install
235
+
236
+ ```
237
+ pip install proxyml-core # pure: schema + export
238
+ pip install proxyml-core[modeling] # + scikit-learn, scipy
239
+ ```
@@ -0,0 +1,13 @@
1
+ proxyml_core/__init__.py,sha256=x1Uw2EivHkQyDFGGl_swWytVMDvXEKcgNjCf0k5O1qo,1005
2
+ proxyml_core/_version.py,sha256=j7bsYsaAses-dNgoBWAaOhMloIGH72uFdRTbiFRlf8Q,849
3
+ proxyml_core/export.py,sha256=vevNi3s4WRdCh4DwlmSI2Cdb1sg-2HLLFjMRhGt3-bw,8793
4
+ proxyml_core/schema.py,sha256=tyySFJzgl5luC3blVWp3uyrv1L3QwiTxr1rhDiLpBt8,6782
5
+ proxyml_core/modeling/__init__.py,sha256=M1mcePMBlDzYYFkL2OA8TiIVVToHrDtgVFATwWnP7gM,567
6
+ proxyml_core/modeling/estimators.py,sha256=qnNglhUHw5-OhkXx0cVMtyz_GLgzWDUiqNN4rhWTrfk,2432
7
+ proxyml_core/modeling/extract.py,sha256=RwqwyWT70v-EQR_noPmRLBNgz2kd0m7c6H5u9y1pEVg,4925
8
+ proxyml_core/modeling/preprocess.py,sha256=F_25r88yl9DZOgHw_y2NDUOpiscc_RkA2-o4XRgVtuk,2550
9
+ proxyml_core-0.1.0.dist-info/licenses/LICENSE,sha256=g3kg6VH6Fi9-VhRB0ZYTPsVKUAMx7D9UsoZMJ_KZtko,10196
10
+ proxyml_core-0.1.0.dist-info/METADATA,sha256=TFNefQXEYpZorcz1Lh2hSBl1WbgYCfOAziH-rlNPgwU,13888
11
+ proxyml_core-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
12
+ proxyml_core-0.1.0.dist-info/top_level.txt,sha256=IgLPgv8fD4gWRw-mxtZ3Drsub9CRcMBU-BNvcsDlq3s,13
13
+ proxyml_core-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,183 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of developing and
55
+ discussing the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and included
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by the combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any other
81
+ Contribution incorporated within the Work constitutes patent or
82
+ contributory patent infringement, then any patent licenses granted to
83
+ You under this License for that Work shall terminate as of the date
84
+ such litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative
92
+ Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or in addition to the
115
+ NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, copy, modify, merge,
120
+ publish, distribute, sublicense, and/or sell copies of the
121
+ Contribution and such Derivative Works.
122
+
123
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
124
+ any Contribution intentionally submitted for inclusion in the Work
125
+ by You to the Licensor shall be under the terms and conditions of
126
+ this License, without any additional terms or conditions.
127
+ Notwithstanding the above, nothing herein shall supersede or modify
128
+ the terms of any separate license agreement you may have executed
129
+ with Licensor regarding such Contributions.
130
+
131
+ 6. Trademarks. This License does not grant permission to use the trade
132
+ names, trademarks, service marks, or product names of the Licensor,
133
+ except as required for reasonable and customary use in describing the
134
+ origin of the Work and reproducing the content of the NOTICE file.
135
+
136
+ 7. Disclaimer of Warranty. Unless required by applicable law or
137
+ agreed to in writing, Licensor provides the Work (and each
138
+ Contributor provides its Contributions) on an "AS IS" BASIS,
139
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
140
+ implied, including, without limitation, any conditions of TITLE,
141
+ NONINFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
142
+ PURPOSE. You are solely responsible for determining the
143
+ appropriateness of using or reproducing the Work and assume any
144
+ risks associated with Your exercise of permissions under this License.
145
+
146
+ 8. Limitation of Liability. In no event and under no legal theory,
147
+ whether in tort (including negligence), contract, or otherwise,
148
+ unless required by applicable law (such as deliberate and grossly
149
+ negligent acts) or agreed to in writing, shall any Contributor be
150
+ liable to You for damages, including any direct, indirect, special,
151
+ incidental, or exemplary damages of any character arising as a
152
+ result of this License or out of the use or inability to use the
153
+ Work (including but not limited to damages for loss of goodwill,
154
+ work stoppage, computer failure or malfunction, or all other
155
+ commercial damages or losses), even if such Contributor has been
156
+ advised of the possibility of such damages.
157
+
158
+ 9. Accepting Warranty or Additional Liability. While redistributing
159
+ the Work or Derivative Works thereof, You may choose to offer,
160
+ and charge a fee for, acceptance of support, warranty, indemnity,
161
+ or other liability obligations and/or rights consistent with this
162
+ License. However, in accepting such obligations, You may charge only
163
+ on Your own behalf and on Your sole responsibility, not on behalf of
164
+ any other Contributor, and only if You agree to indemnify, defend,
165
+ and hold each Contributor harmless for any liability incurred by,
166
+ or claims asserted against, such Contributor by reason of your
167
+ accepting any warranty or additional liability.
168
+
169
+ END OF TERMS AND CONDITIONS
170
+
171
+ Copyright 2026 ProxyML
172
+
173
+ Licensed under the Apache License, Version 2.0 (the "License");
174
+ you may not use this file except in compliance with the License.
175
+ You may obtain a copy of the License at
176
+
177
+ http://www.apache.org/licenses/LICENSE-2.0
178
+
179
+ Unless required by applicable law or agreed to in writing, software
180
+ distributed under the License is distributed on an "AS IS" BASIS,
181
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
182
+ See the License for the specific language governing permissions and
183
+ limitations under the License.
@@ -0,0 +1 @@
1
+ proxyml_core