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()[0]
  write_file(blob_file, 'load_model')
  loaded_model = joblib.load('load_model')


This didn't work though:

with open(blob_file, 'rb') as f:
      model = pickle.load(f)

What is the best way?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.