So, I want to show the classification_score from sklearn in the streamlit project I have with expectation the score will show as neatly arranged as in Jupyter notebook. But, it seems the behavior isn’t the same, leading the arrangement become odd and put out of the place.
I have tried several ways to re-arrange the placement namely : with st.column, st.expaner, etc but sadly to no avail.
I was wondering if anyone had the same problem previously and found the right way to do the arrangement so the score become neatly arrange like in the Jupyter notebook?
Thank you in advance.
st.markdown("<br>", unsafe_allow_html=True) if "scaled_data_train" in st.session_state: st.write(st.session_state.scaled_data_train) else: # Setting the upload variabel uploaded_file = st.file_uploader("Choose a file to upload for training data", type="csv", help="The file will be used for training the Machine Learning", ) # Setting the upload options when there's file on uploader menu if uploaded_file is not None: try: # Uploading Dataframe dataframe = get_data(uploaded_file) X = dataframe.drop(columns="Outcome") y = dataframe["Outcome"] # Storing dataframe to session state if 'X' not in st.session_state: st.session_state["X"] = X if 'y' not in st.session_state: st.session_state["y"] = y except: st.write("Please upload any data") # Markdown to gice space st.markdown("<br>", unsafe_allow_html=True) st.markdown("<br>", unsafe_allow_html=True) st.markdown("<h3 style='text-align: center; color: cyan;'>Model Setting</h3>", unsafe_allow_html=True) st.markdown("<br>", unsafe_allow_html=True) # Selecting Model for Classification model_selection = st.selectbox( "Select Machine Learning Model for Classification Task", ("Logistic Regression", "Random Forest") ) st.write("Model selected:", model_selection) # Setting Logistic Regression Model if model_selection == "Logistic Regression": col1, col2, col3 = st.columns(3) with col1: # Setting Logistic Regression Penalty log_res_penalty = st.radio( "Norm of the penalty", ('l1', 'l2', 'none')) with col2: # Setting Logistis Regression Solver log_res_solver = st.radio( "Algorithm optimization", ("lbfgs", "liblinear", "newton-cg", "newton-cholesky", "sag", "saga" )) with col3: # Inverse of regularization strength log_res_inverse = st.number_input( "Inverse of regularization", min_value=0.001, value=1.0, step=0.01) # Logistic Regression Object log_res_obj = LogisticRegression( penalty=log_res_penalty, C=log_res_inverse, solver=log_res_solver) # Fitting Data to Logistic Regression Model if st.button("Fit Data to Logistic Re Model"): # Initiating variable to fir data X_train = st.session_state.scaled_data_train X_test = st.session_state.scaled_data_test y_train = st.session_state.y_train y_test = st.session_state.y_test # Fitting model to data log_res_obj.fit(X_train, y_train) st.write("Training Success") # Predicting train data y_train_predict = log_res_obj.predict(X_train) y_train_predict_df = pd.DataFrame(y_train_predict) # Predicting test data y_test_predict = log_res_obj.predict(X_test) y_test_predict_df = pd.DataFrame(y_train_predict) # Predicting F1 score classification_report_train = classification_report( y_train, y_train_predict, labels=[0, 1]) classification_report_test = classification_report( y_test, y_test_predict, labels=[0, 1])