-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Contact details
What happened?
Exporting a scikit-learn Pipeline that contains a TransformedTargetRegressor (TTR) step using pymilo.Export(...) fails: PyMilo raises PymiloSerializationException and reports the model has non-standard/custom internal objects.
Steps to reproduce
- Build a pipeline with an X-scaler and a TransformedTargetRegressor :
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import SGDRegressor
from sklearn.compose import TransformedTargetRegressor
from sklearn.pipeline import Pipeline
from pymilo import Export
reg = SGDRegressor(...)
x_scaler = StandardScaler()
y_scaler = StandardScaler()
ttr = TransformedTargetRegressor(regressor=reg, transformer=y_scaler)
pipeline = Pipeline([("x_scaler", x_scaler), ("ttr", ttr)])
Export(pipeline).save("_tmp_pipeline_ttr.json")
- Run the script → Export fails.
Expected behavior
PyMilo should either successfully serialize the Pipeline that contains TransformedTargetRegressor (by handling TTR).
Actual behavior
Export(pipeline) raises a PymiloSerializationException. Internally Python raises TypeError: Object of type TransformedTargetRegressor is not JSON serializable, so PyMilo cannot produce the JSON export for this composite object.
Operating system
Windows
Python version
Python 3.12
PyMilo version
PyMilo 1.3
Relevant log output
Exception type: PymiloSerializationException
Exception message: PymiloSerializationException('Pymilo Serialization failed since the given model has some non-standard customized internal objects or functions.')