Exemple #1
0
        '''))
  
import plotly_express as px

configure_plotly_browser_state()
px.scatter(df_prop, x="GROSS SQUARE FEET", y="SALE PRICE", size ="TOTAL UNITS" ,color="borough_name",
           hover_data=["BUILDING CLASS CATEGORY","LOT"], log_x=True, size_max=60)

"""**Observation:**

- Properties with more total units do not fetch larger sales price
Properties in Staten Island have comparitively lesser sales price in comparison with other boroughs in New york city
"""

configure_plotly_browser_state()
px.box(df_prop, x="borough_name", y="SALE PRICE", color="TAX CLASS AT TIME OF SALE",hover_data=['NEIGHBORHOOD', 'BUILDING CLASS CATEGORY'],notched=True)

"""**Observation:**

- Manhatten has the highest priced properties that have a tax class 1 representing residential property of up to three units (such as one-,two-, and three-family homes and small stores or offices with one or two attached apartments) as compared to other boroughs.
- Properties in Staten Island have comparitively lesser sales price in comparison with other boroughs in New york city
"""

configure_plotly_browser_state()
px.box(df_prop, x="SALE PRICE", notched=True, hover_data=['borough_name'], orientation='h')

configure_plotly_browser_state()
px.box(df_prop, x="day_week", y="SALE PRICE", color="TAX CLASS AT TIME OF SALE", notched=True)

"""**Observation:**
Exemple #2
0
        x='cnt',
        orientation='h',
        title='Most Common Team - Player Pairings')
    fig.update_yaxes(title='Count')
    fig.update_xaxes(title='Team & Player Pairing',
                     categoryorder='category ascending')
    fig.update_yaxes(autorange="reversed")
    st.plotly_chart(fig, use_container_width=True)

with streamlit_analytics.track(unsafe_password="******"):
    fig = px.box(d2.loc[d2.player.isin(
        d2.groupby('player').agg({
            'pick': 'size'
        }).reset_index().sort_values('pick',
                                     ascending=False).head(25)['player'])],
                 x="player",
                 y="pick",
                 points="all",
                 hover_data=['team', 'date', 'source'],
                 title='Distribution of Draft Position by Player',
                 width=1600)
    fig.update_xaxes(title='Player')
    fig.update_yaxes(title='Draft Position')
    st.plotly_chart(fig, use_container_width=True)

with streamlit_analytics.track(unsafe_password="******"):
    d = d2.groupby(['team', 'team_img', 'player']).agg({
        'pick': ['min', 'mean', 'median', 'size']
    }).reset_index()
    d.columns = [
        'team', 'team_img', 'player', 'min_pick', 'avg_pick', 'median_pick',
Exemple #3
0
        y_values = st.sidebar.selectbox('Y axis', options=numeric_columns)
        color_value = st.sidebar.selectbox("Color", options=non_numeric_columns)
        plot = px.line(data_frame=df, x=x_values, y=y_values, color=color_value)
        st.plotly_chart(plot)
    except Exception as e:
        print(e)

if chart_select == 'Histogram':
    st.sidebar.subheader("Histogram Settings")
    try:
        x = st.sidebar.selectbox('Feature', options=numeric_columns)
        bin_size = st.sidebar.slider("Number of Bins", min_value=10,
                                     max_value=100, value=40)
        color_value = st.sidebar.selectbox("Color", options=non_numeric_columns)
        plot = px.histogram(x=x, data_frame=df, color=color_value)
        st.plotly_chart(plot)
    except Exception as e:
        print(e)

if chart_select == 'Boxplot':
    st.sidebar.subheader("Boxplot Settings")
    try:
        y = st.sidebar.selectbox("Y axis", options=numeric_columns)
        x = st.sidebar.selectbox("X axis", options=non_numeric_columns)
        color_value = st.sidebar.selectbox("Color", options=non_numeric_columns)
        plot = px.box(data_frame=df, y=y, x=x, color=color_value)
        st.plotly_chart(plot)
    except Exception as e:
        print(e)     
        st.balloons()   
Exemple #4
0
def main():
    st.title("Predict Salary")
    gender = st.text_input("Gender: M/F")
    ssc_p = float(st.number_input("SSC percentile"))
    ssc_b = st.text_input("SSC B:Central/Others")
    hsc_p = float(st.number_input("HSC percentile"))
    hsc_b = st.text_input("HSC B: Central/Others")
    hsc_s = st.text_input("HSC S: Commerce/Science/Arts")
    degree_p = float(st.number_input("Degree percentile"))
    degree_t = st.text_input("Degree T: Sci&Tech/Comm&Mgmt/Others")
    workex = st.text_input("Workex: Yes/No")
    etest_p = float(st.number_input("E-test percentile"))
    special = st.text_input("Special: Mkt&Fin/Mkt&HR")
    mba_p = float(st.number_input("MBA percentile"))
    status = st.text_input("Status: Placed/Not Placed")

    if st.button("Predict Salary"):
        output = func2(gender, ssc_p, ssc_b, hsc_p, hsc_b, hsc_s, degree_p,
                       degree_t, workex, etest_p, special, mba_p, status)
        st.success('Estimated salary: {}'.format(output))
    if st.button("Placed or Not"):
        output = func1(gender, ssc_p, ssc_b, hsc_p, hsc_b, hsc_s, degree_p,
                       degree_t, workex, etest_p, special, mba_p)
        st.success('Prediction {}'.format(output))
    agree = st.checkbox("Hide Graphs")
    if (not agree):
        st.sidebar.subheader("Visualization Settings")
        try:
            st.write(df)
            numeric_columns = list(df.select_dtypes(['float', 'int']).columns)

            non_numeric_columns = list(df.select_dtypes(['object']).columns)

            non_numeric_columns.append(None)
            print(numeric_columns)
        except Exception as e:
            print(e)
            st.write("Please upload file to the application.")
        # add a select widget to the side bar
        chart_select = st.sidebar.selectbox(
            label="Select the chart type",
            options=['Histogram', 'Lineplots', 'Scatterplots', 'Boxplot'])

        if chart_select == 'Scatterplots':
            st.sidebar.subheader("Scatterplot Settings")
            try:
                x_values = st.sidebar.selectbox('X axis',
                                                options=numeric_columns)
                y_values = st.sidebar.selectbox('Y axis',
                                                options=numeric_columns)
                color_value = st.sidebar.selectbox("Color",
                                                   options=non_numeric_columns)
                plot = px.scatter(data_frame=df,
                                  x=x_values,
                                  y=y_values,
                                  color=color_value)
                # display the chart
                st.plotly_chart(plot)
            except Exception as e:
                print(e)

        if chart_select == 'Lineplots':
            st.sidebar.subheader("Line Plot Settings")
            try:
                x_values = st.sidebar.selectbox('X axis',
                                                options=numeric_columns)
                y_values = st.sidebar.selectbox('Y axis',
                                                options=numeric_columns)
                color_value = st.sidebar.selectbox("Color",
                                                   options=non_numeric_columns)
                plot = px.line(data_frame=df,
                               x=x_values,
                               y=y_values,
                               color=color_value)
                st.plotly_chart(plot)
            except Exception as e:
                print(e)

        if chart_select == 'Histogram':
            st.sidebar.subheader("Histogram Settings")
            try:
                x = st.sidebar.selectbox('Feature', options=numeric_columns)
                bin_size = st.sidebar.slider("Number of Bins",
                                             min_value=10,
                                             max_value=100,
                                             value=40)
                color_value = st.sidebar.selectbox("Color",
                                                   options=non_numeric_columns)
                plot = px.histogram(x=x, data_frame=df, color=color_value)
                st.plotly_chart(plot)
            except Exception as e:
                print(e)

        if chart_select == 'Boxplot':
            st.sidebar.subheader("Boxplot Settings")
            try:
                y = st.sidebar.selectbox("Y axis", options=numeric_columns)
                x = st.sidebar.selectbox("X axis", options=non_numeric_columns)
                color_value = st.sidebar.selectbox("Color",
                                                   options=non_numeric_columns)
                plot = px.box(data_frame=df, y=y, x=x, color=color_value)
                st.plotly_chart(plot)
            except Exception as e:
                print(e)
Exemple #5
0
                                         }] + [{
                                             'if': {
                                                 'column_id': 'City',
                                             },
                                             'width': '120px'
                                         }],
                 style_header={'backgroundColor': '#F8F7F4'},
                 filtering=True,
             ), ),
         html.Div(
             dcc.Graph(figure=px.box(
                 tmp,
                 x="amount",
                 y="Weekday",
                 orientation="h",
                 notched=True,
                 category_orders={
                     "Weekday": [
                         "Friday", "Saturday", "Sunday", "Monday",
                         "Tuesday", "Wednesday", "Thursday"
                     ]
                 }))),
         html.Div(
             dcc.Graph(figure=px.area(
                 tmp, x="Date", y="amount", color="Category")))
     ],
     className="two column",
     style={
         'width': '100%',
         'backgroundColor': 'blue'
     },
 ),
# In[196]:

px.bar(data_frame=gapminder[gapminder.year == 2007], x='country', y='pop')

# ### Histogram

# In[197]:

px.histogram(data_frame=gapminder, x='pop')

# ### Box plot - Normal

# In[198]:

px.box(data_frame=gapminder, y='lifeExp')

# ### Box Plot - Colored / Grouped

# In[199]:

px.box(data_frame=gapminder, y='lifeExp', color='continent')

# ### Violin plot

# In[200]:

px.violin(data_frame=gapminder, y='lifeExp', color='continent', box=True)

# ### Line Graph
def update_graph(option_slctd):
    print(option_slctd)
    print(type(option_slctd))

    container = "The type of data choosen. by user was: {}".format(
        option_slctd)

    dff1 = df1.copy()
    dff1 = dff1[dff1["type"] == option_slctd]

    dff2 = df2.copy()
    dff2 = dff2[dff2["type"] == option_slctd]

    dff3 = df3.copy()
    dff3 = dff3[dff3["type"] == option_slctd]

    dff4 = df4.copy()
    dff4 = dff4[dff4["type"] == option_slctd]

    dff5 = df5.copy()
    dff5 = dff5[dff5["type"] == option_slctd]

    dff6 = df6.copy()
    dff6 = dff6[dff6["type"] == option_slctd]

    dfs = {
        "0033C822": dff1,
        "0034C8DF": dff2,
        "0034C74E": dff3,
        "0034C91E": dff4,
        "0034C559": dff5,
        "0034C864": dff6
    }

    data = [["0033C822",
             dff1["value"].max()], ["0034C8DF", dff2["value"].max()],
            ["0034C74E",
             dff3["value"].max()], ["0034C91E", dff4["value"].max()],
            ["0034C559", dff5["value"].max()],
            ["0034C864", dff6["value"].max()]]

    df = pd.DataFrame(data, columns=['device', 'value'])

    features = ["CO2", "humidity", "temperature"]
    # Plotly Express
    fig1 = go.Figure()
    fig2 = px.box(dff1, y="value")
    fig3 = px.bar(df, x="device", y="value")
    fig4 = px.scatter(dff1[6:132], x="timestamp", y="value")
    fig5 = px.scatter_3d(gdf6[:10],
                         x='CO2',
                         y='temperature',
                         z='humidity',
                         color='timestamp')
    fig6 = px.parallel_coordinates(
        gdf5[:50],
        color="CO2",
        labels={
            "CO2": "CO2",
            "humidity": "Humidity",
            "temperature": "Temperature",
        },
        color_continuous_scale=px.colors.diverging.Tealrose,
        color_continuous_midpoint=2)
    fig7 = px.scatter_matrix(gdf6, dimensions=features, color="CO2")
    fig7.update_traces(diagonal_visible=False)

    for i in dfs:
        fig1.add_trace(
            go.Scatter(x=dfs[i]["timestamp"], y=dfs[i]["value"], name=i))

    return container, fig1, fig2, fig3, fig4, fig5, fig6, fig7
Exemple #8
0
# %% timeseries
st.subheader('Timeseries')
df_preprocessed['datetime'] = pd.to_datetime(df_preprocessed['datetime'])
fig2 = px.line(df_preprocessed, x='datetime', y='temp')
ts_chart = st.plotly_chart(fig2)

# %% boxplots
st.subheader('Boxplots')
categories_count = ['casual', 'registered', 'count']
chosen_count = st.sidebar.selectbox('Which counts for boxplots?',
                                    categories_count)

fig3 = px.box(df_preprocessed,
              x='weekday',
              y=chosen_count,
              color='season',
              notched=True)
boxplot_chart = st.plotly_chart(fig3)

st.title('Modelization')

# %% Modelization
X = df_preprocessed[['temp', 'humidity']]
y = df_preprocessed['count']
model_rf = RandomForestRegressor(max_depth=2, n_estimators=10)
model_rf.fit(X, y)

# %% Online timeseries

Exemple #9
0
def main():
    st.title("Infographs")

    html_temp = """
    <div style="background-color:Red;padding:10px">
    <h1 style="color:orange;text-align:center;"><em>Infographs</em> </h1>
    </div>
    <br></br>
    """

    offer = ('Offer-Type-1', 'Offer-Type-2', 'Offer-Type-3', 'Offer-Type-4',
             'Offer-Type-5', 'Offer-Type-6', 'Offer-Type-7', 'Offer-Type-8',
             'Offer-Type-9', 'Offer-Type-10')
    option_offer = list(range(len(offer)))
    offer_type = st.selectbox("Offer_type",
                              option_offer,
                              format_func=lambda x: offer[x])
    offer_type = offer_type + 1
    gender_box = ('M', 'F', 'O')
    gender = st.selectbox("Gender", options=list(gender_box))
    days_of_membership = st.number_input("Days Of Memebership")
    total_amount = st.number_input("Amount(Bill of the customer)")
    year = st.number_input("year")
    age_in_range = st.slider("Age", 0, 100)
    age_in_range = str(age_in_range) + "s"
    income_in_range = st.text_input("Income Of The Customer")
    result = ""
    if st.button("Predict"):
        result = membership_predict(offer_type, gender, days_of_membership,
                                    total_amount, year, age_in_range,
                                    income_in_range)
        if (result == 1):
            st.success("The Customer Will Take Member Ship")
        elif (result == 0):
            st.warning("He wont Take")
    agree = st.checkbox("Hide Graphs")
    if (not agree):
        st.sidebar.subheader("Visualization Settings")
        try:
            st.write(df)
            # numeric_columns = list(df.select_dtypes(['float', 'int']).columns)
            numeric_columns = list(
                ['income', 'total_amount', 'days_of_membership'])

            non_numeric_columns = list(df.select_dtypes(['object']).columns)

            non_numeric_columns.append(None)
            print(numeric_columns)
        except Exception as e:
            print(e)
            st.write("Please upload file to the application.")
        # add a select widget to the side bar
        chart_select = st.sidebar.selectbox(
            label="Select the chart type",
            options=['Histogram', 'Lineplots', 'Scatterplots', 'Boxplot'])

        if chart_select == 'Scatterplots':
            st.sidebar.subheader("Scatterplot Settings")
            try:
                x_values = st.sidebar.selectbox('X axis',
                                                options=numeric_columns)
                y_values = st.sidebar.selectbox('Y axis',
                                                options=numeric_columns)
                color_value = st.sidebar.selectbox("Color",
                                                   options=non_numeric_columns)
                plot = px.scatter(data_frame=df,
                                  x=x_values,
                                  y=y_values,
                                  color=color_value)
                # display the chart
                st.plotly_chart(plot)
            except Exception as e:
                print(e)

        if chart_select == 'Lineplots':
            st.sidebar.subheader("Line Plot Settings")
            try:
                x_values = st.sidebar.selectbox('X axis',
                                                options=numeric_columns)
                y_values = st.sidebar.selectbox('Y axis',
                                                options=numeric_columns)
                color_value = st.sidebar.selectbox("Color",
                                                   options=non_numeric_columns)
                plot = px.line(data_frame=df,
                               x=x_values,
                               y=y_values,
                               color=color_value)
                st.plotly_chart(plot)
            except Exception as e:
                print(e)

        if chart_select == 'Histogram':
            st.sidebar.subheader("Histogram Settings")
            try:
                x = st.sidebar.selectbox('Feature', options=numeric_columns)
                bin_size = st.sidebar.slider("Number of Bins",
                                             min_value=10,
                                             max_value=100,
                                             value=40)
                color_value = st.sidebar.selectbox("Color",
                                                   options=non_numeric_columns)
                plot = px.histogram(x=x, data_frame=df, color=color_value)
                st.plotly_chart(plot)
            except Exception as e:
                print(e)

        if chart_select == 'Boxplot':
            st.sidebar.subheader("Boxplot Settings")
            try:
                y = st.sidebar.selectbox("Y axis", options=numeric_columns)
                x = st.sidebar.selectbox("X axis", options=non_numeric_columns)
                color_value = st.sidebar.selectbox("Color",
                                                   options=non_numeric_columns)
                plot = px.box(data_frame=df, y=y, x=x, color=color_value)
                st.plotly_chart(plot)
            except Exception as e:
                print(e)
# Relation between Student and default

pd.crosstab(df_credit['default'], df_credit['student'], rownames=['Default'], colnames=['Student'])

# Correlation between selected variables
plt.figure(figsize=(5,5))
c = df_credit.corr()
sns.heatmap(c,cmap="BrBG",annot=True)

"""**Observation:**
- The heat map illustrates that income and balance are negatively correlated.
"""

# Explore how often a student defaults
configure_plotly_browser_state()
px.box(df_credit, x="default", y="income", color="student",hover_data=['balance'],notched=True)

"""**Observation:**

- Student defaulters are lesser as compared to others

# Model Building
"""

#Select the variables to be one-hot encoded
one_hot_features = ['student', 'default']
# Convert categorical variables into dummy/indicator variables (i.e. one-hot encoding).
one_hot_encoded = pd.get_dummies(df_credit[one_hot_features],drop_first=True)
one_hot_encoded.info(verbose=True, memory_usage=True, null_counts=True)

# Convert Categorical to Numerical for default column
Exemple #11
0
def main():
    activities = [
        'EDA', 'Visualization', 'Regression', 'Classification',
        'Documentation', 'About Us'
    ]
    st.sidebar.success('Updates Coming Soon! 🌟🎉')
    option = st.sidebar.selectbox('Choose a section', activities)
    st.sidebar.markdown(
        '''Use this section for finding useful insights about your data,and feel free to use them in your notebooks
                                             
    🎯   Version : 1.0.1  ''')

    if option == 'EDA':
        st.subheader("Explanatory Data Analysis")

        data = st.file_uploader("Please upload a CSV dataset ", type=['csv'])

        st.warning('Your dataset goes here...')
        if data is not None:
            df = pd.read_csv(data)
            st.dataframe(df)
            st.info('Some useful data insights about your data')
            if st.checkbox("Display shape"):
                r, c = df.shape
                st.write('Rows = ', r, 'Columns = ', c)

            if st.checkbox('Display columns'):
                st.write(df.columns)

            if st.checkbox('Select multiple columns'):
                selected_col = st.multiselect('Select preferred columns',
                                              df.columns)
                df1 = df[selected_col]
                st.dataframe(df1)

            if st.checkbox("Head"):
                st.write(df.head())

            if st.checkbox('Tail'):
                st.write(df.tail())

            if st.checkbox('Null values'):
                st.write(df.isnull().sum())

            if st.checkbox('Data types'):
                st.write(df.dtypes)

            if st.checkbox('Random sample'):
                st.write(df.sample(20))

            if st.checkbox('Display correlations'):
                st.write(df.corr())

            if st.checkbox('Summary'):
                st.write(df.describe(include='all').T)

    elif option == 'Visualization':
        st.subheader("Data Visualization and Graphing")

        st.sidebar.subheader("File Upload")

        # Setup file upload
        uploaded_file = st.sidebar.file_uploader(
            label="Upload your CSV file. (200MB max)", type=['csv'])

        if uploaded_file is not None:
            st.success('Your data goes here')

        try:
            df = pd.read_csv(uploaded_file)
        except Exception as e:
            st.warning('Data not found')

        global numeric_columns
        global non_numeric_columns
        try:
            st.write(df)
            numeric_columns = list(df.select_dtypes(['float', 'int']).columns)
            non_numeric_columns = list(df.select_dtypes(['object']).columns)
            non_numeric_columns.append(None)
            print(non_numeric_columns)
        except Exception as e:
            print(e)

        chart_select = st.sidebar.selectbox(label="Select the chart type",
                                            options=[
                                                'Scatterplots', 'Lineplots',
                                                'Histogram', 'Boxplot',
                                                'Violinplot', 'Piechart'
                                            ])

        st.info('The Graphs generated will be displayed here')

        if chart_select == 'Scatterplots':
            st.sidebar.subheader("Scatterplot Settings")
            try:
                x_values = st.sidebar.selectbox('X axis',
                                                options=numeric_columns)
                y_values = st.sidebar.selectbox('Y axis',
                                                options=numeric_columns)
                color_value = st.sidebar.selectbox("Color",
                                                   options=non_numeric_columns)
                plot = px.scatter(data_frame=df,
                                  x=x_values,
                                  y=y_values,
                                  color=color_value)
                # display the chart
                st.plotly_chart(plot)
            except Exception as e:
                print(e)

        if chart_select == 'Lineplots':
            st.sidebar.subheader("Line Plot Settings")
            try:
                x_values = st.sidebar.selectbox('X axis',
                                                options=numeric_columns)
                y_values = st.sidebar.selectbox('Y axis',
                                                options=numeric_columns)
                color_value = st.sidebar.selectbox("Color",
                                                   options=non_numeric_columns)
                plot = px.line(data_frame=df,
                               x=x_values,
                               y=y_values,
                               color=color_value)
                st.plotly_chart(plot)
            except Exception as e:
                print(e)

        if chart_select == 'Histogram':
            st.sidebar.subheader("Histogram Settings")
            try:
                x = st.sidebar.selectbox('Feature', options=numeric_columns)
                bin_size = st.sidebar.slider("Number of Bins",
                                             min_value=10,
                                             max_value=100,
                                             value=40)
                color_value = st.sidebar.selectbox("Color",
                                                   options=non_numeric_columns)
                plot = px.histogram(x=x, data_frame=df, color=color_value)
                st.plotly_chart(plot)
            except Exception as e:
                print(e)

        if chart_select == 'Boxplot':
            st.sidebar.subheader("Boxplot Settings")
            try:
                y = st.sidebar.selectbox("Y axis", options=numeric_columns)
                x = st.sidebar.selectbox("X axis", options=non_numeric_columns)
                color_value = st.sidebar.selectbox("Color",
                                                   options=non_numeric_columns)
                plot = px.box(data_frame=df, y=y, x=x, color=color_value)
                st.plotly_chart(plot)
            except Exception as e:
                print(e)

        if chart_select == 'Piechart':
            st.sidebar.subheader("Piechart Settings")
            try:
                x_values = st.sidebar.selectbox('X axis',
                                                options=numeric_columns)
                y_values = st.sidebar.selectbox('Y axis',
                                                options=non_numeric_columns)
                plot = px.pie(data_frame=df, values=x_values, names=y_values)
                st.plotly_chart(plot)

            except Exception as e:
                print(e)

        if chart_select == 'Violinplot':
            st.sidebar.subheader("Violin Plot Settings")
            try:
                x_values = st.sidebar.selectbox('X axis',
                                                options=numeric_columns)
                y_values = st.sidebar.selectbox('Y axis',
                                                options=numeric_columns)
                color_value = st.sidebar.selectbox("Color",
                                                   options=non_numeric_columns)
                plot = px.violin(data_frame=df,
                                 x=x_values,
                                 y=y_values,
                                 color=color_value)
                st.plotly_chart(plot)
            except Exception as e:
                print(e)

    elif option == 'Regression':
        st.subheader("Regression ML Model Builder")

        # Model building
        def build_model(df):
            l = len(df)

            #df = df.iloc[:100]
            X = df.iloc[:, :
                        -1]  # Using all column except for the last column as X
            Y = df.iloc[:, -1]  # Selecting the last column as Y

            st.markdown('**1.2. Dataset dimension**')
            st.write('X (Independent Axis)')
            st.info(X.shape)
            st.write('Y (Dependent Axis)')
            st.info(Y.shape)

            st.markdown('**1.3. Variable details**:')
            st.write('X variable (first few are shown)')
            st.info(list(X.columns[:int(l / 5)]))
            st.write('Y variable')
            st.info(Y.name)

            # Build lazy model
            X_train, X_test, Y_train, Y_test = train_test_split(
                X, Y, test_size=split_size, random_state=seed_number)
            reg = LazyRegressor(verbose=0,
                                ignore_warnings=False,
                                custom_metric=None)
            models_train, predictions_train = reg.fit(X_train, X_train,
                                                      Y_train, Y_train)
            models_test, predictions_test = reg.fit(X_train, X_test, Y_train,
                                                    Y_test)

            st.subheader('2.Model Performance Plot (Training Set)')

            st.write('Training set')
            st.write(predictions_train)
            st.markdown(filedownload(predictions_train, 'training.csv'),
                        unsafe_allow_html=True)

            st.write('Test set')
            st.write(predictions_test)
            st.markdown(filedownload(predictions_test, 'test.csv'),
                        unsafe_allow_html=True)

            st.subheader('3.Model Performance Plot(Test set)')

            with st.markdown('**R-squared**'):
                # Tall
                predictions_test["R-Squared"] = [
                    0 if i < 0 else i for i in predictions_test["R-Squared"]
                ]
                plt.figure(figsize=(3, 9))
                sns.set_theme(style="darkgrid")
                ax1 = sns.barplot(y=predictions_test.index,
                                  x="R-Squared",
                                  data=predictions_test)
                ax1.set(xlim=(0, 1))
            st.markdown(imagedownload(plt, 'plot-r2-tall.pdf'),
                        unsafe_allow_html=True)
            # Wide
            plt.figure(figsize=(12, 3))
            sns.set_theme(style="darkgrid")
            ax1 = sns.barplot(x=predictions_test.index,
                              y="R-Squared",
                              data=predictions_test)
            ax1.set(ylim=(0, 1))
            plt.xticks(rotation=90)
            st.pyplot(plt)
            st.markdown(imagedownload(plt, 'plot-r2-wide.pdf'),
                        unsafe_allow_html=True)

            with st.markdown('**RMSE (capped at l/2)**'):
                # Tall
                predictions_test["RMSE"] = [(l / 2) if i > (l / 2) else i
                                            for i in predictions_test["RMSE"]]
                plt.figure(figsize=(3, 9))
                sns.set_theme(style="darkgrid")
                ax2 = sns.barplot(y=predictions_test.index,
                                  x="RMSE",
                                  data=predictions_test)
            st.markdown(imagedownload(plt, 'plot-rmse-tall.pdf'),
                        unsafe_allow_html=True)
            # Wide
            plt.figure(figsize=(12, 3))
            sns.set_theme(style="darkgrid")
            ax2 = sns.barplot(x=predictions_test.index,
                              y="RMSE",
                              data=predictions_test)
            plt.xticks(rotation=90)
            st.pyplot(plt)
            st.markdown(imagedownload(plt, 'plot-rmse-wide.pdf'),
                        unsafe_allow_html=True)

            with st.markdown('**Calculation time**'):
                # Tall
                predictions_test["Time Taken"] = [
                    0 if i < 0 else i for i in predictions_test["Time Taken"]
                ]
                plt.figure(figsize=(3, 9))
                sns.set_theme(style="darkgrid")
                ax3 = sns.barplot(y=predictions_test.index,
                                  x="Time Taken",
                                  data=predictions_test)
            st.markdown(imagedownload(plt, 'plot-calculation-time-tall.pdf'),
                        unsafe_allow_html=True)
            # Wide
            plt.figure(figsize=(9, 3))
            sns.set_theme(style="darkgrid")
            ax3 = sns.barplot(x=predictions_test.index,
                              y="Time Taken",
                              data=predictions_test)
            plt.xticks(rotation=90)
            st.pyplot(plt)
            st.markdown(imagedownload(plt, 'plot-calculation-time-wide.pdf'),
                        unsafe_allow_html=True)

        def filedownload(df, filename):
            csv = df.to_csv(index=False)
            b64 = base64.b64encode(
                csv.encode()).decode()  # strings <-> bytes conversions
            href = f'<a href="data:file/csv;base64,{b64}" download={filename}>Download {filename} File</a>'
            return href

        def imagedownload(plt, filename):
            s = io.BytesIO()
            plt.savefig(s, format='pdf', bbox_inches='tight')
            plt.close()
            b64 = base64.b64encode(
                s.getvalue()).decode()  # strings <-> bytes conversions
            href = f'<a href="data:image/png;base64,{b64}" download={filename}>Download {filename} File</a>'
            return href

        with st.sidebar.header('File Uploader Section'):
            uploaded_file = st.sidebar.file_uploader(
                "Upload an input as CSV file", type=["csv"])

        with st.sidebar.header(
                'Set the optimization parameters\n (Grab the slider and set to any suitable point)'
        ):

            split_size = st.sidebar.slider('Data split ratio (in fraction):',
                                           0.0, 1.0, 0.7, 0.01)
            seed_number = st.sidebar.slider('Set the random-seed-value :', 0,
                                            1, 100, 5)

        with st.sidebar.header('Project made by:'):
            st.write("Made by: MAINAK CHAUDHURI")

        #---------------------------------#

        st.subheader('Dataset display')

        if uploaded_file is not None:
            df = pd.read_csv(uploaded_file)
            st.markdown('**Snap of the dataset**')
            st.write(df)
            build_model(df)
        else:
            st.info('Upload a file')
            st.info('OR')
            if st.button('Use preloaded data instead'):
                st.info("Dataset used : Pima diabetes")

                diabetes = load_diabetes()

                X = pd.DataFrame(diabetes.data,
                                 columns=diabetes.feature_names).loc[:100]
                Y = pd.Series(diabetes.target, name='response').loc[:100]
                df = pd.concat([X, Y], axis=1)

                st.markdown(
                    'Displaying results form a sample preloaded data :')
                st.write(df.head(5))

                build_model(df)

    elif option == 'Classification':
        st.subheader("Classifier ML Model Builder")

        def build_model(df):
            l = len(df)

            #df = df.iloc[:100]
            X = df.iloc[:, :
                        -1]  # Using all column except for the last column as X
            Y = df.iloc[:, -1]  # Selecting the last column as Y

            st.markdown('**1.2. Dataset dimension**')
            st.write('X (Independent Axis)')
            st.info(X.shape)
            st.write('Y (Dependent Axis)')
            st.info(Y.shape)

            st.markdown('**1.3. Variable details**:')
            st.write('X variable (first few are shown)')
            st.info(list(X.columns[:int(l / 5)]))
            st.write('Y variable')
            st.info(Y.name)

            # Build lazy model
            X_train, X_test, Y_train, Y_test = train_test_split(
                X, Y, test_size=split_size, random_state=seed_number)
            clf = LazyClassifier(verbose=0,
                                 ignore_warnings=False,
                                 custom_metric=None)
            models_train, predictions_train = clf.fit(X_train, X_train,
                                                      Y_train, Y_train)
            models_test, predictions_test = clf.fit(X_train, X_test, Y_train,
                                                    Y_test)

            st.subheader('2.Model Performance Plot (Training Set)')

            st.write('Training set')
            st.write(predictions_train)
            st.markdown(filedownload(predictions_train, 'training.csv'),
                        unsafe_allow_html=True)

            st.write('Test set')
            st.write(predictions_test)
            st.markdown(filedownload(predictions_test, 'test.csv'),
                        unsafe_allow_html=True)

            st.subheader('3.Model Performance Plot(Test set)')

            with st.markdown('**Accuracy**'):
                # Tall
                predictions_test["Accuracy"] = [
                    0 if i < 0 else i for i in predictions_test["Accuracy"]
                ]
                plt.figure(figsize=(5, 12))
                sns.set_theme(style="darkgrid")
                ax1 = sns.barplot(y=predictions_test.index,
                                  x="Accuracy",
                                  data=predictions_test)
                ax1.set(xlim=(0, 1))
            st.markdown(imagedownload(plt, 'plot-r2-tall.pdf'),
                        unsafe_allow_html=True)
            # Wide
            plt.figure(figsize=(12, 5))
            sns.set_theme(style="darkgrid")
            ax1 = sns.barplot(x=predictions_test.index,
                              y="Accuracy",
                              data=predictions_test)
            ax1.set(ylim=(0, 1))
            plt.xticks(rotation=90)
            st.pyplot(plt)
            st.markdown(imagedownload(plt, 'plot-r2-wide.pdf'),
                        unsafe_allow_html=True)

        def filedownload(df, filename):
            csv = df.to_csv(index=False)
            b64 = base64.b64encode(
                csv.encode()).decode()  # strings <-> bytes conversions
            href = f'<a href="data:file/csv;base64,{b64}" download={filename}>Download {filename} File</a>'
            return href

        def imagedownload(plt, filename):
            s = io.BytesIO()
            plt.savefig(s, format='pdf', bbox_inches='tight')
            plt.close()
            b64 = base64.b64encode(
                s.getvalue()).decode()  # strings <-> bytes conversions
            href = f'<a href="data:image/png;base64,{b64}" download={filename}>Download {filename} File</a>'
            return href

        with st.sidebar.header('File Uploader Section'):
            uploaded_file = st.sidebar.file_uploader(
                "Upload an input as CSV file", type=["csv"])

        with st.sidebar.header(
                'Set the optimization parameters\n (Grab the slider and set to any suitable point)'
        ):

            split_size = st.sidebar.slider('Data split ratio (in fraction):',
                                           0.0, 1.0, 0.7, 0.01)
            seed_number = st.sidebar.slider('Set the random-seed-value :', 0,
                                            1, 100, 5)

        with st.sidebar.header('Project made by:'):
            st.write("Made by: MAINAK CHAUDHURI")

        #---------------------------------#

        st.subheader('Dataset display')

        if uploaded_file is not None:
            df = pd.read_csv(uploaded_file)
            st.markdown('**Snap of the dataset**')
            st.write(df)
            build_model(df)
        else:
            st.info('Upload a file')
            st.info('OR')
            if st.button('Use preloaded data instead'):
                st.info("Dataset used : Pima diabetes")

                diabetes = load_diabetes()

                X = pd.DataFrame(diabetes.data,
                                 columns=diabetes.feature_names).loc[:100]
                Y = pd.Series(diabetes.target, name='response').loc[:100]
                df = pd.concat([X, Y], axis=1)

                st.markdown(
                    'Displaying results form a sample preloaded data :')
                st.write(df.head(5))

                build_model(df)

    elif option == 'Documentation':
        st.subheader("How to use Notebooker Pro")

    elif option == 'About Us':
        st.subheader("About Us 😊")
        st.markdown(
            '''This web application is made by Mainak Chaudhuri. He is a Computer Science and Engineering student of the SRM University, studying in the second year of B.Tech. The main idea of this application is to help beginners and data science enthusiasts chalk out a plan for preparing a good data science notebook, for college projects, online courses or to add in their portfolio. This application accepts a dataset from the user and displays useful insights about the data. Additionally, it also helps the user visualize the data, choose the best supervised machine learning model (regression & classifaction handled separately) and decide the best suit depending on the dataset size,split and seed values which can be set by the user with the help of the side panel. This application claims to be the first of it's kind ever developed till date by a single developer and also has a serving history and positive reports from 180+ users.
                    
                    
     👉   N.B. : This application is an intellectual property of Mainak Chaudhuri and hence holds a reserved copyright. Any form of illegal immitation of graphics, contents or documentation without prior permission of the owner if proved, can result in legal actions against the plagiarist.'''
        )

        st.success('For more info, feel free to contact @ : ')
        url = 'https://www.linkedin.com/in/mainak-chaudhuri-127898176/'

        if st.button('Mainak Chaudhuri'):
            webbrowser.open_new_tab(url)
st.write("### Price Distribution for", bhs)
hs = px.histogram(filtered_data,
                 filtered_data['price'],
                 labels = {"price": "Price ($)",
                            "y": "Count"},
                 template = 'plotly_dark',
                 width = 750)
st.write(hs)

# BOROUGH BOX PLOTS

st.write("### Borough Price Distributions")
vp = px.box(filtered_data,
               y = dataset['price'],
               color = dataset['neighbourhood_group_cleansed'],
               template = 'plotly_dark',
               range_y = (0, 500),
               labels = {"color": "Borough",
                         "y": "Price ($)"},
               width = 750)
st.write(vp)

# FEATURE PLOTTING

st.title("")
st.subheader("")
st.title("Dimensionality Reduction")

# Smaller Feature Set
features = ['host_listings_count','bedrooms','beds','price',
            'minimum_nights','maximum_nights','number_of_reviews',
            'calculated_host_listings_count']
Exemple #13
0
import streamlit as st
import plotly_express as px
from experiments.classical_ml import loadResults

results = loadResults().sort_values('mean_test_score', ascending=False)
# results = loadResults().sort_values('rank_test_score')
results['clf_name'] = results.param_clf.apply(lambda clf: clf.split('(')[0])

st.write(
    results,
    results[['params', 'mean_test_score', 'rank_test_score']],
)

st.write(
    px.bar(results, y='mean_test_score', x=results.index),
    px.box(results, y='mean_test_score', color='clf_name'),
)


clfs = st.multiselect('Clf', results.clf_name.unique())
if (len(clfs)):
    st.write(
        px.box(
            results[results.clf_name.isin(clfs)],
            y='mean_test_score', color='param_vect__ngram_range'
        ),
        px.box(
            results[results.clf_name.isin(clfs)],
            y='mean_test_score', color='param_vect__max_features'
        ),
    )
Exemple #14
0
def app():
    def upload_data(uploaded_file):
        df = pd.read_csv(uploaded_file, sep=';')
        numeric_cols = list(df.select_dtypes(['float64', 'int64']).columns)
        text_data = df.select_dtypes(['object'])
        text_cols = text_data.columns
        return df, numeric_cols, text_cols

    st.subheader('Visualization')
    st.info(
        'Exploring the world of Machine Learning and Artificial Intelligence with the magic of data'
    )
    with st.beta_expander("Upload"):
        col1, col2 = st.beta_columns(2)
        with col1:
            uploaded_file = st.file_uploader(label="Upload your csv file:",
                                             type=['csv', 'xlsx'])
            if uploaded_file is not None:
                try:
                    df, numeric_cols, text_cols = upload_data(uploaded_file)
                except Exception as e:
                    df = pd.read_excel(uploaded_file)
                    numeric_cols = list(
                        df.select_dtypes(['float', 'int']).columns)
        try:
            if uploaded_file is not None:
                if st.button('View Data'):
                    latest_iteration = st.empty()
                    for i in range(100):
                        latest_iteration.info(f' {i + 1} %')
                        time.sleep(0.05)
                    time.sleep(0.2)
                    latest_iteration.empty()
                    st.info(uploaded_file.name)
                    st.write(df)
                    x_val = df.shape[0]
                    y_val = df.shape[1]
                    st.write("Data-shape :", x_val, "Features :", y_val)
            else:
                st.error("Please Upload a File")
        except Exception as e:
            print('')
    with st.beta_expander("Let's Visualise"):
        col3, col4 = st.beta_columns((1, 3))
        if uploaded_file is not None:
            with col3:
                chart_select = st.selectbox(label="Select the chart-type",
                                            options=[
                                                'Scatter-plots', 'Histogram',
                                                'Distplot', 'Box-plot',
                                                'Violin-plot', 'Line-chart',
                                                'Heat-map'
                                            ])
                if chart_select == 'Scatter-plots':
                    st.subheader("Scatter-plot Settings:")
                    x_values = st.selectbox('X-axis', options=numeric_cols)
                    y_values = st.selectbox('Y-axis', options=numeric_cols)
                    with col4:
                        plot = px.scatter(data_frame=df,
                                          x=x_values,
                                          y=y_values)
                        st.plotly_chart(plot)
                if chart_select == 'Histogram':
                    st.subheader("Histogram Settings:")
                    x_values = st.selectbox('value', options=numeric_cols)
                    x_val = np.array(df[x_values])
                    fig, ax = plt.subplots(figsize=(15, 9))
                    sns.set_style("dark")
                    sns.set_style("darkgrid")
                    sns.histplot(data=x_val, kde=True)
                    with col4:
                        st.pyplot(fig)
                if chart_select == 'Distplot':
                    st.subheader("Distplot Settings:")
                    x_values = st.selectbox('value', options=numeric_cols)
                    x_val = np.array(df[x_values])
                    fig, ax = plt.subplots(figsize=(15, 9))
                    sns.set_style("dark")
                    sns.set_style("darkgrid")
                    sns.distplot(x_val)
                    with col4:
                        st.pyplot(fig)
                if chart_select == 'Box-plot':
                    st.subheader("Box-plot Settings:")
                    x_values = st.selectbox('X-axis', options=numeric_cols)
                    y_values = st.selectbox('Y-axis', options=numeric_cols)
                    with col4:
                        plot = px.box(data_frame=df, x=x_values, y=y_values)
                        st.plotly_chart(plot)
                if chart_select == 'Violin-plot':
                    st.subheader("Violin-plot Settings:")
                    x_values = st.selectbox('X-axis', options=numeric_cols)
                    y_values = st.selectbox('Y-axis', options=numeric_cols)
                    with col4:
                        plot = px.violin(data_frame=df,
                                         x=x_values,
                                         y=y_values,
                                         points='all',
                                         box=True)
                        st.plotly_chart(plot)
                if chart_select == 'Heat-map':
                    st.subheader('Heat-map')

                    @st.cache
                    def create_data():
                        data_val = pd.DataFrame(df)
                        return data_val

                    data_val = create_data()
                    fig, ax = plt.subplots(figsize=(15, 9))
                    sns.set_style("darkgrid")
                    sns.set_style("dark")
                    sns.set_theme(style='darkgrid', palette='deep')
                    sns.heatmap(data_val.corr(),
                                ax=ax,
                                annot=True,
                                fmt='.3f',
                                linewidths=.9,
                                cbar_kws={"orientation": "horizontal"},
                                cmap='BuPu')
                    with col4:
                        st.pyplot(fig)
                if chart_select == 'Line-chart':
                    print(uploaded_file.name)
                    st.subheader("Line-3d-chart Settings:")
                    option1 = False
                    if uploaded_file.name == 'student-por.csv' or uploaded_file.name == 'student-mat.csv':
                        error_entry = st.success("Grade-column created!!")
                        time.sleep(0.1)
                        error_entry.empty()
                        grade = []
                        dgp = df
                        for i in dgp['G3'].values:
                            if i in range(0, 10):
                                grade.append('F')
                            elif i in range(10, 12):
                                grade.append('D')
                            elif i in range(12, 14):
                                grade.append('C')
                            elif i in range(14, 16):
                                grade.append('B')
                            else:
                                grade.append('A')
                        se = pd.Series(grade)
                        dgp['Grade'] = se.values
                        option1 = True
                        if uploaded_file.name == 'student-por.csv' or uploaded_file.name == 'student-mat.csv' and option1 == True:
                            ncols = list(
                                dgp.select_dtypes(['float64',
                                                   'int64']).columns)
                            feature_selection = st.multiselect(
                                label="Features to plot",
                                options=ncols,
                                default=ncols[0])
                            feature_ticker = st.selectbox(
                                'Feature ticker',
                                options=list(["A", "B", "C", "D", "E"]))
                            print(feature_selection)
                            if feature_selection:
                                df1 = dgp
                                df2 = df1[df1['Grade'] == feature_ticker]
                                df_features = df2[feature_selection]
                                with col4:
                                    plot = px.line(data_frame=df_features,
                                                   x=df_features.index,
                                                   y=feature_selection)
                                    st.plotly_chart(plot)
                            elif feature_selection == []:
                                st.error("Please select one Feature-selection")

        else:
            st.error("Please upload file in 'Upload' section")
    st.subheader("Pre-processing, Spliting, Training")
    col6, col7, col8 = st.beta_columns((1, 1, 1))
    col9, col10 = st.beta_columns((6, 1))
    if uploaded_file is not None:
        with col6:
            pg = st.beta_expander("Preprocessing")
            with pg:
                ppd = st.checkbox(label="Preprocess-data")
                if ppd:
                    dataset = df
                    sc = {
                        'GP': 1,
                        'MS': 2,
                    }
                    parent = {
                        'mother': 1,
                        'father': 2,
                        'other': 3,
                    }
                    reas = {
                        'home': 1,
                        'reputation': 2,
                        'course': 3,
                        'other': 4,
                    }
                    mjob = {
                        'teacher': 1,
                        'health': 2,
                        'services': 3,
                        'at_home': 4,
                        'other': 5,
                    }
                    fjob = {
                        'teacher': 1,
                        'health': 2,
                        'services': 3,
                        'at_home': 4,
                        'other': 5,
                    }
                    change = {
                        'yes': 1,
                        'no': 0,
                    }

                    dataset['address'].replace(to_replace="U",
                                               value=1,
                                               inplace=True)
                    dataset['address'].replace(to_replace="R",
                                               value=2,
                                               inplace=True)
                    dataset['famsize'].replace(to_replace="LE3",
                                               value=1,
                                               inplace=True)
                    dataset['famsize'].replace(to_replace="GT3",
                                               value=2,
                                               inplace=True)
                    dataset['Pstatus'].replace(to_replace="T",
                                               value=1,
                                               inplace=True)
                    dataset['Pstatus'].replace(to_replace="A",
                                               value=2,
                                               inplace=True)
                    dataset['romantic'] = dataset['romantic'].map(change)
                    dataset['internet'] = dataset['internet'].map(change)
                    dataset['famsup'] = dataset['famsup'].map(change)
                    dataset['schoolsup'] = dataset['schoolsup'].map(change)
                    dataset['sex'].replace(to_replace="M",
                                           value=1,
                                           inplace=True)
                    dataset['sex'].replace(to_replace="F",
                                           value=2,
                                           inplace=True)
                    dataset['Mjob'] = dataset['Mjob'].map(mjob)
                    dataset['Fjob'] = dataset['Fjob'].map(fjob)
                    dataset['activities'] = dataset['activities'].map(change)
                    dataset['paid'] = dataset['paid'].map(change)
                    dataset['nursery'] = dataset['nursery'].map(change)
                    dataset['higher'] = dataset['higher'].map(change)
                    dataset['reason'] = dataset['reason'].map(reas)
                    dataset['guardian'] = dataset['guardian'].map(parent)
                    dataset['school'] = dataset['school'].map(sc)
                    grade = []
                    for i in dataset['G3'].values:
                        if i in range(0, 10):
                            grade.append(4)
                        elif i in range(10, 12):
                            grade.append(3)
                        elif i in range(12, 14):
                            grade.append(2)
                        elif i in range(14, 16):
                            grade.append(1)
                        else:
                            grade.append(0)

                    Data1 = dataset
                    se = pd.Series(grade)
                    Data1['Grade'] = se.values
                    dataset.drop(dataset[dataset.G1 == 0].index, inplace=True)
                    dataset.drop(dataset[dataset.G3 == 0].index, inplace=True)
                    d1 = dataset
                    d1['All_Sup'] = d1['famsup'] & d1['schoolsup']

                    def max_parenteducation(d1):
                        return (max(d1['Medu'], d1['Fedu']))

                    d1['maxparent_edu'] = d1.apply(
                        lambda row: max_parenteducation(row), axis=1)
                    # d1['PairEdu'] = d1[['Fedu', 'Medu']].mean(axis=1)
                    d1['more_high'] = d1['higher'] & (d1['schoolsup']
                                                      | d1['paid'])
                    d1['All_alc'] = d1['Walc'] + d1['Dalc']
                    d1['Dalc_per_week'] = d1['Dalc'] / d1['All_alc']
                    d1.drop(['Dalc'], axis=1, inplace=True)
                    d1.drop(['Walc'], axis=1, inplace=True)
                    d1['studytime_ratio'] = d1['studytime'] / (d1[[
                        'studytime', 'traveltime', 'freetime'
                    ]].sum(axis=1))
                    d1.drop(['studytime'], axis=1, inplace=True)
                    d1.drop(['Fedu'], axis=1, inplace=True)
                    d1.drop(['Medu'], axis=1, inplace=True)
                    X = d1.iloc[:, [
                        1, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
                        19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33,
                        34
                    ]]
                    Y = d1.iloc[:, [28]]
                    time.sleep(0.01)
                    dp = st.success("Data-Preprocessed")
                    time.sleep(1)
                    dp.empty()

        with col7:
            sg = st.beta_expander("Splitting")
            with sg:
                sd = st.checkbox(label="Splitting Training Data")
                if sd:
                    test_size = st.number_input('Test-size', value=0.3)
                    random_state = st.number_input('Random-state', value=42)
                    xTrain, xTest, yTrain, yTest = train_test_split(
                        X, Y, test_size=test_size, random_state=random_state)

        with col8:
            tdd = st.beta_expander("Train")
            with tdd:
                classifier_name = st.selectbox("Select Classifier :",
                                               ("LVQ", "PNN"))
                if classifier_name == "LVQ":
                    check_box5 = st.checkbox(label="LVQ Classifier-Settings")
                    if check_box5:
                        feat_range = d1.shape[1]
                        n_inp1 = st.selectbox('Features-inputs',
                                              range(feat_range))
                        n_cla1 = st.number_input('Classes', 0)
                        step1 = st.number_input('Step', 0.01)
                    with col9:
                        t = st.button("Train")
                        if t:
                            Lvq_net = algorithms.LVQ21(n_inputs=n_inp1,
                                                       n_classes=n_cla1,
                                                       verbose=False,
                                                       step=step1,
                                                       shuffle_data=False)
                            Lvq_net.train(xTrain, yTrain, epochs=100)
                            y_training = Lvq_net.predict(xTrain)
                            y_prediction = Lvq_net.predict(xTest)
                            time.sleep(0.1)
                            zz = st.balloons()
                            st.markdown(
                                'Prediction accuracy of LVQ Train data : ',
                                unsafe_allow_html=True)
                            st.write('{:.2%}\n'.format(
                                metrics.accuracy_score(yTrain, y_training)))
                            st.markdown(
                                'Prediction accuracy of LVQ Test data : ',
                                unsafe_allow_html=True)
                            st.write('{:.2%}\n'.format(
                                metrics.accuracy_score(yTest, y_prediction)))
                            cohen_score = cohen_kappa_score(
                                yTest, y_prediction)
                            st.markdown('LVQ Cohen-Kappa Score :',
                                        unsafe_allow_html=True)
                            st.write(cohen_score)
                            time.sleep(1)
                            zz.empty()

                if classifier_name == "PNN":
                    check_box5 = st.checkbox(label="PNN Classifier-Settings")
                    if check_box5:
                        std_dev = st.number_input("Standard-deviation", 5)
                    with col9:
                        p = st.button("Train")
                        if p:
                            pnn = algorithms.PNN(std=std_dev, verbose=False)
                            pnn.train(xTrain, yTrain)
                            y_training1 = pnn.predict(xTrain)
                            y_prediction1 = pnn.predict(xTest)
                            time.sleep(0.1)
                            xy = st.balloons()
                            st.markdown(
                                'Prediction accuracy of PNN Train data : ',
                                unsafe_allow_html=True)
                            st.write('{:.2%}\n'.format(
                                metrics.accuracy_score(yTrain, y_training1)))
                            st.markdown(
                                'Prediction accuracy of PNN Test data : ',
                                unsafe_allow_html=True)
                            st.write('{:.2%}\n'.format(
                                metrics.accuracy_score(yTest, y_prediction1)))
                            cohen_score = cohen_kappa_score(
                                yTest, y_prediction1)
                            st.markdown('PNN Cohen-Kappa Score :',
                                        unsafe_allow_html=True)
                            st.write(cohen_score)
                            time.sleep(1)
                            xy.empty()
    else:
        st.error("Please upload a file in 'Upload' section.")
def Plot():
    wb = xw.Book.caller()
    df = From_pkl()

    Animation = wb.sheets('Dash').range('B6:B7').value
    inputs = wb.sheets('Dash').range('B12:M12').value
    Layout = wb.sheets('Dash').range('B9:F9').value

    Filter = wb.sheets('Dash').range('G3').value

    af = Animation[0]
    ag = Animation[1]

    Title = Layout[0]
    hover_name = Layout[1]
    Log_x = Layout[3]
    Log_y = Layout[4]

    if Filter is not None:
        df = df.query(Filter)

    if inputs[0] == 'scatter':
        Plot = px.scatter(df,
                          title=Title,
                          x=inputs[1],
                          y=inputs[2],
                          color=inputs[3],
                          size=inputs[4],
                          facet_row=inputs[5],
                          facet_col=inputs[6],
                          hover_name=hover_name,
                          animation_frame=af,
                          animation_group=ag,
                          log_x=Log_x,
                          log_y=Log_y,
                          trendline=inputs[7],
                          marginal_x=inputs[8],
                          marginal_y=inputs[9])

    elif inputs[0] == 'line':
        Plot = px.line(df,
                       title=Title,
                       x=inputs[1],
                       y=inputs[2],
                       color=inputs[3],
                       log_x=Log_x,
                       log_y=Log_y,
                       facet_row=inputs[4],
                       facet_col=inputs[5],
                       line_group=inputs[6],
                       line_dash=inputs[7])

    elif inputs[0] == 'scatter matrix':
        Plot = px.scatter_matrix(df, title=Title, color=inputs[1])

    elif inputs[0] == 'bar':
        Plot = px.bar(df,
                      x=inputs[1],
                      title=Title,
                      y=inputs[2],
                      color=inputs[3],
                      log_x=Log_x,
                      log_y=Log_y,
                      facet_row=inputs[4],
                      facet_col=inputs[5])

    elif inputs[0] == 'density':
        Plot = px.density_contour(
            df,
            title=Title,
            x=inputs[1],
            y=inputs[2],
            color=inputs[3],
            facet_row=inputs[4],
            facet_col=inputs[5],
            marginal_x=inputs[8],
            marginal_y=inputs[7],
            log_x=Log_x,
            log_y=Log_y,
        )

    elif inputs[0] == 'box':
        Plot = px.box(df,
                      title=Title,
                      x=inputs[1],
                      y=inputs[2],
                      color=inputs[3],
                      log_x=Log_x,
                      log_y=Log_y,
                      facet_row=inputs[4],
                      facet_col=inputs[5])

    elif inputs[0] == 'histogram':
        Plot = px.histogram(df,
                            title=Title,
                            x=inputs[1],
                            y=inputs[2],
                            log_x=Log_x,
                            log_y=Log_y,
                            color=inputs[3],
                            facet_row=inputs[4],
                            facet_col=inputs[5],
                            histfunc=inputs[6],
                            marginal=inputs[8])

    elif inputs[0] == 'violin':
        Plot = px.violin(df,
                         title=Title,
                         x=inputs[1],
                         y=inputs[2],
                         color=inputs[3],
                         facet_row=inputs[4],
                         log_x=Log_x,
                         log_y=Log_y,
                         facet_col=inputs[5])

    elif inputs[0] == '3d scatter':
        Plot = px.scatter_3d(df,
                             title=Title,
                             x=inputs[1],
                             y=inputs[2],
                             z=inputs[3],
                             log_x=Log_x,
                             log_y=Log_y,
                             color=inputs[4],
                             size=inputs[5],
                             hover_name=hover_name)

    elif inputs[0] == '3d line':
        Plot = px.line_3d(
            df,
            title=Title,
            x=inputs[1],
            y=inputs[2],
            z=inputs[3],
            log_x=Log_x,
            log_y=Log_y,
            color=inputs[4],
            size=inputs[5],
        )

    elif inputs[0] == 'scatter polar':
        Plot = px.scatter_polar(df,
                                title=Title,
                                r=inputs[1],
                                theta=inputs[2],
                                color=inputs[3],
                                log_x=Log_x,
                                log_y=Log_y,
                                symbol=inputs[4])

    elif inputs[0] == 'line polar':
        Plot = px.line_polar(df,
                             title=Title,
                             r=inputs[1],
                             theta=inputs[2],
                             log_x=Log_x,
                             log_y=Log_y,
                             color=inputs[2],
                             line_close=True)

    elif inputs[0] == 'bar polar':
        Plot = px.bar_polar(df,
                            title=Title,
                            r=inputs[1],
                            theta=inputs[2],
                            log_x=Log_x,
                            log_y=Log_y,
                            color=inputs[3])

    elif inputs[0] == 'parallel_categories':
        Plot = px.parallel_categories(df, title=Title, color=inputs[1])

    plotly.offline.plot(Plot)