Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -752,6 +752,12 @@ elif app_mode == "Model Training":
|
|
752 |
Choose from a wide range of algorithms and configurations.
|
753 |
""")
|
754 |
|
|
|
|
|
|
|
|
|
|
|
|
|
755 |
if 'cleaned_data' not in st.session_state or st.session_state.cleaned_data is None:
|
756 |
st.warning("Please clean your data in the Smart Cleaning section first.")
|
757 |
st.stop()
|
@@ -963,8 +969,7 @@ elif app_mode == "Model Training":
|
|
963 |
except Exception as e:
|
964 |
st.error(f"An error occurred during training: {e}")
|
965 |
|
966 |
-
|
967 |
-
if st.session_state.model is not None:
|
968 |
st.subheader("💾 Save Model")
|
969 |
model_filename = st.text_input("Enter Model Filename (without extension)", "trained_model")
|
970 |
if st.button("Save Model"):
|
@@ -973,6 +978,8 @@ elif app_mode == "Model Training":
|
|
973 |
st.success(f"Model saved as {model_filename}.joblib")
|
974 |
except Exception as e:
|
975 |
st.error(f"Error saving model: {e}")
|
|
|
|
|
976 |
|
977 |
# Visualization Lab Section
|
978 |
elif app_mode == "Visualization Lab":
|
|
|
752 |
Choose from a wide range of algorithms and configurations.
|
753 |
""")
|
754 |
|
755 |
+
# Initialize session state variables if they don't exist
|
756 |
+
if 'model' not in st.session_state:
|
757 |
+
st.session_state.model = None
|
758 |
+
if 'preprocessor' not in st.session_state:
|
759 |
+
st.session_state.preprocessor = None
|
760 |
+
|
761 |
if 'cleaned_data' not in st.session_state or st.session_state.cleaned_data is None:
|
762 |
st.warning("Please clean your data in the Smart Cleaning section first.")
|
763 |
st.stop()
|
|
|
969 |
except Exception as e:
|
970 |
st.error(f"An error occurred during training: {e}")
|
971 |
|
972 |
+
if st.session_state.model is not None:
|
|
|
973 |
st.subheader("💾 Save Model")
|
974 |
model_filename = st.text_input("Enter Model Filename (without extension)", "trained_model")
|
975 |
if st.button("Save Model"):
|
|
|
978 |
st.success(f"Model saved as {model_filename}.joblib")
|
979 |
except Exception as e:
|
980 |
st.error(f"Error saving model: {e}")
|
981 |
+
else:
|
982 |
+
st.warning("No trained model available. Train a model first to enable saving.")
|
983 |
|
984 |
# Visualization Lab Section
|
985 |
elif app_mode == "Visualization Lab":
|