I have a ML model (trained in Sklearn) and based on it I have created a Flask web service and hosted it on Windows IIS server.
What is the best practice to load the model? Shall I load the model when we start the API or model should be loading when the request coming?
Case1
import flask
import joblib
app = Flask(name)
load the models
MODELS = joblib.load(model_file)
endpoints
@app.route("/predictions", methods=["GET", "POST"])
def predictions():
some code
case2
import flask
import joblib
app = Flask(name)
endpoints
@app.route("/predictions", methods=["GET", "POST"])
def predictions():
load the model
model = joblib.load(model_file)