-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
42 lines (32 loc) · 1.08 KB
/
app.py
File metadata and controls
42 lines (32 loc) · 1.08 KB
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
import numpy as np
import pandas as pd
from flask import Flask, abort, jsonify, request
from pandas.io.json import json_normalize
import pickle as pickle
import sklearn
import random
with open('pickle_model', 'rb') as f:
model = pickle.load(f)
app = Flask(__name__)
@app.route('/')
def default():
return 'Homepage'
@app.route('/api', methods=['POST'])
def predict():
input = request.get_json(force=True)
hq=input['headquarters']
industry=input['industry']
founders=input['numFounders']
funding_round=input['numFundingRounds']
articles=input['numArticles']
employees=input['numEmployees']
predict_df=pd.DataFrame(columns=['Headquarters Location', 'Categories',
'Number of Founders',
'Number of Funding Rounds',
'Number of Articles',
'Number of Employees'])
predict_df.loc[0] = ([hq, industry, founders, funding_round, articles, employees])
prediction = model.predict_proba(predict_df)[0][1]
return jsonify(prediction=prediction)
if __name__ == '__main__':
app.run()