-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhyperguide_button.py
2527 lines (2229 loc) · 166 KB
/
hyperguide_button.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from ipywidgets import Layout, Button, Box, VBox
from IPython.display import display
import warnings
warnings.filterwarnings('ignore', category=FutureWarning)
import pandas as pd
import numpy as np
import os
import sys
pd.options.mode.chained_assignment = None
import os.path
import seaborn as sns
import ipywidgets as widgets
from ipywidgets import interactive
from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import accuracy_score
from sklearn.model_selection import cross_validate
from sklearn.svm import SVC
from sklearn.linear_model import LinearRegression, LogisticRegression
from utils import scatter_plot, scatter_plot_overview, feature_importance, parallel_coordinates
if not sys.warnoptions:
warnings.simplefilter("ignore")
os.environ["PYTHONWARNINGS"] = "ignore"
class Hyper_Parameter_Guide(widgets.DOMWidget):
def __init__(self, X_train, y_train, dataset_name):
self.X_train = X_train
self.y_train = y_train
self.dataset_name = dataset_name
self.current_algo = ''
self.current_hp_box = None
self.visualisation_types = None #do not delete
self.algos_visualisation_type = None #do not delete
self.action = ''
self.test_acc = 0
self.from_training = False
self.from_visualisation = False
self.run_cl = widgets.Button(description='Confirm!', disabled=False, button_style='info',
tooltip='Click to confirm', icon='check')
self.run_reg = widgets.Button(description='Confirm!', disabled=False, button_style='info',
tooltip='Click to confirm', icon='check')
self.run2 = widgets.Button(description='Confirm!', disabled=False, button_style='info',
tooltip='Click to confirm', icon='check')
self.button_plot = widgets.Button(description='Plot!', disabled=False, button_style='info', tooltip='Click to Plot', icon='pencil')
self.go_to_visualisation_button = widgets.Button(description='Go to Visualisation', disabled=False,
button_style='info', tooltip='Click to see more', icon='bar-chart')
self.go_to_training_button_1 = widgets.Button(description='Go to Training', disabled=False,
button_style='info', tooltip='Click to train more', icon='signal')
self.go_to_training_button_2 = widgets.Button(description='Go to Training', disabled=False,
button_style='info', tooltip='Click to train more', icon='signal')
self.algo_action = 2
self.algo_level = 4
self.guidance_level = 6
self.param_level = 8
self.training_level = 10
self.plotting_level = 12
self.classification_algos_visualisation = [
Button(description='Random Forest', layout=Layout(flex='4 1 auto', width='auto')),
Button(description='knn', layout=Layout(flex='4 1 auto', width='auto')),
Button(description='SVM', layout=Layout(flex='4 1 auto', width='auto')),
Button(description='Overall', layout=Layout(flex='4 1 auto', width='auto'))
]
self.regression_algos_visualisation = [
Button(description='Random Forest', layout=Layout(flex='4 1 auto', width='auto')),
Button(description='Linear Regression', layout=Layout(flex='4 1 auto', width='auto')),
Button(description='Logistic Regression', layout=Layout(flex='4 1 auto', width='auto')),
Button(description='Overall', layout=Layout(flex='4 1 auto', width='auto'))
]
self.regression_algos_training = [
Button(description='Random Forest', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='Linear Regression', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='Logistic Regression', layout=Layout(flex='3 1 auto', width='auto'))
]
self.classification_algos_training = [
Button(description='Random Forest', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='knn', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='SVM', layout=Layout(flex='3 1 auto', width='auto'))
]
def init(self):
action_question = widgets.HTML('<h1>What do you want to run?</h1>')
self.actions = [
Button(description='Training', layout=Layout(flex='3 1%', width='auto')),
Button(description='Visualisation', layout=Layout(flex='3 1%', width='auto')) ]
for action in self.actions:
action.on_click(self.show_actions)
self.box_layout = Layout(display='flex', flex_flow='row', aligh_items='stretch', width='100%')
actions_box = Box(children=self.actions, layout=self.box_layout)
self.container=VBox([action_question, actions_box])
display(self.container)
def show_actions(self, button):
for btn in self.actions:
btn.style.button_color = 'lightgray'
button.style.button_color = 'lightblue'
type_question = widgets.HTML('<h2>What task do you want to do?</h2>')
self.container.children = tuple(list(self.container.children)[:self.algo_level] + [type_question])
action_box=Box()
if button.description=='Training':
self.action = 'training'
action_box=self.get_types_training()
elif button.description=='Visualisation':
self.action = 'visualisation'
action_box=self.get_types_visualisation()
self.container.children = tuple(list(self.container.children)[:self.algo_action+1]+[action_box])
def get_types_training(self):
self.from_visualisation = False
self.action = 'training'
self.ml_types = [
Button(description='Classification', layout=Layout(flex='2 1 0%', width='auto')),
Button(description='Regression', layout=Layout(flex='2 1 0%', width='auto'))
]
for training_type in self.ml_types:
training_type.on_click(self.show_types)
return Box(children=self.ml_types, layout=self.box_layout)
def get_types_visualisation(self):
self.from_training = False
self.action = 'visualisation'
self.ml_types = [
Button(description='Classification', layout=Layout(flex='2 1 0%', width='auto')),
Button(description='Regression', layout=Layout(flex='2 1 0%', width='auto'))
]
for training_type in self.ml_types:
training_type.on_click(self.show_types)
return Box(children=self.ml_types, layout=self.box_layout)
def show_types(self, button):
if button.description == 'Go to Training':
self.action = 'training'
self.go_to_training_button_2 = widgets.Button(description='Go to Training', disabled=False,
button_style='info', tooltip='Click to train more', icon='signal')
for btn in self.actions:
if btn.description == 'Training':
btn.style.button_color = 'lightblue'
else:
btn.style.button_color = 'lightgray'
for btn in self.ml_types:
if btn.description == self.alg_type:
btn.style.button_color = 'lightblue'
else:
btn.style.button_color = 'lightgray'
if self.action == 'training':
algo_question = widgets.HTML('<h3>Which {} algorithm do you want to train?</h3>'.format(self.alg_type))
elif self.action == 'visualisation':
algo_question = widgets.HTML('<h3>Which {} algorithm do you want to visualise?</h3>'.format(self.alg_type))
self.container.children = tuple(list(self.container.children)[:self.algo_level] + [algo_question])
if self.alg_type == 'Classification':
self.alg_type = 'Classification'
algo_box = self.get_classification_algos()
if self.alg_type == 'Regression':
self.alg_type = 'Regression'
algo_box = self.get_regression_algos()
self.from_visualisation = False
self.container.children = tuple(list(self.container.children)[:self.algo_level+1] + [algo_box])
else:
for btn in self.ml_types:
btn.style.button_color = 'lightgray'
button.style.button_color = 'lightblue'
if self.action == 'training':
algo_question = widgets.HTML('<h3>Which {} algorithm do you want to train?</h3>'.format(button.description))
elif self.action == 'visualisation':
algo_question = widgets.HTML('<h3>Which {} algorithm do you want to visualise?</h3>'.format(button.description))
self.container.children = tuple(list(self.container.children)[:self.algo_level] + [algo_question])
algo_box = Box()
if button.description == 'Classification':
self.alg_type = 'Classification'
algo_box = self.get_classification_algos()
elif button.description == 'Regression':
self.alg_type = 'Regression'
algo_box = self.get_regression_algos()
self.container.children = tuple(list(self.container.children)[:self.algo_level+1] + [algo_box])
def get_classification_algos(self):
if self.action == 'training':
self.classification_algos_training = [
Button(description='Random Forest', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='knn', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='SVM', layout=Layout(flex='3 1 auto', width='auto'))
]
for algo in self.classification_algos_training:
algo.on_click(self.show_algos)
return Box(children=self.classification_algos_training, layout=self.box_layout)
elif self.action == 'visualisation':
self.classification_algos_visualisation = [
Button(description='Random Forest', layout=Layout(flex='4 1 auto', width='auto')),
Button(description='knn', layout=Layout(flex='4 1 auto', width='auto')),
Button(description='SVM', layout=Layout(flex='4 1 auto', width='auto')),
Button(description='Overall', layout=Layout(flex='4 1 auto', width='auto'))
]
for algo in self.classification_algos_visualisation:
algo.on_click(self.classification_visualisation_types)
return Box(children=self.classification_algos_visualisation, layout=self.box_layout)
def get_regression_algos(self):
if self.action == 'training':
self.regression_algos_training = [
Button(description='Random Forest', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='Linear Regression', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='Logistic Regression', layout=Layout(flex='3 1 auto', width='auto'))
]
for algo in self.regression_algos_training:
algo.on_click(self.show_algos)
return Box(children=self.regression_algos_training, layout=self.box_layout)
elif self.action == 'visualisation':
self.regression_algos_visualisation = [
Button(description='Random Forest', layout=Layout(flex='4 1 auto', width='auto')),
Button(description='Linear Regression', layout=Layout(flex='4 1 auto', width='auto')),
Button(description='Logistic Regression', layout=Layout(flex='4 1 auto', width='auto')),
Button(description='Overall', layout=Layout(flex='4 1 auto', width='auto'))
]
for algo in self.regression_algos_visualisation:
algo.on_click(self.regression_visualisation_types)
return Box(children=self.regression_algos_visualisation, layout=self.box_layout)
def show_algos(self, button):
self.action = 'training'
if button is None:
for btn in self.get_current_algo_btns():
if btn.description == self.current_algo:
btn.style.button_color = 'lightblue'
else:
btn.style.button_color = 'lightgray'
alg = self.current_algo
elif button.description == 'Go to Training':
self.go_to_training_button_1 = widgets.Button(description='Go to Training', disabled=False,
button_style='info', tooltip='Click to train more', icon='signal')
alg = self.algos_visualisation_type
for btn in self.actions:
if btn.description == 'Training':
btn.style.button_color = 'lightblue'
else:
btn.style.button_color = 'lightgray'
for btn in self.ml_types:
if btn.description == self.alg_type:
btn.style.button_color = 'lightblue'
else:
btn.style.button_color = 'lightgray'
if self.alg_type == 'Classification':
algo_box = self.get_classification_algos()
if self.alg_type == 'Regression':
algo_box = self.get_regression_algos()
algo_question = widgets.HTML('<h3>Which {} algorithm do you want to train?</h3>'.format(self.alg_type))
self.container.children = tuple(list(self.container.children)[:self.algo_level] +[algo_question] + [algo_box])
alg = self.current_algo
self.from_visualisation = False
self.show_algos(button=None)
else:
for btn in self.get_current_algo_btns():
btn.style.button_color = 'lightgray'
button.style.button_color = 'lightblue'
alg = button.description
guidance_question = widgets.HTML('<h4>In which mode do you prefer to train {}?</h4>'.format(alg))
self.container.children = tuple(list(self.container.children)[:self.guidance_level] + [guidance_question])
self.guidance_types = [Button(description='Default', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='Supported', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='Profi', layout=Layout(flex='3 1 auto', width='auto'))]
guidance_box = Box(children=self.guidance_types, layout=self.box_layout)
for btn in self.guidance_types:
btn.on_click(self.show_hyperparamters)
self.container.children = tuple(list(self.container.children)[:self.guidance_level+1] + [guidance_box])
def classification_visualisation_types(self, button):
for btn in self.classification_algos_visualisation:
btn.style.button_color = 'lightgray'
button.style.button_color = 'lightblue'
self.algos_visualisation_type = button.description
if self.algos_visualisation_type != "Overall":
self.current_algo = button.description
guidance_question = widgets.HTML('<h4>In which mode do you prefer to visualise {}?</h4>'.format(button.description))
self.container.children = tuple(list(self.container.children)[:self.guidance_level] + [guidance_question])
self.visualisation_types = [Button(description='Hyperparameter Importance Plot', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='Parallel Coordinate Hyperparameter Plot', layout=Layout(flex='3 1 auto', width='auto'))]
visualisation_box = Box(children=self.visualisation_types, layout=self.box_layout)
for btn in self.visualisation_types:
btn.on_click(self.show_visualisation)
self.container.children = tuple(list(self.container.children)[:self.guidance_level+1] + [visualisation_box])
else:
self.show_visualisation(button)
def regression_visualisation_types(self, button):
for btn in self.regression_algos_visualisation:
btn.style.button_color = 'lightgray'
button.style.button_color = 'lightblue'
self.algos_visualisation_type = button.description
if self.algos_visualisation_type != "Overall":
self.current_algo = button.description
guidance_question = widgets.HTML('<h4>In which mode do you prefer to visualise {}?</h4>'.format(button.description))
self.container.children = tuple(list(self.container.children)[:self.guidance_level] + [guidance_question])
self.visualisation_types = [Button(description='Hyperparameter Importance Plot', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='Parallel Coordinate Hyperparameter Plot', layout=Layout(flex='3 1 auto', width='auto'))]
visualisation_box = Box(children=self.visualisation_types, layout=self.box_layout)
for btn in self.visualisation_types:
btn.on_click(self.show_visualisation)
self.container.children = tuple(list(self.container.children)[:self.guidance_level+1] + [visualisation_box])
else:
self.show_visualisation(button)
def scatter_plot_overview_helper(self, button):
first = int(self.chosen_parameters.children[0].value)
second = int(self.chosen_parameters.children[1].value)
third = int(self.chosen_parameters.children[2].value)
n_chosen= first+second+third
if n_chosen != 2:
self.container.children = tuple(list(self.container.children)[:self.guidance_level+3] +
[widgets.HTML('<h4>Not two selected. Please select 2!</h4>')])
else:
fig_widget = scatter_plot_overview(self.dataset_name, self.alg_type, first, second, third)
self.container.children = tuple(list(self.container.children)[:self.guidance_level+3] +
fig_widget+ [self.go_to_training_button_2])
self.from_visualisation = True
self.go_to_training_button_2.on_click(self.show_types)
def show_visualisation(self, button):
self.action = 'visualisation'
if self.visualisation_types is not None and self.algos_visualisation_type != "Overall":
for btn in self.visualisation_types:
btn.style.button_color = 'lightgray'
button.style.button_color = 'lightblue'
if button.description == "Overall" or button.description == 'Go to Visualisation':
if button.description == 'Go to Visualisation':
for btn in self.actions:
if btn.description == 'Visualisation':
btn.style.button_color = 'lightblue'
else:
btn.style.button_color = 'lightgray'
for btn in self.ml_types:
if btn.description == self.alg_type:
btn.style.button_color = 'lightblue'
else:
btn.style.button_color = 'lightgray'
if self.alg_type == 'Classification':
algos_visualisation = self.classification_algos_visualisation
else:
algos_visualisation = self.regression_algos_visualisation
algo_question = widgets.HTML('<h3>Which {} algorithm do you want to visualise?</h3>'.format(self.alg_type))
self.container.children = tuple(list(self.container.children)[:self.algo_level]+[algo_question] + [Box(children=algos_visualisation, layout=self.box_layout)])
for btn in algos_visualisation:
if btn.description == 'Overall':
btn.style.button_color = 'lightblue'
else:
btn.style.button_color = 'lightgray'
for algo in algos_visualisation:
if self.alg_type == 'Classification':
algo.on_click(self.classification_visualisation_types)
else:
algo.on_click(self.regression_visualisation_types)
self.from_training = False
guidance_question = widgets.HTML('<h4>Please select two metrics:')
self.container.children = tuple(list(self.container.children)[:self.guidance_level] + [guidance_question])
self.chosen_parameters = self.create_box_scatter_visualisation_choice()
self.container.children = tuple(list(self.container.children)[:self.guidance_level+1] + [self.chosen_parameters])
first = int(self.chosen_parameters.children[0].value)
second = int(self.chosen_parameters.children[1].value)
third = int(self.chosen_parameters.children[2].value)
self.container.children = tuple(list(self.container.children)[:self.guidance_level+2] + [self.run2])
fig_widget = scatter_plot_overview(self.dataset_name, self.alg_type, first, second, third)
self.container.children = tuple(list(self.container.children)[:self.guidance_level+3] +
fig_widget+[self.go_to_training_button_2])
self.run2.on_click(self.scatter_plot_overview_helper)
self.from_visualisation = True
self.go_to_training_button_2.on_click(self.show_types)
elif self.algos_visualisation_type != "Overall" and button.description == 'Hyperparameter Importance Plot' and self.from_training == False:
fig_widget = feature_importance(self.dataset_name, self.algos_visualisation_type, self.alg_type)
self.container.children = tuple(list(self.container.children)[:self.guidance_level+2] + fig_widget+
[self.go_to_training_button_1])
self.from_visualisation = True
self.go_to_training_button_1.on_click(self.show_algos)
elif self.algos_visualisation_type != "Overall" and button.description == 'Parallel Coordinate Hyperparameter Plot':
fig_widget = parallel_coordinates(self.dataset_name, self.algos_visualisation_type, self.alg_type)
self.container.children = tuple(list(self.container.children)[:self.guidance_level+2] + fig_widget +
[self.go_to_training_button_1])
self.from_visualisation = True
self.go_to_training_button_1.on_click(self.show_algos)
def show_hyperparamters(self, button):
for btn in self.guidance_types:
btn.style.button_color = 'lightgray'
button.style.button_color = 'lightblue'
try:
if self.get_active_btn(self.ml_types).description == 'Classification':
self.show_classification_hyperparams(button)
else:
self.show_regression_hyperparams(button)
except:
if self.alg_type == 'Classification':
self.show_classification_hyperparams(button)
else:
self.show_regression_hyperparams(button)
def show_classification_hyperparams(self, button):
try:
if self.get_active_btn(self.classification_algos_training).description == 'Random Forest':
self.show_rf_classification_hyperparams(button)
elif self.get_active_btn(self.classification_algos_training).description == 'knn':
self.show_knn_hyperparams(button)
else:
self.show_svm_params(button)
except:
if self.current_algo == 'Random Forest':
self.show_rf_classification_hyperparams(button)
elif self.current_algo == 'knn':
self.show_knn_hyperparams(button)
else:
self.show_svm_params(button)
def show_regression_hyperparams(self, button):
try:
if self.get_active_btn(self.regression_algos_training).description == 'Random Forest':
self.show_rf_regression_hyperparams(button)
elif self.get_active_btn(self.regression_algos_training).description == 'Linear Regression':
self.show_lin_regression_hyperparams(button)
else:
self.show_log_regression_params(button)
except:
if self.current_algo == 'Random Forest':
self.show_rf_regression_hyperparams(button)
elif self.current_algo == 'Linear Regression':
self.show_lin_regression_hyperparams(button)
else:
self.show_log_regression_params(button)
def show_rf_regression_hyperparams(self, button):
if button.description == 'Default':
self.current_algo = 'reg_rf_def'
self.container.children = tuple(list(self.container.children)[:self.param_level] +
[widgets.HTML("The following hyperparameters will be used for training. Please confirm. <br/>"
"{n_estimators: 100, <br/>criterion: 'squared_error', <br/>max_depth: None, <br/>"
"min_samples_split: 2, <br/>min_samples_leaf: 1, <br/>min_weight_fraction_leaf: 0.0, <br/>"
"max_features: 'auto', <br/>max_leaf_nodes: None, <br/>min_impurity_decrease: 0.0, <br/>"
"bootstrap: True, <br/>oob_score: False, <br/>warm_start: False, <br/>"
"ccp_alpha: 0.0, <br/>max_samples: None}")])
elif button.description == 'Supported':
self.current_algo = 'reg_rf_sup'
self.current_hp_box = self.create_box_reg_rf_sup()
self.container.children = tuple(list(self.container.children)[:self.param_level] + [self.current_hp_box])
elif button.description == 'Profi':
self.current_algo = 'reg_rf_pro'
self.current_hp_box = self.create_box_reg_rf_pro()
self.container.children = tuple(list(self.container.children)[:self.param_level] + [self.current_hp_box])
self.container.children = tuple(list(self.container.children)[:self.param_level+1] + [self.run_reg])
self.run_reg.on_click(self.reg_rf)
def show_rf_classification_hyperparams(self, button):
if button.description == 'Default':
self.current_algo = 'class_rf_def'
self.container.children = tuple(list(self.container.children)[:self.param_level] +
[widgets.HTML("The following hyperparameters will be used for training. Please confirm. <br/>"
"{n_estimators: 100, <br/>criterion: 'gini', <br/>"
"max_depth: None, <br/>min_samples_split: 2, <br/>"
"min_samples_leaf: 1, <br/>min_weight_fraction_leaf: 0.0,<br/>"
"max_features: 'auto', <br/>max_leaf_nodes: None, <br/>"
"min_impurity_decrease: 0.0, <br/>bootstrap: True,<br/>"
"oob_score: False, <br/>warm_start: 'False', <br/>"
"class_weight: None, <br/>ccp_alpha: 0.0, <br/>max_samples: None}")])
elif button.description == 'Supported':
self.current_algo = 'class_rf_sup'
self.current_hp_box = self.create_box_class_rf_sup()
self.container.children = tuple(list(self.container.children)[:self.param_level] + [self.current_hp_box])
elif button.description == 'Profi':
self.current_algo = 'class_rf_pro'
self.current_hp_box = self.create_box_class_rf_pro()
self.container.children = tuple(list(self.container.children)[:self.param_level] + [self.current_hp_box])
self.container.children = tuple(list(self.container.children)[:self.param_level+1] + [self.run_cl])
self.run_cl.on_click(self.class_rf)
def show_lin_regression_hyperparams(self, button):
if button.description == 'Default':
self.current_algo = 'reg_lin_def'
self.container.children = tuple(list(self.container.children)[:self.param_level] + [
widgets.HTML("The following hyperparameters will be used for training. Please confirm. <br/>"
"{fit_intercept: True, <br/>normalize: False, <br/>copy_X: True, <br/>n_jobs: None,"
"<br/>positive: False}")])
elif button.description == 'Supported':
self.current_algo = 'reg_lin_sup'
self.container.children = tuple(list(self.container.children)[:self.param_level] + [
widgets.HTML("The following hyperparameters (the same as default) will be used for training. Please confirm. <br/>"
"{fit_intercept: True, <br/>normalize: False, <br/>copy_X: True, <br/>n_jobs: None},"
"<br/>positive: False")])
elif button.description == 'Profi':
self.current_algo = 'reg_lin_pro'
self.current_hp_box = self.create_box_reg_lin_pro()
self.container.children = tuple(list(self.container.children)[:self.param_level] + [self.current_hp_box])
self.container.children = tuple(list(self.container.children)[:self.param_level + 1] + [self.run_reg])
self.run_reg.on_click(self.reg_lin)
def show_log_regression_params(self, button):
if button.description == 'Default':
self.current_algo = 'reg_log_def'
self.container.children = tuple(list(self.container.children)[:self.param_level] + [
widgets.HTML("The following hyperparameters will be used for training. Please confirm. <br/>"
"{penalty: 'l2', <br/>dual: False, <br/>tol: 0.0001, <br/>C: 1.0, <br/>fit_intercept: True, <br/>"
"intercept_scaling: 1.0, <br/>class_weight: None, <br/>solver: 'lbfgs', <br/>max_iter: 100, <br/>"
"multi_class: 'auto', <br/>warm_start: False, <br/>l1_ratio: None}")])
elif button.description == 'Supported':
self.current_algo = 'reg_log_sup'
self.current_hp_box = self.create_box_reg_log_sup()
self.container.children = tuple(list(self.container.children)[:self.param_level] + [self.current_hp_box])
elif button.description == 'Profi':
self.current_algo = 'reg_log_pro'
self.current_hp_box = self.create_box_reg_log_pro()
self.container.children = tuple(list(self.container.children)[:self.param_level] + [self.current_hp_box])
self.container.children = tuple(list(self.container.children)[:self.param_level + 1] + [self.run_reg])
self.run_reg.on_click(self.reg_log)
def show_knn_hyperparams(self, button):
if button.description == 'Default':
self.current_algo = 'class_knn_def'
self.container.children = tuple(list(self.container.children)[:self.param_level] + [
widgets.HTML("The following hyperparameters will be used for training. Please confirm. <br/>"
"{n_neighbors: 5, <br/>weights: 'uniform', <br/>algorithm: 'auto', <br/>leaf_size: 30, <br/>"
"metric_params: None, <br/>p: 2, <br/>metric: 'minkowski', <br/>n_jobs: None}")])
elif button.description == 'Supported':
self.current_algo = 'class_knn_sup'
self.current_hp_box = self.create_box_class_knn_sup()
self.container.children = tuple(list(self.container.children)[:self.param_level] + [self.current_hp_box])
elif button.description == 'Profi':
self.current_algo = 'class_knn_pro'
self.current_hp_box = self.create_box_class_knn_pro()
self.container.children = tuple(list(self.container.children)[:self.param_level] + [self.current_hp_box])
self.container.children = tuple(list(self.container.children)[:self.param_level + 1] + [self.run_cl])
self.run_cl.on_click(self.class_knn)
def show_svm_params(self, button):
if button.description == 'Default':
self.current_algo = 'class_svm_def'
self.container.children = tuple(list(self.container.children)[:self.param_level] + [
widgets.HTML("The following hyperparameters will be used for training. Please confirm. <br/>"
"{C: 1.0, <br/>kernel: 'rbf', <br/>degree: 3, <br/>gamma: 'scale', <br/>coef0: 0.0, <br/>"
"shrinking: True, <br/>probability: False, <br/>tol: 0.001, <br/>cache_size: 200.0, <br/>"
"class_weight: None, <br/>max_iter: -1, <br/>verbose: False, <br/>"
"decision_function_shape: 'ovr', <br/>break_ties: False, <br/>random_state: None}")])
elif button.description == 'Supported':
self.current_algo = 'class_svm_sup'
self.current_hp_box = self.create_box_class_svm_sup()
self.container.children = tuple(list(self.container.children)[:self.param_level] + [self.current_hp_box])
elif button.description == 'Profi':
self.current_algo = 'class_svm_pro'
self.current_hp_box = self.create_box_class_svm_pro()
self.container.children = tuple(list(self.container.children)[:self.param_level] + [self.current_hp_box])
self.container.children = tuple(list(self.container.children)[:self.param_level + 1] + [self.run_cl])
self.run_cl.on_click(self.class_svm)
def get_active_btn(self, btn_array):
return [btn for btn in btn_array if btn.style.button_color == 'lightblue'][0]
def get_current_algo_btns(self):
if self.from_visualisation == True:
if self.get_active_btn(self.ml_types).description == 'Classification':
self.classification_algos_training = [
Button(description='Random Forest', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='knn', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='SVM', layout=Layout(flex='3 1 auto', width='auto'))
]
return self.classification_algos_training
elif self.get_active_btn(self.ml_types).description == 'Regression':
self.regression_algos_training = [
Button(description='Random Forest', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='Linear Regression', layout=Layout(flex='3 1 auto', width='auto')),
Button(description='Logistic Regression', layout=Layout(flex='3 1 auto', width='auto'))
]
return self.regression_algos_training
elif self.get_active_btn(self.ml_types).description == 'Classification' and self.action == 'training':
return self.classification_algos_training
elif self.get_active_btn(self.ml_types).description == 'Classification' and self.action == 'visualisation':
return self.classification_algos_visualisation
elif self.get_active_btn(self.ml_types).description == 'Regression' and self.action == 'training':
return self.regression_algos_training
elif self.get_active_btn(self.ml_types).description == 'Regression' and self.action == 'visualisation':
return self.regression_algos_visualisation
def create_box_class_knn_sup(self):
n_neighbors = widgets.IntSlider(min=1, max=len(self.X_train) / 2,
value=len(self.X_train) ** (1 / 2),
step=1, description="n-neighbors",
style={'description_width': 'initial'})
def react(slider):
n_neighbors.style.handle_color = 'green' if slider <= len(self.X_train) ** (
1 / 2) + 5 and slider >= (len(self.X_train) ** (1 / 2)) / 2 - 5 else 'red'
box = interactive(react, slider=n_neighbors)
return box
def create_box_class_knn_pro(self):
fields = {
'n-neighbors': ('', 5),
'weights': (['uniform', 'distance'], 'uniform'),
'algorithm': (['auto', 'ball_tree', 'kd_tree', 'brute'], 'auto'),
'leaf size': ('', 30),
'p': ('int', 2),
'metric': ('str', 'minkowski'),
'n_jobs': ('', -1)}
widget = {}
widget['grid'] = widgets.GridspecLayout(1, 2)
vbox_widgets_left = []
vbox_widgets_right = []
for hp_name, hp_tuple in fields.items():
widget_descp = hp_name
layout = widgets.Layout(width='215px')
label = widgets.Label(widget_descp, layout=layout)
if hp_name == 'n-neighbors':
layout = widgets.Layout(width='70%')
text_box = widgets.BoundedIntText(placeholder=hp_tuple[0], value=hp_tuple[1], min=1, max=len(self.X_train), layout=layout, disabled=False)
if hp_name == 'leaf size' or hp_name == 'p' or hp_name == 'n_jobs':
layout = widgets.Layout(width='70%')
text_box = widgets.IntText(placeholder=hp_tuple[0], value=hp_tuple[1], layout=layout, disabled=False)
elif hp_name == 'algorithm' or hp_name == 'weights':
layout = widgets.Layout(width='70%')
text_box = widgets.RadioButtons(options=hp_tuple[0], value=hp_tuple[1], layout=layout, disabled=False)
elif hp_name == 'metric':
layout = widgets.Layout(width='70%')
text_box = widgets.Text(placeholder=hp_tuple[0], value=hp_tuple[1], layout=layout, disabled=False)
widget[hp_name] = widgets.HBox(children=[label, text_box])
if hp_name == 'n-neighbors' or hp_name == 'algorithm' or hp_name == 'p':
vbox_widgets_left.append(widget[hp_name])
else:
vbox_widgets_right.append(widget[hp_name])
widget['grid'][0, 0] = widgets.VBox(children=vbox_widgets_left)
widget['grid'][0, 1] = widgets.VBox(children=vbox_widgets_right)
widget['grid'].grid_gap = '20px'
children = [widget['grid']]
box = widgets.VBox(children=children)
return box
def create_box_reg_lin_pro(self):
fields = {
'fit intercept': (True, ''),
'normalize': (False, ''),
'copy X': (True, ''),
'n_jobs': ('', -1),
'positive': (False, '')}
widget = {}
widget['grid'] = widgets.GridspecLayout(1, 2)
vbox_widgets_left = []
vbox_widgets_right = []
for hp_name, hp_tuple in fields.items():
widget_descp = hp_name
layout = widgets.Layout(width='215px')
label = widgets.Label(widget_descp, layout=layout)
if hp_name == 'n_jobs':
layout = widgets.Layout(width='70%')
text_box = widgets.IntText(placeholder=hp_tuple[0], value=hp_tuple[1], layout=layout, disabled=False)
else:
layout = widgets.Layout(width='70%')
text_box = widgets.Checkbox(value=hp_tuple[0], layout=layout, disabled=False)
widget[hp_name] = widgets.HBox(children=[label, text_box])
if hp_name == 'fit intercept' or hp_name == 'copy X' or hp_name == 'positive':
vbox_widgets_left.append(widget[hp_name])
else:
vbox_widgets_right.append(widget[hp_name])
widget['grid'][0, 0] = widgets.VBox(children=vbox_widgets_left)
widget['grid'][0, 1] = widgets.VBox(children=vbox_widgets_right)
widget['grid'].grid_gap = '20px'
children = [widget['grid']]
box = widgets.VBox(children=children)
return box
def create_box_reg_log_pro(self):
fields = {
'penalty': (['l1', 'l2', 'elasticnet', 'none'], 'l2'),
'dual': (False, ''),
'tol': ('', 0.0001),
'C': ('', 1.0),
'fit intercept': (True, ''),
'intercept scaling': ('', 1.0),
'class weight': (['balanced', None], 'balanced'),
'random state': ('int or None', 'None'),
'solver': (['newton-cg', 'lbfgs', 'liblinear', 'sag', 'saga'], 'lbfgs'),
'max iter': ('', 100),
'multi class': (['auto', 'ovr', 'multinomial'], 'auto'),
'verbose': (False, ''),
'warm start': (False, ''),
'n_jobs': ('int or None', 'None'),
'l1 ration': ('float or None', 'None')}
widget = {}
widget['grid'] = widgets.GridspecLayout(1, 2)
vbox_widgets_left = []
vbox_widgets_right = []
for hp_name, hp_tuple in fields.items():
widget_descp = hp_name
layout = widgets.Layout(width='215px')
label = widgets.Label(widget_descp, layout=layout)
if hp_name == 'max iter' or hp_name == 'n_jobs':
layout = widgets.Layout(width='70%')
text_box = widgets.IntText(placeholder=hp_tuple[0], value=hp_tuple[1], layout=layout, disabled=False)
if hp_name == 'class weight' or hp_name == 'penalty' or hp_name == 'solver' or hp_name == 'multi class':
layout = widgets.Layout(width='70%')
text_box = widgets.RadioButtons(options=hp_tuple[0], layout=layout, disabled=False)
if hp_name == 'random state' or hp_name == 'l1 ration':
layout = widgets.Layout(width='70%')
text_box = widgets.Text(placeholder=hp_tuple[0], value=hp_tuple[1], layout=layout, disabled=False)
if hp_name == 'tol' or hp_name == 'C' or hp_name == 'intercept scaling':
layout = widgets.Layout(width='70%')
text_box = widgets.FloatText(placeholder=hp_tuple[0], value=hp_tuple[1], layout=layout, disabled=False,
style={'description_width': 'initial'})
if hp_name == 'dual' or hp_name == 'fit intercept' or hp_name == 'verbose' or hp_name == 'warm start':
layout = widgets.Layout(width='70%')
text_box = widgets.Checkbox(value=hp_tuple[0], layout=layout, disabled=False)
widget[hp_name] = widgets.HBox(children=[label, text_box])
if hp_name == 'penalty' or hp_name == 'fit intercept' or hp_name == 'class weight' or hp_name == 'solver' or hp_name == 'multi class':
vbox_widgets_left.append(widget[hp_name])
else:
vbox_widgets_right.append(widget[hp_name])
widget['grid'][0, 0] = widgets.VBox(children=vbox_widgets_left)
widget['grid'][0, 1] = widgets.VBox(children=vbox_widgets_right)
widget['grid'].grid_gap = '20px'
children = [widget['grid']]
box = widgets.VBox(children=children)
return box
def create_box_reg_log_sup(self):
penalty = widgets.RadioButtons(options=['none', 'l2'], description="penalty")
c = widgets.RadioButtons(options=[0.001, 0.01, 0.1, 1, 10.0, 100.0, 1000.0], description="C")
box_reg_log_sup = widgets.HBox(children=[penalty, c])
return box_reg_log_sup
def create_box_class_svm_pro(self):
fields = {
'C': ('', 1.0),
'kernel': (['linear','poly','rbf','sigmoid'], 'rbf'),
'degree': ('', 3),
'gamma': ('scale, auto or float', 'scale'),
'coef0': ('', 0.0),
'shrinking': (True, ''),
'probability': (False,''),
'tol': ('', 0.001),
'cache size': ('', 200.0),
'class weight': (['balanced', None], 'balanced'),
'verbose': (False, ''),
'max iter': ('', -1),
'decision function shape': (['ovo','ovr'],'ovr'),
'break ties': (False, ''),
'random state': ('int or None', 'None')}
widget = {}
widget['grid'] = widgets.GridspecLayout(1, 2)
vbox_widgets_left = []
vbox_widgets_right = []
for hp_name, hp_tuple in fields.items():
widget_descp = hp_name
layout = widgets.Layout(width='215px')
label = widgets.Label(widget_descp, layout=layout)
if hp_name == 'degree' or hp_name == 'max iter':
layout = widgets.Layout(width='70%')
text_box = widgets.IntText(placeholder=hp_tuple[0], value = hp_tuple[1], layout=layout, disabled=False)
if hp_name == 'kernel' or hp_name == 'decision function shape' or hp_name == 'class weight':
layout = widgets.Layout(width='70%')
text_box = widgets.RadioButtons(options=hp_tuple[0], value=hp_tuple[1], layout=layout, disabled=False)
if hp_name == 'gamma' or hp_name == 'random state':
layout = widgets.Layout(width='70%')
text_box = widgets.Text(placeholder=hp_tuple[0], value=hp_tuple[1], layout=layout, disabled=False)
if hp_name == 'C' or hp_name == 'coef0' or hp_name == 'tol' or hp_name == 'cache size':
layout = widgets.Layout(width='70%')
text_box = widgets.FloatText(placeholder=hp_tuple[0], value=hp_tuple[1], layout=layout, disabled=False, style = {'description_width': 'initial'})
if hp_name == 'shrinking' or hp_name == 'probability' or hp_name == 'verbose' or hp_name=='break ties':
layout = widgets.Layout(width='70%')
text_box = widgets.Checkbox(value=hp_tuple[0], layout=layout, disabled=False)
widget[hp_name] = widgets.HBox(children=[label, text_box])
if hp_name == 'C' or hp_name == 'degree' or hp_name == 'gamma' or hp_name == 'coef0' or hp_name == 'probability' or hp_name == 'cache size' or hp_name == 'verbose' or hp_name == 'decision function shape':
vbox_widgets_left.append(widget[hp_name])
else:
vbox_widgets_right.append(widget[hp_name])
widget['grid'][0, 0] = widgets.VBox(children=vbox_widgets_left)
widget['grid'][0, 1] = widgets.VBox(children=vbox_widgets_right)
widget['grid'].grid_gap = '20px'
children = [widget['grid']]
box = widgets.VBox(children = children)
return box
def create_box_class_svm_sup(self):
c = widgets.RadioButtons(options=[0.001,0.01,0.1,1.0,10.0,100.0,1000.0], value=1, description="C")
kernel = widgets.RadioButtons(options=['rbf','poly'], value='rbf', description="kernel")
gamma = widgets.RadioButtons(options=['scale',0.001,0.01,0.1,1.0,10.0,100.0,1000.0], value='scale', description="gamma")
box = widgets.HBox(children=[c, kernel, gamma])
return box
def create_box_class_rf_pro(self):
fields = {
'n-estimators': ('', 1),
'criterion': (['gini','entropy'], 'gini'),
'max depth': ('int or None', 'None'),
'min samples split': ('int or float in range (0.0, 1.0]', 0.1),
'min samples leaf': ('int or float in range (0, 0.5]', 0.1),
'min weight fraction leaf': ('float in range [0, 0.5]', 0),
'max features': ('auto, sqrt, log2, int or float','auto'),
'max leaf nodes': ('int or None','None'),
'min impurity decrease': ('', 0) ,
'bootstrap': (True,''),
'oob score': (False,''),
'n_jobs': ('', -1),
'verbose': ('int', 0),
'warm start': (False,''),
'class weight': (['balanced','balanced_subsample',None], 'balanced'),
'ccp alpha': ('', 0),
'max samples': ('float in range (0,1] or None', 'None'),
'random state': ('int or None', 'None')}
widget = {}
widget['grid'] = widgets.GridspecLayout(1, 2)
vbox_widgets_left = []
vbox_widgets_right = []
for hp_name, hp_tuple in fields.items():
widget_descp = hp_name
layout = widgets.Layout(width='215px')
label = widgets.Label(widget_descp, layout=layout)
if hp_name == 'n-estimators' or hp_name == 'n_jobs' or hp_name == 'verbose':
layout = widgets.Layout(width='70%')
text_box = widgets.IntText(placeholder=hp_tuple[0], value = hp_tuple[1], layout=layout, disabled=False)
if hp_name == 'criterion' or hp_name == 'class weight':
layout = widgets.Layout(width='70%')
text_box = widgets.RadioButtons(options=hp_tuple[0], value = hp_tuple[1], layout=layout, disabled=False)
if hp_name == 'max depth' or hp_name == 'max features' or hp_name == 'max leaf nodes' or hp_name == 'max samples' or hp_name == 'random state':
layout = widgets.Layout(width='70%')
text_box = widgets.Text(placeholder=hp_tuple[0], value = hp_tuple[1], layout=layout, disabled=False)
if hp_name == 'min samples split' or hp_name == 'min samples leaf' or hp_name == 'min impurity decrease' or hp_name == 'ccp alpha':
layout = widgets.Layout(width='70%')
text_box = widgets.FloatText(placeholder=hp_tuple[0], value=hp_tuple[1], layout=layout, disabled=False, style = {'description_width': 'initial'})
if hp_name == 'min weight fraction leaf':
layout = widgets.Layout(width='70%')
text_box = widgets.BoundedFloatText(placeholder=hp_tuple[0], value=hp_tuple[1], min=0, max=0.5, step=0.001, layout=layout, disabled=False, style = {'description_width': 'initial'})
if hp_name == 'bootstrap' or hp_name == 'oob score' or hp_name == 'warm start':
layout = widgets.Layout(width='70%')
text_box = widgets.Checkbox(value=hp_tuple[0], layout=layout, disabled=False)
widget[hp_name] = widgets.HBox(children=[label, text_box])
if hp_name == 'n-estimators' or hp_name == 'max depth' or hp_name == 'min samples leaf' or hp_name == 'max features' or hp_name == 'min impurity decrease' or hp_name == 'oob score' or hp_name == 'verbose' or hp_name == 'class weight' or hp_name == 'max samples':
vbox_widgets_left.append(widget[hp_name])
else:
vbox_widgets_right.append(widget[hp_name])
widget['grid'][0, 0] = widgets.VBox(children=vbox_widgets_left)
widget['grid'][0, 1] = widgets.VBox(children=vbox_widgets_right)
widget['grid'].grid_gap = '20px'
children = [widget['grid']]
box = widgets.VBox(children = children)
return box
def create_box_class_rf_sup(self):
n_estimators = widgets.RadioButtons(options=[50, 100, 500, 1000], value=50, description="n-estimators", style={'description_width': 'initial'})
max_depth = widgets.IntSlider(min=1, max=len(self.X_train) * 2, value=len(self.X_train), step=1, description="max depth", style={'description_width': 'initial'})
max_features = widgets.IntSlider(min=1, max=len(self.X_train[0]), value=len(self.X_train[0]) ** 0.5, step=1, description="max features", style={'description_width': 'initial'})
def react_1(slider_1):
max_depth .style.handle_color = 'green' if slider_1 <= len(self.X_train) + len(self.X_train) / 10 and slider_1 >= len(self.X_train) - len(self.X_train) / 10 else 'red'
def react_2(slider_2):
max_features.style.handle_color = 'green' if slider_2 <= len(self.X_train[0]) ** 0.5 + 1 and slider_2 >= len(self.X_train[0]) ** 0.5 - 1 else 'red'
box_1 = interactive(react_1, slider_1=max_depth )
box_2 = interactive(react_2, slider_2=max_features)
box = widgets.HBox(children=[n_estimators, box_1, box_2])
return box
def create_box_reg_rf_pro(self):
fields = {
'n-estimators': ('', 1),
'criterion': (['mse','mae'], 'mse'),
'max depth': ('int or None', 'None'),
'min samples split': ('int or float in range (0.0, 1.0]', 0.1),
'min samples leaf': ('int or float in range (0, 0.5]', 0.1),
'min weight fraction leaf': ('float in range [0, 0.5]', 0),
'max features': ('auto, sqrt, log2, int or float','auto'),
'max leaf nodes': ('int or None', 'None'),
'min impurity decrease': ('', 0.0),
'bootstrap': (True,''),
'oob score': (False,''),
'n_jobs': ('', -1),
'verbose': ('', 0),
'warm start': (False,''),
'ccp alpha': ('', 0.0),
'max samples': ('float in range (0,1] or None', 'None'),
'random state': ('int or None', 'None')
}
widget = {}
widget['grid'] = widgets.GridspecLayout(1, 2)
vbox_widgets_left = []
vbox_widgets_right = []
for hp_name, hp_tuple in fields.items():
widget_descp = hp_name
layout = widgets.Layout(width='215px')
label = widgets.Label(widget_descp, layout=layout)
if hp_name == 'n-estimators' or hp_name == 'n_jobs' or hp_name == 'verbose':
layout = widgets.Layout(width='70%')
text_box = widgets.IntText(placeholder=hp_tuple[0], value = hp_tuple[1], layout=layout, disabled=False)
if hp_name == 'criterion':
layout = widgets.Layout(width='70%')
text_box = widgets.RadioButtons(options=hp_tuple[0], layout=layout, disabled=False)
if hp_name == 'max depth' or hp_name == 'max features' or hp_name == 'max leaf nodes' or hp_name == 'max samples' or hp_name == 'random state':
layout = widgets.Layout(width='70%')
text_box = widgets.Text(placeholder=hp_tuple[0], value = hp_tuple[1], layout=layout, disabled=False)
if hp_name == 'min samples split' or hp_name == 'min samples leaf' or hp_name == 'min impurity decrease' or hp_name == 'ccp alpha':
layout = widgets.Layout(width='70%')
text_box = widgets.FloatText(placeholder=hp_tuple[0], value=hp_tuple[1], layout=layout, disabled=False, style = {'description_width': 'initial'})
if hp_name == 'min weight fraction leaf':
layout = widgets.Layout(width='70%')
text_box = widgets.BoundedFloatText(placeholder=hp_tuple[0], value=hp_tuple[1], min=0, max=0.5, step=0.001, layout=layout, disabled=False, style = {'description_width': 'initial'})
if hp_name == 'bootstrap' or hp_name == 'oob score' or hp_name == 'warm start':
layout = widgets.Layout(width='70%')
text_box = widgets.Checkbox(value=hp_tuple[0], layout=layout, disabled=False)
widget[hp_name] = widgets.HBox(children=[label, text_box])
if hp_name == 'n-estimators' or hp_name == 'max depth' or hp_name == 'min samples split' or hp_name == 'min weight fraction leaf' or hp_name == 'max leaf nodes' or hp_name == 'bootstrap' or hp_name == 'n_jobs' or hp_name == 'warm start' or hp_name == 'max samples':