No fallar al predecir un grupo sin categorías vistas en el ajuste
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
"""A stratum in which no row is at a level the fit saw gives no value, not an error."""
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
from models.cacu.pim import Mixture
|
||||
|
||||
|
||||
def test_rows_only_at_unseen_levels_are_left_without_a_risk():
|
||||
X = pd.DataFrame({"cytology": ["NILM", "NILM", "ASC-US", "ASC-US"] * 10})
|
||||
y = pd.DataFrame({"c": [0, 1] * 20, "l": [1.0, 0.0] * 20, "r": [np.inf, 0.0] * 20})
|
||||
y.loc[::5, ["c", "l", "r"]] = [-999, 0.5, 2.0]
|
||||
mixture = Mixture((1, 5), ["cytology"], (), {"cytology": ["NILM", "ASC-US", "High Grade"]})
|
||||
mixture.fit(X, y)
|
||||
assert np.isnan(mixture.predict(pd.DataFrame({"cytology": ["High Grade"]}))).all()
|
||||
Reference in New Issue
Block a user