Spaces:
Runtime error
Runtime error
Commit ·
7d564bf
1
Parent(s): 85dfb8e
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,57 +0,0 @@
|
|
| 1 |
-
# -*- coding: utf-8 -*-
|
| 2 |
-
"""app.ipynb
|
| 3 |
-
|
| 4 |
-
Automatically generated by Colaboratory.
|
| 5 |
-
|
| 6 |
-
Original file is located at
|
| 7 |
-
https://colab.research.google.com/drive/1HGxLfdQXQt3h4I7aoSTmLSGxPaqhdJbe
|
| 8 |
-
"""
|
| 9 |
-
|
| 10 |
-
!pip install gradio
|
| 11 |
-
|
| 12 |
-
import gradio as gr
|
| 13 |
-
import numpy as np
|
| 14 |
-
import pandas as pd
|
| 15 |
-
from sklearn.preprocessing import StandardScaler
|
| 16 |
-
from sklearn.model_selection import train_test_split
|
| 17 |
-
from sklearn import svm
|
| 18 |
-
from sklearn.metrics import accuracy_score
|
| 19 |
-
salim_diabetes_dataset = pd.read_csv('diabetes.csv')
|
| 20 |
-
X = salim_diabetes_dataset.drop(columns = 'Outcome', axis=1)
|
| 21 |
-
Y = salim_diabetes_dataset['Outcome']
|
| 22 |
-
scaler = StandardScaler()
|
| 23 |
-
scaler.fit(X)
|
| 24 |
-
standardized_data = scaler.transform(X)
|
| 25 |
-
print(standardized_data)
|
| 26 |
-
X = standardized_data
|
| 27 |
-
Y = salim_diabetes_dataset['Outcome']
|
| 28 |
-
from sklearn.neural_network import MLPClassifier
|
| 29 |
-
classifier = MLPClassifier(max_iter=1000, alpha=1)
|
| 30 |
-
X_train, X_test, Y_train, Y_test = train_test_split(X,Y, test_size = 0.2, stratify=Y, random_state=2)
|
| 31 |
-
classifier.fit(X_train, Y_train)
|
| 32 |
-
|
| 33 |
-
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):
|
| 34 |
-
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])
|
| 35 |
-
prediction = classifier.predict(x.reshape(1, -1))
|
| 36 |
-
if prediction == 0:
|
| 37 |
-
return "Patient is NOT DIABETIC"
|
| 38 |
-
elif prediction == 1:
|
| 39 |
-
return "Patient is DIABETIC"
|
| 40 |
-
|
| 41 |
-
outputs = gr.outputs.Textbox()
|
| 42 |
-
app = gr.Interface(fn=diabetes,
|
| 43 |
-
inputs=[gr.inputs.Slider(0,9,step=1,label= 'How many months pregnant is the patient, 0 if unapplicable'),
|
| 44 |
-
'number',
|
| 45 |
-
'number',
|
| 46 |
-
'number',
|
| 47 |
-
'number',
|
| 48 |
-
'number',
|
| 49 |
-
gr.inputs.Slider(0,1,label= 'Diabetes Pedigree function'),
|
| 50 |
-
'number'],
|
| 51 |
-
outputs='text',
|
| 52 |
-
theme="grass",
|
| 53 |
-
title="Salim's Machine Learning App",
|
| 54 |
-
description="This is a diabetes model")
|
| 55 |
-
|
| 56 |
-
app.launch(share = True)
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|