I am trying to deploy the variable "prediction" from FLASK to the cell with ID = prediction. The variable is correctly calculated in the app, I just cannot deploy & display it in the html table ... I would really appreciate if you could tell me how to proceed. I did the most difficult part with the model and now I cannot deploy it. Thanks in advance
import numpy as np
from flask import Flask, request, render_template
import pickle
import pandas as pd
app = Flask(__name__)
model = pickle.load(open('logreg.pkl', 'rb'))
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict',methods=['POST'])
def predict():
int_features = [str(x) for x in request.form.values()]
final_features = np.array(int_features)
df = pd.read_csv('list_last_update.csv')
home_team = df[df['Name']==final_features[0]]
away_team = df[df['Name']==final_features[1]]
X1 = np.array(home_team[['OVA', 'ATT']])
X2 = np.array(away_team[['OVA', 'ATT']])
X = np.concatenate((X1, X2), axis=None).astype(int)
X = X.reshape(1, -1)
prediction = model.predict(X)
return render_template('index.html')
if __name__ == "__main__":
app.run(host='0.0.0.0',port=8080)
``
<td>
<div class="autocomplete" style="width:300px;">
<input id="away_team" type="text" name="team2" placeholder="Away Team" required="required" />
</div>
</td>
<button type="submit" class="btn btn-primary btn-block btn-large">Print team rates</button>
</form>
<td>
<input id="prediction" type="number" style="text-align:center"/>
</td>
<td>
<input id="draw_game_odd" type="number" style="text-align:center"/>
</td>
<td>
<input id="away_team_odd" type="number" style="text-align:center"/>
</td>