Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -179,19 +179,7 @@ with tab1:
|
|
| 179 |
|
| 180 |
# Option to toggle PCA
|
| 181 |
use_pca = st.checkbox('Use PCA for Visualization', value=True)
|
| 182 |
-
|
| 183 |
-
if use_pca:
|
| 184 |
-
st.write("""
|
| 185 |
-
##### 🧠 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!
|
| 186 |
-
""")
|
| 187 |
-
# Apply PCA for dimensionality reduction
|
| 188 |
-
pca = PCA(n_components=2)
|
| 189 |
-
X_transformed = pca.fit_transform(X)
|
| 190 |
-
user_features_transformed = pca.transform([user_features])[0]
|
| 191 |
-
else:
|
| 192 |
-
X_transformed = X[:, :2] # Just use the first two features for visualization
|
| 193 |
-
user_features_transformed = user_features[:2]
|
| 194 |
-
|
| 195 |
# Create a DataFrame for easier plotting with plotly
|
| 196 |
df_transformed = pd.DataFrame(X_transformed, columns=['Feature1', 'Feature2'])
|
| 197 |
|
|
@@ -242,13 +230,17 @@ with tab1:
|
|
| 242 |
##### Here are the groups from our tidying method. Each color has a number at its center, representing its group.
|
| 243 |
""")
|
| 244 |
st.plotly_chart(fig)
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
st.write(f"##### Overlapping clusters mean some flowers are very similar and hard to tell apart just by looking at these features.")
|
| 253 |
st.write(f"# Based on your flower data (⭐), it likely belongs to **Group {dmojis[predicted_cluster[0]+1]}**")
|
| 254 |
|
|
|
|
| 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 |
|
|
|
|
| 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 |
|