-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews.py
39 lines (33 loc) · 1.33 KB
/
views.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
from django.shortcuts import render
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score
def home(request):
return render(request, 'home.html')
def predict(request):
return render(request, 'predict.html')
def result(request):
data = pd.read_csv("C:/Users/sujit/AIML Internship/diabetes_dataset/diabetes.csv")
X = data.drop("Outcome", axis=1)
Y = data['Outcome']
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2, random_state=42)
model = SVC()
model.fit(X_train, Y_train)
val1 = float(request.GET['n1'])
val2 = float(request.GET['n2'])
val3 = float(request.GET['n3'])
val4 = float(request.GET['n4'])
val5 = float(request.GET['n5'])
val6 = float(request.GET['n6'])
val7 = float(request.GET['n7'])
val8 = float(request.GET['n8'])
pred = model.predict([[val1, val2, val3, val4, val5, val6, val7, val8]])
result2 = ""
if pred==[1]:
result1 = "Oopsie! Diabetes alert!"
else:
result1 = "Woohoo!!! No diabetes here!"
return render(request, "predict.html", {"result2":result1})