File size: 6,694 Bytes
c1b7912
 
 
 
5ae31d0
c1b7912
 
 
 
 
 
 
 
528ba8e
 
 
c1b7912
 
898d3b4
 
ea239aa
eaaff34
898d3b4
eaaff34
898d3b4
b9cc840
898d3b4
c1b7912
 
 
aa80b2d
c1b7912
2ee6b24
 
 
 
 
 
 
 
 
 
528ba8e
2ee6b24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7790674
a8f16fe
 
 
 
 
 
 
 
 
1b3286d
db87ad5
c1b7912
 
0d68274
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import pickle
import gradio as gr

# Load the pickled model
with open('./RF.pickle', 'rb') as file:
    model = pickle.load(file)

# Define the function for making predictions
def cerviccancer(Age, Num_sexual_partners, First_sexual_intercourse, Num_pregnancies, Smokes, Smokes_years, Smokes_packs_year, 
                 Hormonal_Contraceptives, Hormonal_Contraceptives_years, IUD, IUD_years, STDs, STDs_condylomatosis, STDs_cervical_condylomatosis, 
                 STDs_vaginal_condylomatosis, STDs_vulvoperineal_condylomatosis, STDs_syphilis, STDs_pelvic_inflammatory_disease, STDs_genital_herpes, 
                 STDs_molluscum_contagiosum, STDs_AIDS, STDs_HIV, STDs_Hepatitis_B, STDs_HPV, STDs_Num_of_diagnosis, Dx_Cancer, Dx_CIN, Dx, Hinselmann, Schiller, Citology):
    inputs = [[Age, Num_sexual_partners, First_sexual_intercourse, Num_pregnancies, Smokes, Smokes_years, Smokes_packs_year, 
                 Hormonal_Contraceptives, Hormonal_Contraceptives_years, IUD, IUD_years, STDs, STDs_condylomatosis, STDs_cervical_condylomatosis, 
                 STDs_vaginal_condylomatosis, STDs_vulvoperineal_condylomatosis, STDs_syphilis, STDs_pelvic_inflammatory_disease, STDs_genital_herpes, 
                 STDs_molluscum_contagiosum, STDs_AIDS, STDs_HIV, STDs_Hepatitis_B, STDs_HPV, STDs_Num_of_diagnosis, Dx_Cancer, Dx_CIN, Dx, Hinselmann, Schiller, Citology]]
    prediction = model.predict(inputs)
    prediction_value = prediction[0]
   
    # Categorize prediction_value
    if prediction_value == 0:
        result = "Biopsy Not Needed 🟢"
    else:
        result = "Biopsy Needed 🔴"
                         
    return f"Biopsy Prediction: {prediction_value} \n\nResult: {result}"



# Create the Gradio interface
cerviccancer_ga = gr.Interface(fn=cerviccancer, 
                               inputs = [
                                            gr.Number(13.0, 84.0, label="Age: [13 to 84]"),
                                            gr.Number(1.0, 28.0, label="Number of sexual partners: [1 to 28]"),
                                            gr.Number(10.0, 32.0, label="First sexual intercourse: [10 to 32]"),
                                            gr.Number(0.0, 11.0, label="Num of pregnancies: [0 to 11]"),
                                            gr.Number(0.0, 1.0, label="Smokes: [0 or 1]"),
                                            gr.Number(0.0, 37.0, label="Smokes (years): [0 to 37]"),
                                            gr.Number(0.0, 37.0, label="Smokes (packs/year): [0 to 37]"),
                                            gr.Number(0.0, 1.0, label="Hormonal Contraceptives: [0 or 1]"),
                                            gr.Number(0.0, 30.0, label="Hormonal Contraceptives (years): [0 to 30]"),
                                            gr.Number(0.0, 1.0, label="IUD: [0 or 1]"),
                                            gr.Number(0.0, 19.0, label="IUD (years): [0.0  19.0]"),
                                            gr.Number(0.0, 1.0, label="STDs: [0 or 1]"),
                                            gr.Number(0.0, 1.0, label="STDs:condylomatosis: [0 or 1]"),
                                            gr.Number(0.0, 0.0, label="STDs:cervical condylomatosis: [0]"),
                                            gr.Number(0.0, 1.0, label="STDs:vaginal condylomatosis: [0 or 1]"),
                                            gr.Number(0.0, 1.0, label="STDs:vulvo-perineal condylomatosis: [0 or 1]"),
                                            gr.Number(0.0, 1.0, label="STDs:syphilis: [0 or 1]"),
                                            gr.Number(0.0, 1.0, label="STDs:pelvic inflammatory disease: [0 or 1]"),
                                            gr.Number(0.0, 1.0, label="STDs:genital herpes: [0 or 1]"),
                                            gr.Number(0.0, 1.0, label="STDs:molluscum contagiosum: [0 or 1]"),
                                            gr.Number(0.0, 0.0, label="STDs:AIDS: [0]"),
                                            gr.Number(0.0, 1.0, label="STDs:HIV: [0 or 1]"),
                                            gr.Number(0.0, 1.0, label="STDs:Hepatitis B: [0 or 1]"),
                                            gr.Number(0.0, 1.0, label="STDs:HPV: [0 or 1]"),
                                            gr.Number(0.0, 3.0, label="STDs: Number of diagnosis: [0 to 3]"),
                                            gr.Number(0.0, 1.0, label="Dx:Cancer: [0 or 1]"),
                                            gr.Number(0.0, 1.0, label="Dx:CIN: [0 or 1]"),
                                            gr.Number(0.0, 1.0, label="Dx: [0 or 1]"),
                                            gr.Number(0.0, 1.0, label="Hinselmann: [0 or 1]"),
                                            gr.Number(0.0, 1.0, label="Schiller: [0 or 1]"),
                                            gr.Number(0.0, 1.0, label="Citology: [0 or 1]")
                                          ],
                                outputs="text", title="Cervical Cancer Risk Prediction", 
                               examples = [
                                            [33, 2, 24, 2, 0, 0, 0, 1, 0.08, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                            [29, 2, 20, 1, 0, 0, 0, 1, 0.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                            [21, 1, 17, 2.2, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
                                            [33, 3, 18, 2, 0.14, 1.21, 0.45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
                                            [20, 3, 17, 2, 0, 0, 0, 1, 0.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
                                            [30, 1, 17, 3, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0]
                                        ],
                                description="Predicting probability of Biopsy Using Machine Learning.\n\n Associated Data: \n\nData of Cervical cancer Availability Statement: dataset was obtained from the open-access Cervical cancer (Risk Factors) Data Set database of Cervical Cancer Risk Factors for Biopsy and are available at https://archive.ics.uci.edu/ml/datasets/Cervical+cancer+%28Risk+Factors%29 (accessed on 24 March 2022).\n\nDeveloped by: Parthebhan Pari \n\n Last updated on: Apl 2024",
                                theme='dark'
                               )

cerviccancer_ga.launch(share=True,debug=True)