Arranged Slider side-by-side, and changed to on change instead of on button press.
Browse files
app.py
CHANGED
@@ -81,18 +81,23 @@ with gr.Blocks() as demo:
|
|
81 |
|
82 |
This based on the example [here](https://scikit-learn.org/stable/auto_examples/neighbors/plot_nca_dim_reduction.html#sphx-glr-auto-examples-neighbors-plot-nca-dim-reduction-py)
|
83 |
""")
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
with gr.Row():
|
88 |
pca_graph = gr.Plot(label="PCA")
|
89 |
lda_graph = gr.Plot(label="LDA")
|
90 |
nca_graph = gr.Plot(label="NCA")
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
if __name__ == '__main__':
|
98 |
demo.launch()
|
|
|
81 |
|
82 |
This based on the example [here](https://scikit-learn.org/stable/auto_examples/neighbors/plot_nca_dim_reduction.html#sphx-glr-auto-examples-neighbors-plot-nca-dim-reduction-py)
|
83 |
""")
|
84 |
+
with gr.Row():
|
85 |
+
n_neighbors = gr.Slider(2, 10, 3, step=1, label="Number of Neighbors for KNN")
|
86 |
+
random_state = gr.Slider(0, 100, 0, step=1, label="Random State")
|
87 |
with gr.Row():
|
88 |
pca_graph = gr.Plot(label="PCA")
|
89 |
lda_graph = gr.Plot(label="LDA")
|
90 |
nca_graph = gr.Plot(label="NCA")
|
91 |
+
n_neighbors.change(
|
92 |
+
fn=reduce_dimensions,
|
93 |
+
inputs=[n_neighbors, random_state],
|
94 |
+
outputs=[pca_graph, lda_graph, nca_graph]
|
95 |
+
)
|
96 |
+
random_state.change(
|
97 |
+
fn=reduce_dimensions,
|
98 |
+
inputs=[n_neighbors, random_state],
|
99 |
+
outputs=[pca_graph, lda_graph, nca_graph]
|
100 |
+
)
|
101 |
|
102 |
if __name__ == '__main__':
|
103 |
demo.launch()
|