File size: 1,008 Bytes
0eaa54f
 
 
 
 
 
 
b2c41e7
0eaa54f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from flask import Flask, request, jsonify, render_template
from flask_cors import CORS
import numpy as np
import pandas as pd
from sklearn.linear_model import LogisticRegression

app = Flask(__name__)

app.static_folder = 'static'
app.static_url_path = '/static'

app.secret_key = "flask-nielit-2023"

CORS(app)

@app.route('/')
def iris():
  return render_template("index.html")

@app.route('/irisf', methods=["POST"])
def page():
  swidth=eval(request.form.get("swidth"))
  sheight=eval(request.form.get("sheight"))
  pwidth=eval(request.form.get("pwidth"))
  pheight=eval(request.form.get("pheight"))
  
  url="https://raw.githubusercontent.com/lovnishverma/datasets/main/iris.csv"
  
  data=pd.read_csv(url, header=None)
  flower=data.values
  
  #Split
  x=flower[:,:4]
  y=flower[:,-1]
  
  model=LogisticRegression()
  model.fit(x,y)
  
  arr=model.predict([[swidth,sheight,pwidth,pheight]])

  return render_template("index.html", data=str(arr[0]))


if __name__ == '__main__':
    app.run()