bharat-raghunathan commited on
Commit
2d851fe
·
1 Parent(s): 861c542

Update metadata

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -5,6 +5,11 @@ from collections import OrderedDict
5
  from sklearn.datasets import make_classification
6
  from sklearn.ensemble import RandomForestClassifier
7
 
 
 
 
 
 
8
  def do_train(random_state, n_samples, min_estimators, max_estimators):
9
  RANDOM_STATE = random_state
10
 
@@ -96,19 +101,20 @@ with gr.Blocks() as demo:
96
  </div>
97
  ''')
98
  gr.Markdown(model_card)
99
- gr.Markdown("Author: <a href=\"https://huggingface.co/vumichien\">Vu Minh Chien</a>. Based on the example from <a href=\"https://scikit-learn.org/stable/auto_examples/ensemble/plot_gradient_boosting_oob.html#sphx-glr-auto-examples-ensemble-plot-gradient-boosting-oob-py\">scikit-learn</a>")
100
  n_samples = gr.Slider(minimum=500, maximum=5000, step=500, value=500, label="Number of samples")
101
  random_state = gr.Slider(minimum=0, maximum=2000, step=1, value=0, label="Random seed")
102
- min_estimators = gr.Slider(minimum=5, maximum=300, step=5, value=15, label="Minimum Number of trees")
103
- max_estimators = gr.Slider(minimum=min_estimators, maximum=300, step=5, value=150, label="Maximum Number of trees")
104
 
 
105
  with gr.Row():
106
  with gr.Column():
107
  plot = gr.Plot()
108
-
109
  n_samples.change(fn=do_train, inputs=[n_samples, random_state, min_estimators, max_estimators], outputs=[plot])
110
  random_state.change(fn=do_train, inputs=[n_samples, random_state, min_estimators, max_estimators], outputs=[plot])
111
  min_estimators.change(fn=do_train, inputs=[n_samples, random_state, min_estimators, max_estimators], outputs=[plot])
112
  max_estimators.change(fn=do_train, inputs=[n_samples, random_state, min_estimators, max_estimators], outputs=[plot])
113
 
114
- demo.launch()
 
5
  from sklearn.datasets import make_classification
6
  from sklearn.ensemble import RandomForestClassifier
7
 
8
+ def compare(number1, number2):
9
+ if number1 > number2:
10
+ number2 = number1
11
+ return number2
12
+
13
  def do_train(random_state, n_samples, min_estimators, max_estimators):
14
  RANDOM_STATE = random_state
15
 
 
101
  </div>
102
  ''')
103
  gr.Markdown(model_card)
104
+ gr.Markdown("Author: <a href=\"https://scikit-learn.org/stable/auto_examples/ensemble/plot_ensemble_oob.html#sphx-glr-auto-examples-ensemble-plot-ensemble-oob-py\">scikit-learn</a>")
105
  n_samples = gr.Slider(minimum=500, maximum=5000, step=500, value=500, label="Number of samples")
106
  random_state = gr.Slider(minimum=0, maximum=2000, step=1, value=0, label="Random seed")
107
+ min_estimators = gr.Slider(minimum=5, maximum=300, step=5, value=15, label="Minimum number of trees")
108
+ max_estimators = gr.Slider(minimum=5, maximum=300, step=5, value=150, label="Maximum number of trees")
109
 
110
+ min_estimators.change(compare, [min_estimators, max_estimators], max_estimators)
111
  with gr.Row():
112
  with gr.Column():
113
  plot = gr.Plot()
114
+
115
  n_samples.change(fn=do_train, inputs=[n_samples, random_state, min_estimators, max_estimators], outputs=[plot])
116
  random_state.change(fn=do_train, inputs=[n_samples, random_state, min_estimators, max_estimators], outputs=[plot])
117
  min_estimators.change(fn=do_train, inputs=[n_samples, random_state, min_estimators, max_estimators], outputs=[plot])
118
  max_estimators.change(fn=do_train, inputs=[n_samples, random_state, min_estimators, max_estimators], outputs=[plot])
119
 
120
+ demo.queue().launch()