Is your feature request related to a problem? Please describe.
causalML has no standard way to persist a trained learner. Once you call .fit(), the only way to reuse that model is to keep the Python process alive or re-train from scratch. This is a significant gap for production workflows where models are trained in one environment(e.g. a batch job) and served or evaluated in another. Currently users are forced to reach for pickle or joblib manually, with no guarantee that the serialized object is compatible with the installed version of causalML, no standardized file format, and no integration with experiment tracking tools like MLflow
Describe the solution you'd like
add SerializableLearner mixin that all base learners (BaseTLearner, BaseSLearner, BaseXLearner, BaseRLearner, BaseDRLearner) inherit from, exposing two methods:
pythonlearner.save("model.causalml")
learner = BaseTRegressor.load("model.causalml")
every saved file would embed __causalml_version__ and __learner_class__ metadata. On load, if the installed version does not match, a CausalMLVersionMismatchWarning is raised so users are never silently running a stale model. MLflow integration would be added as an optional thin wrapper via to_mlflow() and from_mlflow(), raising a helpful ImportError if MLflow is not installed
Describe alternatives you've considered
using raw joblib.dump / joblib.load directly works but puts the burden on the user to handle versioning, class validation, and path conventions themselves. There is no way to know whether a saved file was produced by the same version of CausalML, which makes sharing models across teams or environments risky. A standardized mixin solves this once at the library level rather than in every user's codebase
Additional context
Is your feature request related to a problem? Please describe.
causalMLhas no standard way to persist a trained learner. Once you call.fit(), the only way to reuse that model is to keep the Python process alive or re-train from scratch. This is a significant gap for production workflows where models are trained in one environment(e.g. a batch job) and served or evaluated in another. Currently users are forced to reach forpickleorjoblibmanually, with no guarantee that the serialized object is compatible with the installed version ofcausalML,no standardized file format, and no integration with experiment tracking tools likeMLflowDescribe the solution you'd like
add
SerializableLearnermixin that all base learners (BaseTLearner, BaseSLearner, BaseXLearner, BaseRLearner, BaseDRLearner) inherit from, exposing two methods:every saved file would embed
__causalml_version__and__learner_class__metadata. On load, if the installed version does not match, aCausalMLVersionMismatchWarningis raised so users are never silently running a stale model.MLflowintegration would be added as an optional thin wrapper viato_mlflow()andfrom_mlflow(),raising a helpfulImportErrorifMLflowis not installedDescribe alternatives you've considered
using raw
joblib.dump/joblib.loaddirectly works but puts the burden on the user to handle versioning, class validation, and path conventions themselves. There is no way to know whether a saved file was produced by the same version of CausalML, which makes sharing models across teams or environments risky. A standardized mixin solves this once at the library level rather than in every user's codebaseAdditional context