-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
52 lines (38 loc) · 1.53 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import numpy as np
from flask import Flask, request, render_template, jsonify
import pickle
app = Flask(__name__)
model_placement = pickle.load(open('placement.pkl', 'rb'))
model_salary=pickle.load(open('salary.pkl', 'rb'))
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict',methods=['POST'])
def predict():
int_features = [float(x) for x in request.form.values()]
final_features = [np.array(int_features)]
prediction = model_placement.predict(final_features)
output = prediction[0]
if output == 'Yes':
salary = model_salary.predict(final_features)
salary = round(salary[0], -5) / 10
return render_template('index.html', prediction_text=' {}'.format(output)+' Approx. Salary: {}LPA'.format(salary/100000))
if output == 'No':
return render_template('index.html', prediction_text=' {}'.format(output))
@app.route('/api',methods=['GET'])
def api():
dic=request.args.to_dict()
print(dic)
int_features = [float(x) for x in dic.values()]
final_features = [np.array(int_features)]
prediction = model_placement.predict(final_features)
# out={'Not Placed':'No', 'Placed':'Yes'}
output=prediction[0]
if output=='Yes':
salary = model_salary.predict(final_features)
salary=round(salary[0],-5)/10
return jsonify(status=output,salary=salary)
if output == 'No':
return jsonify(status=output,salary=0)
if __name__ == "__main__":
app.run(debug=True)