Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -182,96 +182,42 @@ class Search:
|
|
182 |
|
183 |
import matplotlib.pyplot as plt
|
184 |
|
185 |
-
def plot_pie_chart(
|
186 |
-
|
187 |
-
|
188 |
-
similarities = list(category_similarity_scores.values())
|
189 |
-
normalized_similarities = [sim / sum(similarities) for sim in similarities]
|
190 |
-
|
191 |
-
fig, ax = plt.subplots()
|
192 |
-
ax.pie(normalized_similarities, labels=categories, autopct="%1.11f%%", startangle=90)
|
193 |
-
ax.axis('equal') # Equal aspect ratio ensures the pie chart is circular.
|
194 |
-
plt.show()
|
195 |
-
|
196 |
-
|
197 |
|
|
|
198 |
|
199 |
-
|
200 |
-
def plot_piechart(sorted_cosine_scores_items):
|
201 |
-
sorted_cosine_scores = np.array([
|
202 |
-
sorted_cosine_scores_items[index][1]
|
203 |
-
for index in range(len(sorted_cosine_scores_items))
|
204 |
-
]
|
205 |
-
)
|
206 |
-
categories = st.session_state.categories.split(" ")
|
207 |
-
categories_sorted = [
|
208 |
-
categories[sorted_cosine_scores_items[index][0]]
|
209 |
-
for index in range(len(sorted_cosine_scores_items))
|
210 |
-
]
|
211 |
fig, ax = plt.subplots()
|
212 |
-
ax.pie(
|
213 |
-
|
|
|
|
|
|
|
214 |
|
215 |
|
216 |
def plot_piechart_helper(sorted_cosine_scores_items):
|
217 |
-
sorted_cosine_scores = np.array(
|
218 |
-
|
219 |
-
|
220 |
-
for index in range(len(sorted_cosine_scores_items))
|
221 |
-
]
|
222 |
-
)
|
223 |
-
categories = st.session_state.categories.split(" ")
|
224 |
-
categories_sorted = [
|
225 |
-
categories[sorted_cosine_scores_items[index][0]]
|
226 |
-
for index in range(len(sorted_cosine_scores_items))
|
227 |
-
]
|
228 |
fig, ax = plt.subplots(figsize=(3, 3))
|
229 |
my_explode = np.zeros(len(categories_sorted))
|
230 |
my_explode[0] = 0.2
|
231 |
if len(categories_sorted) == 3:
|
232 |
-
my_explode[1] = 0.1
|
233 |
elif len(categories_sorted) > 3:
|
234 |
my_explode[2] = 0.05
|
|
|
235 |
ax.pie(
|
236 |
sorted_cosine_scores,
|
237 |
labels=categories_sorted,
|
238 |
-
autopct="%1.
|
239 |
explode=my_explode,
|
240 |
)
|
241 |
|
242 |
return fig
|
243 |
|
244 |
|
245 |
-
def plot_piecharts(sorted_cosine_scores_models):
|
246 |
-
scores_list = []
|
247 |
-
categories = st.session_state.categories.split(" ")
|
248 |
-
index = 0
|
249 |
-
for model in sorted_cosine_scores_models:
|
250 |
-
scores_list.append(sorted_cosine_scores_models[model])
|
251 |
-
# scores_list[index] = np.array([scores_list[index][ind2][1] for ind2 in range(len(scores_list[index]))])
|
252 |
-
index += 1
|
253 |
-
|
254 |
-
if len(sorted_cosine_scores_models) == 2:
|
255 |
-
fig, (ax1, ax2) = plt.subplots(2)
|
256 |
-
|
257 |
-
categories_sorted = [
|
258 |
-
categories[scores_list[0][index][0]] for index in range(len(scores_list[0]))
|
259 |
-
]
|
260 |
-
sorted_scores = np.array(
|
261 |
-
[scores_list[0][index][1] for index in range(len(scores_list[0]))]
|
262 |
-
)
|
263 |
-
ax1.pie(sorted_scores, labels=categories_sorted, autopct="%1.1f%%")
|
264 |
-
|
265 |
-
categories_sorted = [
|
266 |
-
categories[scores_list[1][index][0]] for index in range(len(scores_list[1]))
|
267 |
-
]
|
268 |
-
sorted_scores = np.array(
|
269 |
-
[scores_list[1][index][1] for index in range(len(scores_list[1]))]
|
270 |
-
)
|
271 |
-
ax2.pie(sorted_scores, labels=categories_sorted, autopct="%1.1f%%")
|
272 |
-
|
273 |
-
st.pyplot(fig)
|
274 |
-
|
275 |
|
276 |
def plot_alatirchart(sorted_cosine_scores_models):
|
277 |
models = list(sorted_cosine_scores_models.keys())
|
@@ -296,7 +242,9 @@ if 'text_search' not in st.session_state:
|
|
296 |
|
297 |
embeddings_model = Embeddings()
|
298 |
|
299 |
-
model_type =
|
|
|
|
|
300 |
|
301 |
|
302 |
st.title("in in-class coding practice1 Demo")
|
|
|
182 |
|
183 |
import matplotlib.pyplot as plt
|
184 |
|
185 |
+
def plot_pie_chart(category_simiarity_scores):
|
186 |
+
categories = list(category_simiarity_scores.keys())
|
187 |
+
cur_similarities = list(category_simiarity_scores.values())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
+
similarities = [similar / sum(cur_similarities) for similar in cur_similarities]
|
190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
fig, ax = plt.subplots()
|
192 |
+
ax.pie(similarities, labels=categories,
|
193 |
+
autopct="%1.11f%%",
|
194 |
+
startangle=90)
|
195 |
+
ax.axis('equal')
|
196 |
+
plt.show()
|
197 |
|
198 |
|
199 |
def plot_piechart_helper(sorted_cosine_scores_items):
|
200 |
+
sorted_cosine_scores = np.array(list(sorted_cosine_scores_items.values()))
|
201 |
+
categories_sorted = list(sorted_cosine_scores_items.keys())
|
202 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
fig, ax = plt.subplots(figsize=(3, 3))
|
204 |
my_explode = np.zeros(len(categories_sorted))
|
205 |
my_explode[0] = 0.2
|
206 |
if len(categories_sorted) == 3:
|
207 |
+
my_explode[1] = 0.1
|
208 |
elif len(categories_sorted) > 3:
|
209 |
my_explode[2] = 0.05
|
210 |
+
|
211 |
ax.pie(
|
212 |
sorted_cosine_scores,
|
213 |
labels=categories_sorted,
|
214 |
+
autopct="%1.11f%%",
|
215 |
explode=my_explode,
|
216 |
)
|
217 |
|
218 |
return fig
|
219 |
|
220 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
def plot_alatirchart(sorted_cosine_scores_models):
|
223 |
models = list(sorted_cosine_scores_models.keys())
|
|
|
242 |
|
243 |
embeddings_model = Embeddings()
|
244 |
|
245 |
+
model_type = "50d"
|
246 |
+
st.sidebar.write("Model Type: 50d")
|
247 |
+
|
248 |
|
249 |
|
250 |
st.title("in in-class coding practice1 Demo")
|