saherPervaiz commited on
Commit
cf2ec45
·
verified ·
1 Parent(s): c8b56c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -16
app.py CHANGED
@@ -79,7 +79,7 @@ if uploaded_file is not None:
79
  y = df_cleaned[target]
80
 
81
  # Determine if the target is continuous or categorical
82
- is_classification = y.nunique() <= 10 # If target has fewer than or equal to 10 unique values, treat as classification
83
 
84
  # Ensure there is enough data before proceeding with train-test split
85
  if len(X) == 0 or len(y) == 0:
@@ -165,18 +165,15 @@ if uploaded_file is not None:
165
  mime="image/png"
166
  )
167
 
168
- # Display Histograms of Numerical Columns
169
- st.subheader("Histograms of Numerical Columns")
170
- for column in df_cleaned.select_dtypes(include=['number']).columns:
171
- fig, ax = plt.subplots(figsize=(5, 4)) # Small graph
172
- df_cleaned[column].plot(kind="hist", bins=20, ax=ax, title=column)
173
- st.pyplot(fig)
174
- # Save and provide download option for histogram
175
- fig.savefig(f"/tmp/{column}_histogram.png")
176
- with open(f"/tmp/{column}_histogram.png", "rb") as f:
177
- st.download_button(
178
- label=f"Download {column} Histogram",
179
- data=f,
180
- file_name=f"{column}_histogram.png",
181
- mime="image/png"
182
- )
 
79
  y = df_cleaned[target]
80
 
81
  # Determine if the target is continuous or categorical
82
+ is_classification = len(y.unique()) <= 10 # If target has fewer than or equal to 10 unique values, treat as classification
83
 
84
  # Ensure there is enough data before proceeding with train-test split
85
  if len(X) == 0 or len(y) == 0:
 
165
  mime="image/png"
166
  )
167
 
168
+ # Pair plot of numerical columns to visualize relationships
169
+ st.subheader("Pair Plot of Numerical Columns")
170
+ pair_plot = sns.pairplot(df_cleaned[features]) # Generate pair plot for features
171
+ st.pyplot(pair_plot)
172
+ pair_plot.savefig("/tmp/pair_plot.png")
173
+ with open("/tmp/pair_plot.png", "rb") as f:
174
+ st.download_button(
175
+ label="Download Pair Plot",
176
+ data=f,
177
+ file_name="pair_plot.png",
178
+ mime="image/png"
179
+ )