a b/Tabs/predict.py
1
"""This modules contains data about prediction page"""
2
3
# Import necessary modules
4
import streamlit as st
5
6
# Import necessary functions from web_functions
7
from web_functions import predict
8
9
10
def app(df, X, y):
11
    """This function create the prediction page"""
12
13
    # Add title to the page
14
    st.title("Prediction Page")
15
16
    # Add a brief description
17
    st.markdown(
18
        """
19
            <p style="font-size:25px">
20
                This app uses <b style="color:green">Random Forest Classifier</b> for the Prediction of Parkinson's disease.
21
            </p>
22
        """, unsafe_allow_html=True)
23
    with st.expander("View attribute details"):
24
        st.markdown("""MDVP:Fo(Hz) - Average vocal fundamental frequency\n
25
MDVP:Fhi(Hz) - Maximum vocal fundamental frequency\n
26
MDVP:Flo(Hz) - Minimum vocal fundamental frequency\n
27
MDVP:Jitter(%),MDVP:Jitter(Abs),MDVP:RAP,MDVP:PPQ,Jitter:DDP - Several
28
measures of variation in fundamental frequency\n
29
MDVP:Shimmer,MDVP:Shimmer(dB),Shimmer:APQ3,Shimmer:APQ5,MDVP:APQ,Shimmer:DDA - Several measures of variation in amplitude\n
30
NHR,HNR - Two measures of ratio of noise to tonal components in the voice\n
31
status - Health status of the subject (one) - Parkinson's, (zero) - healthy\n
32
RPDE,D2 - Two nonlinear dynamical complexity measures\n
33
DFA - Signal fractal scaling exponent\n
34
spread1,spread2,PPE - Three nonlinear measures of fundamental frequency variation""")
35
    # Take feature input from the user
36
    # Add a subheader
37
    st.subheader("Select Values:")
38
39
    # Take input of features from the user.
40
    avff = st.slider("Average vocal fundamental frequency", int(df["AVFF"].min()), int(df["AVFF"].max()))
41
    mavff = st.slider("Maximum vocal fundamental frequency", int(df["MAVFF"].min()), int(df["MAVFF"].max()))
42
    mivff = st.slider("Minimum vocal fundamental frequency", int(df["MIVFF"].min()), int(df["MIVFF"].max()))
43
    jitddp = st.slider("Jitter:DDP", float(df["Jitter:DDP"].min()), float(df["Jitter:DDP"].max()))
44
    mdvpjit = st.slider("Multidimensional Voice Program:Jitter(%)", float(df["MDVP:Jitter(%)"].min()), float(df["MDVP:Jitter(%)"].max()))
45
    mdvprap = st.slider("MDVP:RAP", float(df["MDVP:RAP"].min()), float(df["MDVP:RAP"].max()))
46
    mdvpapq = st.slider("MDVP:APQ", float(df["MDVP:APQ"].min()), float(df["MDVP:APQ"].max()))
47
    mdvpppq = st.slider("MDVP:PPQ", float(df["MDVP:PPQ"].min()), float(df["MDVP:PPQ"].max()))
48
    mdvpshim = st.slider("MDVP:Shimmer", float(df["MDVP:Shimmer"].min()), float(df["MDVP:Shimmer"].max()))
49
    shimdda = st.slider("Shimmer:DDA", float(df["Shimmer:DDA"].min()), float(df["Shimmer:DDA"].max()))
50
    shimapq3 = st.slider("Shimmer:APQ3", float(df["Shimmer:APQ3"].min()), float(df["Shimmer:APQ3"].max()))
51
    shimapq5 = st.slider("Shimmer:APQ5", float(df["Shimmer:APQ5"].min()), float(df["Shimmer:APQ5"].max()))
52
    nhr = st.slider("NHR", float(df["NHR"].min()), float(df["NHR"].max()))
53
    hnr = st.slider("HNR", float(df["HNR"].min()), float(df["HNR"].max()))
54
    rpde = st.slider("RPDE", float(df["RPDE"].min()), float(df["RPDE"].max()))
55
    dfa = st.slider("DFA", float(df["DFA"].min()), float(df["DFA"].max()))
56
    d2 = st.slider("D2", float(df["D2"].min()), float(df["D2"].max()))
57
    ppe = st.slider("PPE", float(df["PPE"].min()), float(df["PPE"].max()))
58
59
    # Create a list to store all the features
60
    features = [avff, mavff, mivff, jitddp, mdvpjit, mdvprap,mdvpapq,mdvpppq,mdvpshim,shimdda,shimapq3,shimapq5,nhr,hnr,rpde,dfa,d2,ppe]
61
62
    # Create a button to predict
63
    if st.button("Predict"):
64
        # Get prediction and model score
65
        prediction, score = predict(X, y, features)
66
        st.success("Predicted Sucessfully")
67
68
        # Print the output according to the prediction
69
        if (prediction == 1):
70
            st.warning("The person either has Parkison's disease or prone to get Parkinson's disease")
71
        else:
72
            st.info("The person is safe from Parkinson's disease")
73
74
        # Print teh score of the model 
75
        st.write("The model used is trusted by doctor and has an accuracy of ", (score*100),"%")