rashmi commited on
Commit
7e7a15b
1 Parent(s): e069ab8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +65 -41
app.py CHANGED
@@ -63,7 +63,7 @@ def do_submit(n_points_per_cluster, min_samples, xi, min_cluster_size):
63
  reachability = clust.reachability_[clust.ordering_]
64
  labels = clust.labels_[clust.ordering_]
65
 
66
- plt.figure(figsize=(10, 7))
67
  G = gridspec.GridSpec(2, 3)
68
  ax1 = plt.subplot(G[0, :])
69
  ax2 = plt.subplot(G[1, 0])
@@ -125,47 +125,71 @@ with gr.Blocks(title=title, theme=theme) as demo:
125
  the different clusters of OPTICS’s Xi method can be recovered with different choices of thresholds in DBSCAN."
126
  )
127
 
128
- n_points_per_cluster = gr.Slider(
129
- minimum=200,
130
- maximum=500,
131
- label="Number of points per cluster",
132
- step=50,
133
- value=250,
134
- )
135
- min_samples = gr.Slider(
136
- minimum=10,
137
- maximum=100,
138
- label="OPTICS - Minimum number of samples",
139
- step=5,
140
- value=50,
141
- info="The number of samples in a neighborhood for a point to be considered as a core point.",
142
- )
143
- xi = gr.Slider(
144
- minimum=0,
145
- maximum=0.2,
146
- label="OPTICS - Xi",
147
- step=0.05,
148
- value=0.05,
149
- info="Determines the minimum steepness on the reachability plot that constitutes a cluster boundary. ",
150
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
 
152
- min_cluster_size = gr.Slider(
153
- minimum=0.01,
154
- maximum=0.1,
155
- label="OPTICS - Minimum cluster size",
156
- step=0.01,
157
- value=0.05,
158
- info="Minimum number of samples in an OPTICS cluster, expressed as an absolute number or a fraction of the number of samples (rounded to be at least 2).",
159
- )
160
-
161
- plt_out = gr.Plot()
162
-
163
- sub_btn = gr.Button("Submit")
164
- sub_btn.click(
165
- fn=do_submit,
166
- inputs=[n_points_per_cluster, min_samples, xi, min_cluster_size],
167
- outputs=[plt_out],
168
- )
169
 
170
 
171
  if __name__ == "__main__":
 
63
  reachability = clust.reachability_[clust.ordering_]
64
  labels = clust.labels_[clust.ordering_]
65
 
66
+ plt.figure(figsize=(10, 6))
67
  G = gridspec.GridSpec(2, 3)
68
  ax1 = plt.subplot(G[0, :])
69
  ax2 = plt.subplot(G[1, 0])
 
125
  the different clusters of OPTICS’s Xi method can be recovered with different choices of thresholds in DBSCAN."
126
  )
127
 
128
+ with gr.Row().style(equal_height=True):
129
+ with gr.Column(scale=0.75):
130
+ n_points_per_cluster = gr.Slider(
131
+ minimum=200,
132
+ maximum=500,
133
+ label="Number of points per cluster",
134
+ step=50,
135
+ value=250,
136
+ )
137
+ with gr.Row(visible=False):
138
+ gr.Markdown("##")
139
+
140
+ min_samples = gr.Slider(
141
+ minimum=10,
142
+ maximum=100,
143
+ label="OPTICS - Minimum number of samples",
144
+ step=5,
145
+ value=50,
146
+ info="The number of samples in a neighborhood for a point to be considered as a core point.",
147
+ )
148
+ with gr.Row(visible=False):
149
+ gr.Markdown("##")
150
+
151
+ xi = gr.Slider(
152
+ minimum=0,
153
+ maximum=0.2,
154
+ label="OPTICS - Xi",
155
+ step=0.01,
156
+ value=0.05,
157
+ info="Determines the minimum steepness on the reachability plot that constitutes a cluster boundary. ",
158
+ )
159
+ with gr.Row(visible=False):
160
+ gr.Markdown("##")
161
+ min_cluster_size = gr.Slider(
162
+ minimum=0.01,
163
+ maximum=0.1,
164
+ label="OPTICS - Minimum cluster size",
165
+ step=0.01,
166
+ value=0.05,
167
+ info="Minimum number of samples in an OPTICS cluster, expressed as an absolute number or a fraction of the number of samples (rounded to be at least 2).",
168
+ )
169
+
170
+ plt_out = gr.Plot()
171
+
172
+ n_points_per_cluster.change(
173
+ do_submit,
174
+ inputs=[n_points_per_cluster, min_samples, xi, min_cluster_size],
175
+ outputs=plt_out,
176
+ )
177
+ min_samples.change(
178
+ do_submit,
179
+ inputs=[n_points_per_cluster, min_samples, xi, min_cluster_size],
180
+ outputs=plt_out,
181
+ )
182
+ xi.change(
183
+ do_submit,
184
+ inputs=[n_points_per_cluster, min_samples, xi, min_cluster_size],
185
+ outputs=plt_out,
186
+ )
187
+ min_cluster_size.change(
188
+ do_submit,
189
+ inputs=[n_points_per_cluster, min_samples, xi, min_cluster_size],
190
+ outputs=plt_out,
191
+ )
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
 
195
  if __name__ == "__main__":