Spaces:
Running
Running
update
Browse files
app.py
CHANGED
@@ -80,23 +80,17 @@ def _(mo, texts, tfm):
|
|
80 |
return (X,)
|
81 |
|
82 |
|
83 |
-
@app.cell
|
84 |
-
def _(PCA, X, mo):
|
85 |
-
with mo.status.spinner(subtitle="Running PCA ...") as _spinner:
|
86 |
-
pca_tfm = PCA()
|
87 |
-
X_tfm = pca_tfm.fit_transform(X)
|
88 |
-
return X_tfm, pca_tfm
|
89 |
-
|
90 |
-
|
91 |
@app.cell
|
92 |
def _(add_label, get_example, mo, neg_label, pos_label):
|
93 |
btn_spam = mo.ui.button(
|
94 |
label=f"Annotate {neg_label.value}",
|
95 |
-
on_click=lambda d: add_label(get_example(), neg_label.value)
|
|
|
96 |
)
|
97 |
btn_ham = mo.ui.button(
|
98 |
label=f"Annotate {pos_label.value}",
|
99 |
-
on_click=lambda d: add_label(get_example(), pos_label.value)
|
|
|
100 |
)
|
101 |
return btn_ham, btn_spam
|
102 |
|
@@ -177,13 +171,11 @@ def _(get_label, mo):
|
|
177 |
|
178 |
|
179 |
@app.cell
|
180 |
-
def _(X,
|
181 |
mo.stop(not form.value["text_input"], "Need a text input to fetch example")
|
182 |
|
183 |
df_emb = (
|
184 |
pl.DataFrame({
|
185 |
-
"x": X_tfm[:, 0],
|
186 |
-
"y": X_tfm[:, 1],
|
187 |
"index": range(X.shape[0]),
|
188 |
"text": texts
|
189 |
}).with_columns(sim=pl.lit(1))
|
|
|
80 |
return (X,)
|
81 |
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
@app.cell
|
84 |
def _(add_label, get_example, mo, neg_label, pos_label):
|
85 |
btn_spam = mo.ui.button(
|
86 |
label=f"Annotate {neg_label.value}",
|
87 |
+
on_click=lambda d: add_label(get_example(), neg_label.value),
|
88 |
+
keyboard_shortcut="Ctrl-L"
|
89 |
)
|
90 |
btn_ham = mo.ui.button(
|
91 |
label=f"Annotate {pos_label.value}",
|
92 |
+
on_click=lambda d: add_label(get_example(), pos_label.value),
|
93 |
+
keyboard_shortcut="Ctrl-K"
|
94 |
)
|
95 |
return btn_ham, btn_spam
|
96 |
|
|
|
171 |
|
172 |
|
173 |
@app.cell
|
174 |
+
def _(X, cosine_similarity, form, mo, pl, texts, tfm):
|
175 |
mo.stop(not form.value["text_input"], "Need a text input to fetch example")
|
176 |
|
177 |
df_emb = (
|
178 |
pl.DataFrame({
|
|
|
|
|
179 |
"index": range(X.shape[0]),
|
180 |
"text": texts
|
181 |
}).with_columns(sim=pl.lit(1))
|