Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -179,7 +179,24 @@ with tab1:
|
|
| 179 |
|
| 180 |
# Option to toggle PCA
|
| 181 |
use_pca = st.checkbox('Use PCA for Visualization', value=True)
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
# Create a DataFrame for easier plotting with plotly
|
| 184 |
df_transformed = pd.DataFrame(X_transformed, columns=['Feature1', 'Feature2'])
|
| 185 |
|
|
@@ -224,23 +241,7 @@ with tab1:
|
|
| 224 |
|
| 225 |
# Update layout
|
| 226 |
fig.update_layout(width=1200, height=500)
|
| 227 |
-
|
| 228 |
-
st.write("""
|
| 229 |
-
### Visualizing Groups
|
| 230 |
-
##### Here are the groups from our tidying method. Each color has a number at its center, representing its group.
|
| 231 |
-
""")
|
| 232 |
-
st.plotly_chart(fig)
|
| 233 |
-
if use_pca:
|
| 234 |
-
st.write("""
|
| 235 |
-
##### 🧠 PCA (Principal Component Analysis) is like looking at a messy room from the best angle to see the most mess. It helps us see our data more clearly!
|
| 236 |
-
""")
|
| 237 |
-
# Apply PCA for dimensionality reduction
|
| 238 |
-
pca = PCA(n_components=2)
|
| 239 |
-
X_transformed = pca.fit_transform(X)
|
| 240 |
-
user_features_transformed = pca.transform([user_features])[0]
|
| 241 |
-
else:
|
| 242 |
-
X_transformed = X[:, :2] # Just use the first two features for visualization
|
| 243 |
-
user_features_transformed = user_features[:2]
|
| 244 |
st.write(f"##### Overlapping clusters mean some flowers are very similar and hard to tell apart just by looking at these features.")
|
| 245 |
st.write(f"# Based on your flower data (⭐), it likely belongs to **Group {dmojis[predicted_cluster[0]+1]}**")
|
| 246 |
|
|
|
|
| 179 |
|
| 180 |
# Option to toggle PCA
|
| 181 |
use_pca = st.checkbox('Use PCA for Visualization', value=True)
|
| 182 |
+
|
| 183 |
+
st.write("""
|
| 184 |
+
### Visualizing Groups
|
| 185 |
+
##### Here are the groups from our tidying method. Each color has a number at its center, representing its group.
|
| 186 |
+
""")
|
| 187 |
+
st.plotly_chart(fig)
|
| 188 |
+
if use_pca:
|
| 189 |
+
st.write("""
|
| 190 |
+
##### 🧠 PCA (Principal Component Analysis) is like looking at a messy room from the best angle to see the most mess. It helps us see our data more clearly!
|
| 191 |
+
""")
|
| 192 |
+
# Apply PCA for dimensionality reduction
|
| 193 |
+
pca = PCA(n_components=2)
|
| 194 |
+
X_transformed = pca.fit_transform(X)
|
| 195 |
+
user_features_transformed = pca.transform([user_features])[0]
|
| 196 |
+
else:
|
| 197 |
+
X_transformed = X[:, :2] # Just use the first two features for visualization
|
| 198 |
+
user_features_transformed = user_features[:2]
|
| 199 |
+
|
| 200 |
# Create a DataFrame for easier plotting with plotly
|
| 201 |
df_transformed = pd.DataFrame(X_transformed, columns=['Feature1', 'Feature2'])
|
| 202 |
|
|
|
|
| 241 |
|
| 242 |
# Update layout
|
| 243 |
fig.update_layout(width=1200, height=500)
|
| 244 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
st.write(f"##### Overlapping clusters mean some flowers are very similar and hard to tell apart just by looking at these features.")
|
| 246 |
st.write(f"# Based on your flower data (⭐), it likely belongs to **Group {dmojis[predicted_cluster[0]+1]}**")
|
| 247 |
|