bvk1ng commited on
Commit
bab8a75
1 Parent(s): ce24de9

Modified::added Gradio Blocks with Space description

Browse files
Files changed (1) hide show
  1. app.py +34 -12
app.py CHANGED
@@ -33,18 +33,40 @@ def agglomorative_cluster(n_samples: int, n_neighbours: int, n_clusters: int, li
33
 
34
 
35
 
36
-
37
-
38
- demo = gr.Interface(
39
- fn = agglomorative_cluster,
40
- inputs = [gr.Slider(0, 20_000, label="n_samples", info="the number of samples in the data.", step=1),
41
- gr.Slider(0, 30, label="n_neighbours", info="the number of neighbours in the data", step=1),
42
- gr.Dropdown([3, 30], label="n_clusters", info="the number of clusters in the data"),
43
- gr.Dropdown(['average', 'complete', 'ward', 'single'], label="linkage", info="the different types of aggolomorative clustering techniques"),
44
- gr.Checkbox(True, label="connectivity", info="whether to impose a connectivity into the graph")],
45
-
46
- outputs = [gr.Plot(label="Plot")]
47
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  demo.launch()
50
 
 
33
 
34
 
35
 
36
+ with gr.Blocks() as demo:
37
+ gr.Markdown("""
38
+ # Agglomorative Clustering with and without Structure
39
+
40
+ This space is an implementation of the scikit-learn document [Agglomorative clustering with and without structure](https://scikit-learn.org/stable/auto_examples/cluster/plot_agglomerative_clustering.html#sphx-glr-auto-examples-cluster-plot-agglomerative-clustering-py)
41
+ This space shows the effects of imposing **connectivity graph** to capture local structure in the data.
42
+ You can uncheck the checkbox `connectivity` to see the effect on data clustering without **connectivity graph**. There are other parameters in this space
43
+ which you can play with such as `n_samples` (the number of data samples), `n_neighbours` (the number of neighbours), `n_clusters` (the number of clusters) and
44
+ what type of linkage to use for Agglomorative clustering `linkage`.
45
+
46
+ Have fun playing with the tool 🤗
47
+ """)
48
+
49
+ n_samples = gr.Slider(0, 20_000, label="n_samples", info="the number of samples in the data.", step=1)
50
+ n_neighbours = gr.Slider(0, 30, label="n_neighbours", info="the number of neighbours in the data", step=1)
51
+ n_clusters = gr.Slider(3, 30, label="n_clusters", info="the number of clusters in the data", step=2)
52
+ linkage = gr.Dropdown(['average', 'complete', 'ward', 'single'], label="linkage", info="the different types of aggolomorative clustering techniques")
53
+ connectivity = gr.Checkbox(True, label="connectivity", info="whether to impose a connectivity into the graph")
54
+ output = gr.Plot(label="Plot")
55
+
56
+ plot_btn = gr.Button("Plot")
57
+ plot_btn.click(fn=agglomorative_cluster, inputs=[n_samples, n_neighbours, n_clusters, linkage, connectivity],
58
+ outputs=output, api_name="plotcluster")
59
+
60
+ # demo = gr.Interface(
61
+ # fn = agglomorative_cluster,
62
+ # inputs = [gr.Slider(0, 20_000, label="n_samples", info="the number of samples in the data.", step=1),
63
+ # gr.Slider(0, 30, label="n_neighbours", info="the number of neighbours in the data", step=1),
64
+ # gr.Dropdown([3, 30], label="n_clusters", info="the number of clusters in the data"),
65
+ # gr.Dropdown(['average', 'complete', 'ward', 'single'], label="linkage", info="the different types of aggolomorative clustering techniques"),
66
+ # gr.Checkbox(True, label="connectivity", info="whether to impose a connectivity into the graph")],
67
+
68
+ # outputs = [gr.Plot(label="Plot")]
69
+ # )
70
 
71
  demo.launch()
72