I have tried the following way. It worked, but it is giving a different prediction in Flask vs Jupyter (which is correct)
pickledFile = _pickle.dumps(trained_model) cursor.execute("INSERT INTO trained_models(name, model, mod_date) VALUES (%s, _binary%s, %s);",("model1",pickledFile, datetime.now())) cursor.execute("SELECT model, name FROM trained_models where mod_date = select MAX(date) FROM trained_models);") blob_file = cursor.fetchone() write_file(blob_file, 'load_model') loaded_model = joblib.load('load_model') loaded_model.predict(x)
This didn't work though:
with open(blob_file, 'rb') as f: model = pickle.load(f)
What is the best way?