Search code examples
pythonscikit-learndev-to-productionscikit-learn-pipeline

SimpleImputer object has no attribute _fit_dtype


I have a trained scikit-learn model pipeline (including a SimpleImputer) that I'm trying to put into production. However, I get the following error when running it in the production environment.

SimpleImputer object has no attribute _fit_dtype

How do I solve this?


Solution

  • This is a result of using different versions of scikit-learn in the development and production environments. The model has been trained using one version and then it's used with a different version.

    This can be solved by storing the current library versions in the development environment in a requirements.txt file using:

    pip list --format=freeze > requirements.txt
    

    In the production environment, install the same library versions with:

    pip install -r requirements.txt