-
Notifications
You must be signed in to change notification settings - Fork 167
/
app.py
58 lines (44 loc) · 1.22 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
53
54
55
56
57
from flask import Flask, render_template, request
from implementation import randorm_forest_test, random_forest_train, random_forest_predict
from sklearn.preprocessing import StandardScaler
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from random_forest import accuracy
from sklearn.metrics import accuracy_score
from time import time
app = Flask(__name__)
app.url_map.strict_slashes = False
@app.route('/')
def index():
return render_template('home.html')
@app.route('/predict', methods=['POST'])
def login_user():
data_points = list()
data = []
string = 'value'
for i in range(1,31):
data.append(float(request.form['value'+str(i)]))
for i in range(30):
data_points.append(data[i])
print(data_points)
data_np = np.asarray(data, dtype = float)
data_np = data_np.reshape(1,-1)
out, acc, t = random_forest_predict(clf, data_np)
if(out==1):
output = 'Malignant'
else:
output = 'Benign'
acc_x = acc[0][0]
acc_y = acc[0][1]
if(acc_x>acc_y):
acc1 = acc_x
else:
acc1=acc_y
return render_template('result.html', output=output, accuracy=accuracy, time=t)
if __name__=='__main__':
global clf
clf = random_forest_train()
randorm_forest_test(clf)
#print("Done")
app.run(debug=True)