Spaces:
Runtime error
Runtime error
AdithyaSNair
commited on
Commit
β’
b394f4b
1
Parent(s):
2032159
App and requirements
Browse files- app.py +108 -0
- requirements.txt +6 -0
app.py
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
""" Gradio PCOS Prediction .ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
The original file is located at
|
7 |
+
https://colab.research.google.com/drive/1W2dPPr1tHmTDgMgZML6C1Ch-4p_tOeZR
|
8 |
+
"""
|
9 |
+
|
10 |
+
import pandas as pd
|
11 |
+
import gradio as gr
|
12 |
+
import numpy as np
|
13 |
+
import seaborn as sns
|
14 |
+
import matplotlib.pyplot as plt
|
15 |
+
import sklearn
|
16 |
+
from sklearn import tree
|
17 |
+
from sklearn.linear_model import LinearRegression
|
18 |
+
from sklearn.linear_model import LogisticRegression
|
19 |
+
from sklearn.tree import DecisionTreeClassifier
|
20 |
+
from sklearn.preprocessing import scale
|
21 |
+
from sklearn.model_selection import train_test_split
|
22 |
+
from sklearn.metrics import confusion_matrix
|
23 |
+
from sklearn.preprocessing import StandardScaler
|
24 |
+
def main(Follicle_No_Right,Follicle_No_Left,Skin_darkening,Hair_growth,Weight_gain,Cycle):
|
25 |
+
url="https://raw.githubusercontent.com/Athulg19/datasets/main/PCOS_clean_data_without_infertility.csv"
|
26 |
+
data = pd.read_csv(url)
|
27 |
+
data=pd.DataFrame(data)
|
28 |
+
data=data.astype(np.float64)
|
29 |
+
data.dtypes
|
30 |
+
correlation=data.corrwith(data['PCOS (Y/N)']).abs().sort_values(ascending=False)
|
31 |
+
correlation=correlation[correlation>0.4].index
|
32 |
+
data=data[correlation]
|
33 |
+
arr=data.values
|
34 |
+
X=arr[:,1:6]
|
35 |
+
Y=arr[:,0]
|
36 |
+
scaler=StandardScaler().fit(X)
|
37 |
+
rescaledX=scaler.transform(X)
|
38 |
+
np.set_printoptions(precision=3)
|
39 |
+
y=data['PCOS (Y/N)']
|
40 |
+
x=data.drop(['PCOS (Y/N)'],axis=1)
|
41 |
+
X_train,X_test,y_train,y_test = train_test_split(x,y,test_size=.25)
|
42 |
+
logistic = LogisticRegression()
|
43 |
+
logistic.fit(X_train,y_train)
|
44 |
+
data = {'Follicle No. (R)':Follicle_No_Right,'Follicle No. (L)':Follicle_No_Left,'Skin darkening (Y/N)':Skin_darkening,'hair growth(Y/N)':Hair_growth,'Weight gain(Y/N)':Weight_gain,'Cycle(R/I)':Cycle}
|
45 |
+
index = [0]
|
46 |
+
cust_df = pd.DataFrame(data, index)
|
47 |
+
costpredLog = logistic.predict(cust_df)
|
48 |
+
if costpredLog ==0:
|
49 |
+
Prediction = "There is less chance for the patient to catch PCOS"
|
50 |
+
else:
|
51 |
+
Prediction = "There is more chance for the patient to catch PCOS."
|
52 |
+
return Prediction
|
53 |
+
|
54 |
+
iface = gr.Interface(fn = main,
|
55 |
+
|
56 |
+
inputs =['number','number','number','number','number','number'],
|
57 |
+
|
58 |
+
outputs =['text'],
|
59 |
+
|
60 |
+
title="Onset of PCOS prediction",
|
61 |
+
|
62 |
+
description =''' Description
|
63 |
+
|
64 |
+
Polycystic ovary syndrome (PCOS) is a problem with hormones that happens during the reproductive years. If you have PCOS, you may not have periods very often.
|
65 |
+
Or you may have periods that last many days. You may also have too much of a hormone called androgen in your body.
|
66 |
+
With PCOS, many small sacs of fluid develop along the outer edge of the ovary. These are called cysts. The small fluid-filled cysts contain immature eggs.
|
67 |
+
These are called follicles. The follicles fail to regularly release eggs.
|
68 |
+
The exact cause of PCOS is unknown. Early diagnosis and treatment along with weight loss may lower the risk of long-term complications such as type 2 diabetes and heart disease.
|
69 |
+
|
70 |
+
Output0 - Describes the Prediction made
|
71 |
+
|
72 |
+
|
73 |
+
More details about the Inputs taken and how they needed to be taken are given below:
|
74 |
+
|
75 |
+
Follicle_No_Right = Number of follicles is in Right Overy
|
76 |
+
Follicle_No_Left = Number of follicles is in Left Ovary
|
77 |
+
Skin_darkening = yes(1)/No(0)
|
78 |
+
Hair_growth = yes(1)/No(0)
|
79 |
+
Weight_gain = yes(1)/No(0)
|
80 |
+
Cycle = If it is Regular (0) or Irregular (1)
|
81 |
+
|
82 |
+
|
83 |
+
''',
|
84 |
+
article='''
|
85 |
+
Complications of PCOS can include:
|
86 |
+
|
87 |
+
* Infertility
|
88 |
+
|
89 |
+
* Gestational diabetes or pregnancy-induced high blood pressure
|
90 |
+
|
91 |
+
* Miscarriage or premature birth
|
92 |
+
|
93 |
+
* Nonalcoholic steatohepatitis β a severe liver inflammation caused by fat accumulation in the liver
|
94 |
+
|
95 |
+
* Metabolic syndrome β a cluster of conditions including high blood pressure,
|
96 |
+
high blood sugar, and abnormal cholesterol or triglyceride levels that significantly increase your risk of cardiovascular disease
|
97 |
+
|
98 |
+
* Type 2 diabetes or prediabetes
|
99 |
+
|
100 |
+
* Sleep apnea
|
101 |
+
|
102 |
+
* Depression, anxiety and eating disorders
|
103 |
+
|
104 |
+
* Abnormal uterine bleeding
|
105 |
+
|
106 |
+
* Cancer of the uterine lining (endometrial cancer)''')
|
107 |
+
|
108 |
+
iface.launch(debug =True)
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
numpy
|
3 |
+
pandas
|
4 |
+
matplotlib
|
5 |
+
scikit-learn
|
6 |
+
seaborn
|