function for prediction result display

pull/22/head
remrem 10 months ago
parent c1ea1b0c8a
commit 036f46eb91

@ -1,6 +1,6 @@
import streamlit as st import streamlit as st
from io import StringIO from io import StringIO
from ydata_profiling import ProfileReport # from ydata_profiling import ProfileReport
import pandas as pd import pandas as pd
def statistics(df): def statistics(df):
@ -44,8 +44,8 @@ def main():
st.write("## Statistics") st.write("## Statistics")
statistics(df) statistics(df)
profile = ProfileReport(df, title='Pandas Profiling Report', explorative=True) # profile = ProfileReport(df, title='Pandas Profiling Report', explorative=True)
profile.to_widgets() # profile.to_widgets()
if st.button("Next"): if st.button("Next"):
st.switch_page("pages/clean.py") st.switch_page("pages/clean.py")

@ -6,8 +6,18 @@ sys.path.append('./back/')
import clustering_csv as cc import clustering_csv as cc
import prediction as p import prediction as p
if 'df' in st.session_state: def display_prediction_results(df, targetCol):
df_cols.remove(col)
original_col = df[col]
predicted_col = p.getColumnsForPredictionAndPredict(df, df_cols, "Route Type", "Linear Regression")
new_df = pd.DataFrame()
new_df['Original'] = original_col
new_df['Predicted'] = predicted_col
st.dataframe(new_df)
if 'df' in st.session_state:
df = st.session_state.df df = st.session_state.df
df_cols = df.columns.tolist() df_cols = df.columns.tolist()
@ -21,21 +31,10 @@ if 'df' in st.session_state:
if st.button("Linear Regression"): if st.button("Linear Regression"):
col = "Route Type" col = "Route Type"
df_cols.remove(col) display_prediction_results(df, col)
original_col = df[col]
predicted_col = p.getColumnsForPredictionAndPredict(df, df_cols, "Route Type", "Linear Regression")
if st.button("Random Forest"): if st.button("Random Forest"):
col = "Route Type" col = "Route Type"
df_cols.remove(col) display_prediction_results(df, col)
original_col = df[col]
predicted_col = p.getColumnsForPredictionAndPredict(df, df_cols, "Route Type", "Random Forest")
ndf = pd.DataFrame()
ndf['Original'] = original_col
ndf['Predicted'] = predicted_col
st.dataframe(ndf)
else: else:
st.write("Please clean your dataset.") st.write("Please clean your dataset.")

Loading…
Cancel
Save