Deploy ML model on Flask Web app (many features)

Viewed 35

I'm struggling with my ML model that i wish to deploy on Flask.

I used the method get dummies to split the categorical variables, which result in a dataframe of 140 columns (I know it a lot).

Can I simply deploy the model on Flask without the need of requesting all of the binaries feature?

Here is the code for the Web App below :

from flask import Flask,render_template,request
import pickle
import numpy as np


app = Flask('__name__')
model=pickle.load(open('model.pkl','rb'))

 @app.route('/')
 def hello():
     return render_template("home.html", message = "House price prediction by Andy ! ")

@app.route('/',methods=["GET","POST"])
def predict():
    feature=[int(x) for x in request.form.values()]
    #print(feature)
    feature_final=np.array(feature).reshape(-1,1)
    #print(feature_final)
    prediction=model.predict(feature_final)
    return render_template('home.html',prediction_text="Prediction is : {}".format(int(prediction)))


if(__name__=='__main__'):
    app.run(debug=True)

Trying to compact all of dummies columns in simply input for the Flask Web app.

0 Answers
Related