CosmickVisions commited on
Commit
f0a87cd
Β·
verified Β·
1 Parent(s): e4d7511

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -16
app.py CHANGED
@@ -729,6 +729,17 @@ with st.expander("πŸš€ Bulk Actions"):
729
  enhance_section_title("Cleaned Data Preview", "✨")
730
  with st.expander("✨ Cleaned Data Preview", expanded=True):
731
  st.dataframe(st.session_state.cleaned_data.head(), use_container_width=True)
 
 
 
 
 
 
 
 
 
 
 
732
 
733
 
734
 
@@ -1117,27 +1128,39 @@ elif app_mode == "EDA":
1117
  except Exception as e:
1118
  st.error(f"Transformation failed: {str(e)}")
1119
 
1120
- # --------------------------
1121
- # Export & Save
1122
- # --------------------------
1123
  enhance_section_title("Export Options", "πŸ’Ύ")
1124
  st.subheader("πŸ’Ύ Export Options")
1125
  col1, col2 = st.columns(2)
 
 
1126
  with col1:
1127
- if st.button("πŸ“₯ Download Current Visualization"):
1128
- try:
1129
- fig.write_image("visualization.png")
1130
- st.success("Image saved!")
1131
- except NameError:
1132
- st.error("No visualization to download. Please create a chart first.")
 
 
 
 
 
 
 
 
1133
  with col2:
1134
- if st.button("πŸ“Š Export Analysis Report"):
1135
- try:
1136
- profile = ProfileReport(df, minimal=True)
1137
- profile.to_file("analysis_report.html")
1138
- st.success("Report generated!")
1139
- except Exception as e:
1140
- st.error(f"Could not generate analysis report. Ensure pandas-profiling is installed correctly.")
 
 
 
 
 
1141
 
1142
  elif app_mode == "Model Training":
1143
  st.title("🧠 Advanced Model Architect")
 
729
  enhance_section_title("Cleaned Data Preview", "✨")
730
  with st.expander("✨ Cleaned Data Preview", expanded=True):
731
  st.dataframe(st.session_state.cleaned_data.head(), use_container_width=True)
732
+
733
+ enhance_section_title("Export Cleaned Data", "πŸ’Ύ")
734
+ with st.expander("πŸ’Ύ Export Cleaned Data", expanded=True):
735
+ st.write("You can download the cleaned data as a CSV file.")
736
+ csv = df.to_csv(index=False).encode('utf-8')
737
+ st.download_button(
738
+ label="πŸ“₯ Download Cleaned Data as CSV",
739
+ data=csv,
740
+ file_name='cleaned_data.csv',
741
+ mime='text/csv',
742
+ )
743
 
744
 
745
 
 
1128
  except Exception as e:
1129
  st.error(f"Transformation failed: {str(e)}")
1130
 
 
 
 
1131
  enhance_section_title("Export Options", "πŸ’Ύ")
1132
  st.subheader("πŸ’Ύ Export Options")
1133
  col1, col2 = st.columns(2)
1134
+
1135
+ # Download Current Visualization
1136
  with col1:
1137
+ if 'fig' in locals() or 'fig' in globals():
1138
+ img_buffer = io.BytesIO()
1139
+ fig.savefig(img_buffer, format='png')
1140
+ img_buffer.seek(0)
1141
+ st.download_button(
1142
+ label="πŸ“₯ Download Current Visualization",
1143
+ data=img_buffer,
1144
+ file_name="visualization.png",
1145
+ mime="image/png",
1146
+ )
1147
+ else:
1148
+ st.warning("No visualization to download. Please create a chart first.")
1149
+
1150
+ # Export Analysis Report
1151
  with col2:
1152
+ try:
1153
+ profile = ProfileReport(df, minimal=True)
1154
+ profile_html = profile.to_html()
1155
+ st.download_button(
1156
+ label="πŸ“Š Export Analysis Report",
1157
+ data=profile_html,
1158
+ file_name="analysis_report.html",
1159
+ mime="text/html",
1160
+ )
1161
+ except Exception as e:
1162
+ st.error(f"Could not generate analysis report. Ensure pandas-profiling is installed correctly.")
1163
+
1164
 
1165
  elif app_mode == "Model Training":
1166
  st.title("🧠 Advanced Model Architect")