'KeyError: 'initialized_diffuse'

I'm getting a keyerror 'initialized_diffuse' while calling the following API, probably after joblib.load().

import joblib
..........

@routes.route("/forecast", methods=["GET"])
def forecaster():
    try:
       
        forecast = joblib.load("./lib/forecast.pkl")
        forecast_sales = forecast.get_forecast(steps=15).predicted_mean
        sales = pd.read_pickle("./lib/sales.pkl")
        responses = jsonify(
            hist=sales.to_json(orient="columns"),
            pred=forecast_sales.to_json(orient="index"),
        )
        responses.headers.add('Access-Control-Allow-Origin', '*')
        responses.status_code = 200
        return(responses)

    except Exception as e:
        raise e

Any idea on this error?



Solution 1:[1]

I faced the same issue when tried to load the .pkl on statsmodels==0.13.2, which was created earlier on statsmodels==0.11.0; Resolved it after downgrading the statsmodels to the earlier version. Try downgrading the statsmodels version using pip;

pip3 install statsmodels==0.11.0

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1