proxyml-core 0.2.0__tar.gz → 0.2.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.
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/PKG-INFO +1 -1
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/pyproject.toml +1 -1
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/src/proxyml_core/modeling/estimators.py +5 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/src/proxyml_core.egg-info/PKG-INFO +1 -1
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/tests/test_modeling_estimators.py +26 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/LICENSE +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/README.md +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/setup.cfg +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/src/proxyml_core/__init__.py +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/src/proxyml_core/_version.py +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/src/proxyml_core/export.py +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/src/proxyml_core/modeling/__init__.py +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/src/proxyml_core/modeling/extract.py +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/src/proxyml_core/modeling/preprocess.py +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/src/proxyml_core/modeling/scoring.py +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/src/proxyml_core/schema.py +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/src/proxyml_core.egg-info/SOURCES.txt +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/src/proxyml_core.egg-info/dependency_links.txt +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/src/proxyml_core.egg-info/requires.txt +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/src/proxyml_core.egg-info/top_level.txt +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/tests/test_dependency_boundaries.py +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/tests/test_export.py +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/tests/test_export_version_contract.py +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/tests/test_modeling_extract.py +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/tests/test_modeling_preprocess.py +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/tests/test_modeling_scoring.py +0 -0
- {proxyml_core-0.2.0 → proxyml_core-0.2.1}/tests/test_schema.py +0 -0
|
@@ -47,6 +47,10 @@ def binarize_if_probabilities(predictions: np.ndarray) -> np.ndarray:
|
|
|
47
47
|
if predictions.dtype.kind not in "iuf": # not int/uint/float — already discrete labels
|
|
48
48
|
return predictions
|
|
49
49
|
as_float = predictions.astype(float)
|
|
50
|
+
if not np.all(np.isfinite(as_float)):
|
|
51
|
+
# Casting NaN/inf to int is undefined — silently mis-binarizes to 0
|
|
52
|
+
# instead of raising, so reject it explicitly instead.
|
|
53
|
+
raise ValueError("predictions must not contain NaN or infinite values")
|
|
50
54
|
if np.all(as_float == as_float.astype(int)):
|
|
51
55
|
return predictions
|
|
52
56
|
return (as_float >= 0.5).astype(int)
|
|
@@ -60,6 +64,7 @@ def get_default_classifier() -> BaseEstimator:
|
|
|
60
64
|
max_iter=500,
|
|
61
65
|
cv=5,
|
|
62
66
|
n_jobs=-1,
|
|
67
|
+
scoring="accuracy",
|
|
63
68
|
use_legacy_attributes=False,
|
|
64
69
|
)
|
|
65
70
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
|
|
1
3
|
import numpy as np
|
|
4
|
+
import pytest
|
|
2
5
|
|
|
3
6
|
from proxyml_core.modeling.estimators import (
|
|
4
7
|
binarize_if_probabilities,
|
|
@@ -40,6 +43,18 @@ def test_binarize_if_probabilities_passes_through_object_labels():
|
|
|
40
43
|
assert list(out) == ["yes", "no"]
|
|
41
44
|
|
|
42
45
|
|
|
46
|
+
def test_binarize_if_probabilities_rejects_nan():
|
|
47
|
+
# Casting NaN to int is undefined and previously silently mis-binarized
|
|
48
|
+
# to 0 instead of raising — must fail loudly instead.
|
|
49
|
+
with pytest.raises(ValueError, match="NaN or infinite"):
|
|
50
|
+
binarize_if_probabilities(np.array([0.1, 0.6, np.nan, 0.5]))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_binarize_if_probabilities_rejects_inf():
|
|
54
|
+
with pytest.raises(ValueError, match="NaN or infinite"):
|
|
55
|
+
binarize_if_probabilities(np.array([0.1, 0.6, np.inf, 0.5]))
|
|
56
|
+
|
|
57
|
+
|
|
43
58
|
def test_to_json_safe_handles_numpy_types():
|
|
44
59
|
assert to_json_safe(np.array([1, 2, 3])) == [1, 2, 3]
|
|
45
60
|
assert to_json_safe(np.float64(1.5)) == 1.5
|
|
@@ -57,6 +72,17 @@ def test_extract_hyperparameters_includes_cv_selected_values():
|
|
|
57
72
|
assert isinstance(params["alpha_"], float)
|
|
58
73
|
|
|
59
74
|
|
|
75
|
+
def test_get_default_classifier_fits_without_sklearn_deprecation_warnings():
|
|
76
|
+
# scoring="accuracy" and use_legacy_attributes=False pin today's sklearn
|
|
77
|
+
# defaults explicitly, so upgrading sklearn can't silently change fit
|
|
78
|
+
# behavior and users don't see FutureWarning noise on every fit.
|
|
79
|
+
X = np.random.RandomState(0).normal(size=(50, 3))
|
|
80
|
+
y = (X[:, 0] > 0).astype(int)
|
|
81
|
+
with warnings.catch_warnings():
|
|
82
|
+
warnings.simplefilter("error", FutureWarning)
|
|
83
|
+
get_default_classifier().fit(X, y)
|
|
84
|
+
|
|
85
|
+
|
|
60
86
|
def test_get_default_classifier_and_regressor_are_fittable():
|
|
61
87
|
X = np.random.RandomState(0).normal(size=(50, 3))
|
|
62
88
|
y_class = (X[:, 0] > 0).astype(int)
|
|
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
|
|
File without changes
|
|
File without changes
|