Hellisotherpeople commited on
Commit
c0985b8
1 Parent(s): b2644a1

Update app.py

Browse files

Try caching more stuff

Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -122,14 +122,19 @@ if task == "Clustering":
122
  ('vect', embedder),
123
  ('cluster', KMeans(n_clusters = n_clusters, n_init = n_init, max_iter = max_iter)),
124
  ])
125
-
 
 
 
126
 
127
  if task == "Classification":
128
- text_clf.fit(df[column_name], df[labels_column_name])
 
129
  else:
130
  kmeans = cluster_clf.fit(df[column_name])
131
  labels = list(cluster_clf['cluster'].labels_)
132
- text_clf.fit(df[column_name], labels)
 
133
  st.write("Generated Clusters for each example")
134
  st.write(labels)
135
 
@@ -190,8 +195,8 @@ html = format_as_html(t_pred)
190
 
191
  form_html = st.sidebar.form("html_size_form")
192
  form_html.header("Model Explanation Display Settings")
193
- output_width = form_html.number_input("Enter the number of pixels for width of model explanation html display", value = 4000)
194
- output_height = form_html.number_input("Enter the number of pixels for height of model explanation html display", value = 4000)
195
  form_html.form_submit_button("Submit")
196
  st.caption("Scroll to see the full output!")
197
  components.html(html, width = output_width, height = output_height, scrolling = True)
 
122
  ('vect', embedder),
123
  ('cluster', KMeans(n_clusters = n_clusters, n_init = n_init, max_iter = max_iter)),
124
  ])
125
+
126
+ @st.cache
127
+ def fit_text_clf(X, y):
128
+ text_clf.fit(X, y)
129
 
130
  if task == "Classification":
131
+ #text_clf.fit(df[column_name], df[labels_column_name])
132
+ fit_text_clf(df[column_name], df[labels_column_name])
133
  else:
134
  kmeans = cluster_clf.fit(df[column_name])
135
  labels = list(cluster_clf['cluster'].labels_)
136
+ #text_clf.fit(df[column_name], labels)
137
+ fit_text_clf(df[column_name], labels)
138
  st.write("Generated Clusters for each example")
139
  st.write(labels)
140
 
 
195
 
196
  form_html = st.sidebar.form("html_size_form")
197
  form_html.header("Model Explanation Display Settings")
198
+ output_width = form_html.number_input("Enter the number of pixels for width of model explanation html display", value = 2000)
199
+ output_height = form_html.number_input("Enter the number of pixels for height of model explanation html display", value = 2000)
200
  form_html.form_submit_button("Submit")
201
  st.caption("Scroll to see the full output!")
202
  components.html(html, width = output_width, height = output_height, scrolling = True)