Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -149,22 +149,22 @@ if page == "Clustering Analysis":
|
|
| 149 |
|
| 150 |
st.header("Clustering Plots")
|
| 151 |
# plot pca cluster plot
|
| 152 |
-
plot_model(cluster_model, plot = 'cluster', display_format = 'streamlit')
|
| 153 |
|
| 154 |
-
if selected_model != 'ap':
|
| 155 |
-
|
| 156 |
|
| 157 |
-
if selected_model not in ('ap', 'meanshift', 'dbscan', 'optics'):
|
| 158 |
-
|
| 159 |
|
| 160 |
-
if selected_model not in ('ap', 'meanshift', 'sc', 'hclust', 'dbscan', 'optics'):
|
| 161 |
-
|
| 162 |
|
| 163 |
-
if selected_model not in ('ap', 'sc', 'hclust', 'dbscan', 'optics', 'birch'):
|
| 164 |
-
|
| 165 |
|
| 166 |
-
if selected_model != 'ap':
|
| 167 |
-
|
| 168 |
|
| 169 |
# Create a Classification Model to extract feature importance
|
| 170 |
st.header("Feature Importance")
|
|
@@ -172,6 +172,8 @@ if page == "Clustering Analysis":
|
|
| 172 |
s = setup(cluster_model_2, target = 'Cluster')
|
| 173 |
lr = create_model('lr')
|
| 174 |
# this is how you can recreate the table
|
|
|
|
|
|
|
| 175 |
feat_imp = pd.DataFrame({'Feature': get_config('X_train').columns, 'Value' : abs(lr.coef_[0])}).sort_values(by='Value', ascending=False)
|
| 176 |
# sort by feature importance value and filter top 10
|
| 177 |
feat_imp = feat_imp.sort_values(by='Value', ascending=False).head(10)
|
|
|
|
| 149 |
|
| 150 |
st.header("Clustering Plots")
|
| 151 |
# plot pca cluster plot
|
| 152 |
+
# plot_model(cluster_model, plot = 'cluster', display_format = 'streamlit')
|
| 153 |
|
| 154 |
+
# if selected_model != 'ap':
|
| 155 |
+
# plot_model(cluster_model, plot = 'tsne', display_format = 'streamlit')
|
| 156 |
|
| 157 |
+
# if selected_model not in ('ap', 'meanshift', 'dbscan', 'optics'):
|
| 158 |
+
# plot_model(cluster_model, plot = 'elbow', display_format = 'streamlit')
|
| 159 |
|
| 160 |
+
# if selected_model not in ('ap', 'meanshift', 'sc', 'hclust', 'dbscan', 'optics'):
|
| 161 |
+
# plot_model(cluster_model, plot = 'silhouette', display_format = 'streamlit')
|
| 162 |
|
| 163 |
+
# if selected_model not in ('ap', 'sc', 'hclust', 'dbscan', 'optics', 'birch'):
|
| 164 |
+
# plot_model(cluster_model, plot = 'distance', display_format = 'streamlit')
|
| 165 |
|
| 166 |
+
# if selected_model != 'ap':
|
| 167 |
+
# plot_model(cluster_model, plot = 'distribution', display_format = 'streamlit')
|
| 168 |
|
| 169 |
# Create a Classification Model to extract feature importance
|
| 170 |
st.header("Feature Importance")
|
|
|
|
| 172 |
s = setup(cluster_model_2, target = 'Cluster')
|
| 173 |
lr = create_model('lr')
|
| 174 |
# this is how you can recreate the table
|
| 175 |
+
print("Number of columns in X_train:", len(get_config('X_train').columns))
|
| 176 |
+
print("Number of coefficients in lr:", len(lr.coef_[0]))
|
| 177 |
feat_imp = pd.DataFrame({'Feature': get_config('X_train').columns, 'Value' : abs(lr.coef_[0])}).sort_values(by='Value', ascending=False)
|
| 178 |
# sort by feature importance value and filter top 10
|
| 179 |
feat_imp = feat_imp.sort_values(by='Value', ascending=False).head(10)
|