Spaces:
Runtime error
Runtime error
Commit
·
875fa0f
1
Parent(s):
126faab
Upload 2 files
Browse files- app.py +48 -0
- requirements.txt +7 -0
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import numpy as np
|
| 4 |
+
import pandas as pd
|
| 5 |
+
from sklearn.preprocessing import StandardScaler
|
| 6 |
+
from sklearn.model_selection import train_test_split
|
| 7 |
+
from sklearn import svm
|
| 8 |
+
from sklearn.metrics import accuracy_score
|
| 9 |
+
kkk_diabetes_dataset = pd.read_csv('diabetes.csv')
|
| 10 |
+
X = kkk_diabetes_dataset.drop(columns = 'Outcome', axis=1)
|
| 11 |
+
Y = kkk_diabetes_dataset['Outcome']
|
| 12 |
+
scaler = StandardScaler()
|
| 13 |
+
scaler.fit(X)
|
| 14 |
+
standardized_data = scaler.transform(X)
|
| 15 |
+
|
| 16 |
+
X = standardized_data
|
| 17 |
+
Y = kkk_diabetes_dataset['Outcome']
|
| 18 |
+
from sklearn.neural_network import MLPClassifier
|
| 19 |
+
classifier = MLPClassifier(max_iter=1000, alpha=1)
|
| 20 |
+
X_train, X_test, Y_train, Y_test = train_test_split(X,Y, test_size = 0.2, stratify=Y, random_state=2)
|
| 21 |
+
classifier.fit(X_train, Y_train)
|
| 22 |
+
|
| 23 |
+
def diabetes(Pregnancies, Glucose_levels_in_millimoles_per_litres, Blood_Pressure_in_millimetres_of_mercury, Skin_Thickness_in_millimetres, Insulin_levels, BMI_in_kilogram_per_square_metres, Diabetes_Pedigree, Age_in_years):
|
| 24 |
+
x = np.array([Pregnancies, Glucose_levels_in_millimoles_per_litres, Blood_Pressure_in_millimetres_of_mercury, Skin_Thickness_in_millimetres, Insulin_levels, BMI_in_kilogram_per_square_metres, Diabetes_Pedigree, Age_in_years])
|
| 25 |
+
prediction = classifier.predict(x.reshape(1, -1))
|
| 26 |
+
if prediction == 0:
|
| 27 |
+
return "Patient is NOT DIABETIC"
|
| 28 |
+
elif prediction == 1:
|
| 29 |
+
return "Patient is DIABETIC"
|
| 30 |
+
|
| 31 |
+
outputs = gr.outputs.Textbox()
|
| 32 |
+
app = gr.Interface(fn=diabetes,
|
| 33 |
+
inputs=[gr.inputs.Slider(0,9,step=1,label= 'How many times has the patient been pregnant, 0 if unapplicable'),
|
| 34 |
+
'number',
|
| 35 |
+
'number',
|
| 36 |
+
'number',
|
| 37 |
+
'number',
|
| 38 |
+
'number',
|
| 39 |
+
gr.inputs.Slider(0,1,label= 'Diabetes Pedigree function'),
|
| 40 |
+
'number'],
|
| 41 |
+
outputs='text',
|
| 42 |
+
theme="grass",
|
| 43 |
+
title="kkk's Machine Learning App",
|
| 44 |
+
description="This is a diabetes model")
|
| 45 |
+
|
| 46 |
+
app.launch(inline = False)
|
| 47 |
+
|
| 48 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
huggingface-hub==0.5.1
|
| 2 |
+
numpy==1.21.6
|
| 3 |
+
torch
|
| 4 |
+
transformers==4.18.0
|
| 5 |
+
pandas==1.3.5
|
| 6 |
+
matplotlib==3.2.2
|
| 7 |
+
scikit-learn==1.0.2
|