Commit 92efee9e authored by Kareshaan Logeswaran's avatar Kareshaan Logeswaran

created It20008628 backend

parent 99ffd648
from flask import Flask, request, render_template
import numpy as np
from joblib import load
app = Flask(__name__)
model = load('XGB_All_1_model.joblib')
@app.route('/predictcost',methods=['POST'])
def predict():
Year = int(request.form['Year'])
Season = int(request.form['Season'])
Preliminary_Dev = int(request.form['Preliminary_Dev'])
Ploughing = int(request.form['Ploughing'])
Levelling = int(request.form['Levelling'])
Transplanting = int(request.form['Transplanting'])
Plastering = int(request.form['Plastering'])
Fertilization = int(request.form['Fertilization'])
Harvesting = int(request.form['Harvesting'])
Threshing = int(request.form['Threshing'])
Winnowing = int(request.form['Winnowing'])
Tot_without_Imputed = int(request.form['Tot_without_Imputed'])
Seeding = int(request.form['Seeding'])
Hired_Labour = int(request.form['Hired_Labour'])
Family_Labour = int(request.form['Family_Labour'])
Fertilizer_Purchase = int(request.form['Fertilizer_Purchase'])
Average_Yield = int(request.form['Average_Yield'])
feature_list = [Year, Season, Preliminary_Dev, Ploughing, Levelling, Transplanting, Plastering, Fertilization,
Harvesting, Threshing, Winnowing, Tot_without_Imputed, Seeding,Hired_Labour, Family_Labour,
Fertilizer_Purchase, Average_Yield]
single_pred = np.array(feature_list).reshape(1, -1)
prediction = model.predict(single_pred)
result = "Predicted Price: {:.2f}".format(prediction[0]) + " Rs/kg"
return render_template('cost.html',result = result)
@app.route('/')
def index():
return render_template('cost.html')
# python main
if __name__ == '__main__':
#app.run(debug=True)
app.run(host='127.0.0.1', port=5010)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment