-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
57 lines (40 loc) · 1.53 KB
/
Copy pathapp.py
File metadata and controls
57 lines (40 loc) · 1.53 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from flask import Flask,render_template,request
import os
from werkzeug.utils import secure_filename
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/prediction')
def predict():
return render_template('dataloader.html')
@app.route('/uploadajax',methods=['POST'])
def upldfile():
prod_mas = request.files['prod_mas']
filename = secure_filename(prod_mas.filename)
prod_mas.save(os.path.join('./static/Upload/',filename))
import pandas as pd
dataset = pd.read_csv('./static/Upload/'+filename)
print(dataset)
print("****************************")
print(dataset.shape)
print("****************************")
print(dataset.head(5))
print("****************************")
print(dataset.info())
from sklearn.model_selection import train_test_split
predictors = dataset.drop('target',axis=1)#X Value
target = dataset["target"]
X_train,X_test,Y_train,Y_test = train_test_split(predictors,target,test_size=0.20,random_state=0)
from sklearn.metrics import accuracy_score
from sklearn.linear_model import LogisticRegression
lr = LogisticRegression()
#fitness model
lr.fit(X_train,Y_train)
#Prediction
y_pred_lr = lr.predict(X_test)
#Accuracy Score
print("Accuarcy Score: "+str(accuracy_score(y_pred_lr,Y_test)*100))
return render_template('dataloader.html',data="Data Loaded Successfully")
if __name__ == "__main__":
app.run(debug=True)