LovnishVermaPRINCE commited on
Commit
ded7889
·
1 Parent(s): 69a83f3

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +29 -2
main.py CHANGED
@@ -1,5 +1,8 @@
1
  from flask import Flask, request, jsonify, render_template
2
  from flask_cors import CORS
 
 
 
3
 
4
  app = Flask(__name__)
5
  app.static_folder = 'static'
@@ -10,8 +13,32 @@ app.secret_key = "flask-nielit-2023"
10
  CORS(app)
11
 
12
  @app.route('/')
13
- def index():
14
- return render_template('index.html')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  if __name__ == '__main__':
17
  app.run()
 
1
  from flask import Flask, request, jsonify, render_template
2
  from flask_cors import CORS
3
+ import numpy as np
4
+ import pandas as pd
5
+ from sklearn.linear_model import LogisticRegression
6
 
7
  app = Flask(__name__)
8
  app.static_folder = 'static'
 
13
  CORS(app)
14
 
15
  @app.route('/')
16
+ def iris():
17
+ return render_template("index.html")
18
+
19
+ @app.route('/irisf', methods=["POST"])
20
+ def page():
21
+ swidth=eval(request.form.get("swidth"))
22
+ sheight=eval(request.form.get("sheight"))
23
+ pwidth=eval(request.form.get("pwidth"))
24
+ pheight=eval(request.form.get("pheight"))
25
+
26
+ url="https://raw.githubusercontent.com/lovnishverma/datasets/main/iris.csv"
27
+
28
+ data=pd.read_csv(url, header=None)
29
+ flower=data.values
30
+
31
+ #Split
32
+ x=flower[:,:4]
33
+ y=flower[:,-1]
34
+
35
+ model=LogisticRegression()
36
+ model.fit(x,y)
37
+
38
+ arr=model.predict([[swidth,sheight,pwidth,pheight]])
39
+
40
+ return render_template("index.html", data=str(arr[0]))
41
+
42
 
43
  if __name__ == '__main__':
44
  app.run()