-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
747 lines (673 loc) · 25.5 KB
/
app.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
import tkinter
import customtkinter as ctk
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
import pickle
import numpy as np
from pathlib import Path
class App(ttk.Window):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.title(
'Individualized Probability Calculator for Future Clozapine Use'
)
self.geometry('1000x600')
self.resizable(False, False)
# notebook with tabs
self.notebook = ttk.Notebook(master=self, bootstyle='dark')
self.notebook.grid(row=0, column=0, rowspan=7, sticky=NSEW)
tab1 = ttk.Frame(self.notebook, width=400, height=400)
tab1.pack(fill=Y, expand=Y)
self.notebook.add(tab1, text='Baseline')
self.build_tab1(tab1)
tab2 = ttk.Frame(self.notebook)
tab2.pack(fill=Y, expand=Y)
self.notebook.add(tab2, text='12-month')
self.build_tab2(tab2)
tab3 = ttk.Frame(self.notebook)
tab3.pack(fill=Y, expand=Y)
self.notebook.add(tab3, text='24-month')
self.build_tab3(tab3)
tab4 = ttk.Frame(self.notebook)
tab4.pack(fill=Y, expand=Y)
self.notebook.add(tab4, text='36-month')
self.build_tab4(tab4)
# ====
action_frame = ttk.Frame(self)
action_frame.grid(row=7, column=0)
press_label = ttk.Label(
master=action_frame,
text='Please press the buttom to calculate',
font=('Helvetica bold', 16),
width=35
)
press_label.grid(row=0, column=0, pady=(15, 0))
press_label2 = ctk.CTkButton(
master=action_frame,
width=50,
text='Calculate',
command=self.calculate_prob
)
press_label2.grid(row=0, column=1, padx=(
15, 15), pady=(15, 0), sticky='EW')
self.meter = ttk.Meter(
metersize=500,
padding=5,
amounttotal=60,
amountused=0,
stepsize=0.5,
metertype='semi',
subtext='Predicted Probability',
textright='%',
meterthickness=30,
interactive=FALSE,
textfont='-size 36',
subtextfont='-size 18',
bootstyle='danger'
)
self.meter.grid(row=0, column=1, rowspan=3,
sticky=NSEW, padx=(80, 0), pady=50)
def build_tab1(self, tab):
# define the input
lb1 = ttk.Label(
master=tab,
text='1. Age at first service contact',
font=('Helvetica Neuw', 14),
width=35
)
lb1.grid(row=0, column=0, padx=5, pady=5, ipadx=5, ipady=5, sticky='W')
self.lb1_input = ttk.Entry(tab, width=10)
self.lb1_input.grid(row=0, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb2 = ttk.Label(
master=tab,
text='2. Is schizophrenia diagnosis?',
font=('Helvetica Neuw', 14),
width=35
)
lb2.grid(row=1, column=0, padx=5, pady=5, ipadx=5, ipady=5, sticky='W')
self.lb2_options = ttk.StringVar(tab)
self.lb2_options.set('Yes') # default value
lb2_om = ttk.OptionMenu(
tab, self.lb2_options, self.lb2_options.get(), 'Yes', 'No')
lb2_om.grid(row=1, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb3 = ttk.Label(
master=tab,
text='3. Age of illness onset',
font=('Helvetica Neuw', 14),
width=35
)
lb3.grid(row=2, column=0, padx=5, pady=5, ipadx=5, ipady=5, sticky='W')
self.lb3_input = ttk.Entry(tab, width=10)
self.lb3_input.grid(row=2, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb4 = ttk.Label(
master=tab,
text='4. Days of untreated psychosis',
font=('Helvetica Neuw', 14),
width=35
)
lb4.grid(row=3, column=0, padx=5, pady=5, ipadx=5, ipady=5, sticky='W')
self.lb4_input = ttk.Entry(tab, width=10)
self.lb4_input.grid(row=3, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb5 = ttk.Label(
master=tab,
text='5. Years of education',
font=('Helvetica Neuw', 14),
width=35
)
lb5.grid(row=4, column=0, padx=5, pady=5, ipadx=5, ipady=5, sticky='W')
self.lb5_input = ttk.Entry(tab, width=10)
self.lb5_input.grid(row=4, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb6 = ttk.Label(
master=tab,
text='6. CGI depressive score',
font=('Helvetica Neuw', 14),
width=35
)
lb6.grid(row=5, column=0, padx=5, pady=5, ipadx=5, ipady=5, sticky='W')
self.lb6_input = ttk.Entry(tab, width=10)
self.lb6_input.grid(row=5, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb7 = ttk.Label(
master=tab,
text='7. Hospitalized days during first episode',
font=('Helvetica Neuw', 14),
width=35
)
lb7.grid(row=6, column=0, padx=5, pady=5, ipadx=5, ipady=5, sticky='W')
self.lb7_input = ttk.Entry(tab, width=10)
self.lb7_input.grid(row=6, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb8 = ttk.Label(
master=tab,
text='8. Mean of defined daily dose',
font=('Helvetica Neuw', 14),
width=35
)
lb8.grid(row=7, column=0, padx=5, pady=5, ipadx=5, ipady=5, sticky='W')
self.lb8_input = ttk.Entry(tab, width=10)
self.lb8_input.grid(row=7, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb9 = ttk.Label(
master=tab,
text='9. SOFAS score',
font=('Helvetica Neuw', 14),
width=35
)
lb9.grid(row=8, column=0, padx=5, pady=5, ipadx=5, ipady=5, sticky='W')
self.lb9_input = ttk.Entry(tab, width=10)
self.lb9_input.grid(row=8, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb10 = ttk.Label(
master=tab,
text='10. Days of first episode',
font=('Helvetica Neuw', 14),
width=35
)
lb10.grid(row=9, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb10_input = ttk.Entry(tab, width=10)
self.lb10_input.grid(row=9, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
def build_tab2(self, tab):
# define the input
lb11 = ttk.Label(
master=tab,
text='1. Age at frist service contact',
font=('Helvetica Neuw', 14),
width=35
)
lb11.grid(row=0, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb11_input = ttk.Entry(tab, width=10)
self.lb11_input.grid(row=-0, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb12 = ttk.Label(
master=tab,
text='2. Is schizophrenia diagnosis?',
font=('Helvetica Neuw', 14),
width=35
)
lb12.grid(row=1, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb12_options = ttk.StringVar(tab)
self.lb12_options.set('Yes') # default value
lb12_om = ttk.OptionMenu(
tab, self.lb12_options, self.lb12_options.get(), 'Yes', 'No')
lb12_om.grid(row=1, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb13 = ttk.Label(
master=tab,
text='3. Age of illness onset',
font=('Helvetica Neuw', 14),
width=35
)
lb13.grid(row=2, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb13_input = ttk.Entry(tab, width=10)
self.lb13_input.grid(row=2, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb14 = ttk.Label(
master=tab,
text='4. Months of relapse',
font=('Helvetica Neuw', 14),
width=35
)
lb14.grid(row=3, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb14_input = ttk.Entry(tab, width=10)
self.lb14_input.grid(row=3, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb15 = ttk.Label(
master=tab,
text='5. Months of anticholinergic',
font=('Helvetica Neuw', 14),
width=35
)
lb15.grid(row=4, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb15_input = ttk.Entry(tab, width=10)
self.lb15_input.grid(row=4, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb16 = ttk.Label(
master=tab,
text='6. Mean of SOFAS scores',
font=('Helvetica Neuw', 14),
width=35
)
lb16.grid(row=5, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb16_input = ttk.Entry(tab, width=10)
self.lb16_input.grid(row=5, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb17 = ttk.Label(
master=tab,
text='7. Receiving early intervention service?',
font=('Helvetica Neuw', 14),
width=35
)
lb17.grid(row=6, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb17_options = ttk.StringVar(tab)
self.lb17_options.set('Yes') # default value
lb17_om = ttk.OptionMenu(
tab, self.lb17_options, self.lb17_options.get(), 'Yes', 'No')
lb17_om.grid(row=6, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb18 = ttk.Label(
master=tab,
text='8. Mean of defined daily dose',
font=('Helvetica Neuw', 14),
width=35
)
lb18.grid(row=7, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb18_input = ttk.Entry(tab, width=10)
self.lb18_input.grid(row=7, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb19 = ttk.Label(
master=tab,
text='9. Days of untreated psychosis',
font=('Helvetica Neuw', 14),
width=35
)
lb19.grid(row=8, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb19_input = ttk.Entry(tab, width=10)
self.lb19_input.grid(row=8, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb20 = ttk.Label(
master=tab,
text='10. Mean of CGI positive symptoms',
font=('Helvetica Neuw', 14),
width=35
)
lb20.grid(row=9, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb20_input = ttk.Entry(tab, width=10)
self.lb20_input.grid(row=9, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
def build_tab3(self, tab):
# define the input
lb21 = ttk.Label(
master=tab,
text='1. Months of relapse',
font=('Helvetica Neuw', 14),
width=35
)
lb21.grid(row=0, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb21_input = ttk.Entry(tab, width=10)
self.lb21_input.grid(row=0, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb22 = ttk.Label(
master=tab,
text='2. Age at first service contact',
font=('Helvetica Neuw', 14),
width=35
)
lb22.grid(row=1, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb22_input = ttk.Entry(tab, width=10)
self.lb22_input.grid(row=1, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb23 = ttk.Label(
master=tab,
text='3. Is schizophrenia diagnosis?',
font=('Helvetica Neuw', 14),
width=35
)
lb23.grid(row=2, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb23_options = ttk.StringVar(tab)
self.lb23_options.set('Yes') # default value
lb23_om = ttk.OptionMenu(
tab, self.lb23_options, self.lb23_options.get(), 'Yes', 'No')
lb23_om.grid(row=2, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb24 = ttk.Label(
master=tab,
text='4. Mean of daily defined dose',
font=('Helvetica Neuw', 14),
width=35
)
lb24.grid(row=3, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb24_input = ttk.Entry(tab, width=10)
self.lb24_input.grid(row=3, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb25 = ttk.Label(
master=tab,
text='5. Months of anticholinergic',
font=('Helvetica Neuw', 14),
width=35
)
lb25.grid(row=4, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb25_input = ttk.Entry(tab, width=10)
self.lb25_input.grid(row=4, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb26 = ttk.Label(
master=tab,
text='6. Mean of CGI positive symptoms',
font=('Helvetica Neuw', 14),
width=35
)
lb26.grid(row=5, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb26_input = ttk.Entry(tab, width=10)
self.lb26_input.grid(row=5, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb27 = ttk.Label(
master=tab,
text='7. Age of illness onset',
font=('Helvetica Neuw', 14),
width=35
)
lb27.grid(row=6, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb27_input = ttk.Entry(tab, width=10)
self.lb27_input.grid(row=6, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb28 = ttk.Label(
master=tab,
text='8. MSSD of CGI positive symptoms',
font=('Helvetica Neuw', 14),
width=35
)
lb28.grid(row=7, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb28_input = ttk.Entry(tab, width=10)
self.lb28_input.grid(row=7, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb29 = ttk.Label(
master=tab,
text='9. Mean of SOFAS scores',
font=('Helvetica Neuw', 14),
width=35
)
lb29.grid(row=8, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb29_input = ttk.Entry(tab, width=10)
self.lb29_input.grid(row=8, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb30 = ttk.Label(
master=tab,
text='10. Months of poly drug uses',
font=('Helvetica Neuw', 14),
width=35
)
lb30.grid(row=9, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb30_input = ttk.Entry(tab, width=10)
self.lb30_input.grid(row=9, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
def build_tab4(self, tab):
# define the input
lb31 = ttk.Label(
master=tab,
text='1. Months of anticholinergic',
font=('Helvetica Neuw', 14),
width=35
)
lb31.grid(row=0, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb31_input = ttk.Entry(tab, width=10)
self.lb31_input.grid(row=0, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb32 = ttk.Label(
master=tab,
text='2. Months of relapse',
font=('Helvetica Neuw', 14),
width=35
)
lb32.grid(row=1, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb32_input = ttk.Entry(tab, width=10)
self.lb32_input.grid(row=1, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb33 = ttk.Label(
master=tab,
text='3. Is schizophrenia diagnosis?',
font=('Helvetica Neuw', 14),
width=35
)
lb33.grid(row=2, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb33_options = ttk.StringVar(tab)
self.lb33_options.set('Yes') # default value
lb33_om = ttk.OptionMenu(
tab, self.lb33_options, self.lb33_options.get(), 'Yes', 'No')
lb33_om.grid(row=2, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb34 = ttk.Label(
master=tab,
text='4. MSSD of CGI postive symptoms',
font=('Helvetica Neuw', 14),
width=35
)
lb34.grid(row=3, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb34_input = ttk.Entry(tab, width=10)
self.lb34_input.grid(row=3, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb35 = ttk.Label(
master=tab,
text='5. Mean of defined daily dose',
font=('Helvetica Neuw', 14),
width=35
)
lb35.grid(row=4, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb35_input = ttk.Entry(tab, width=10)
self.lb35_input.grid(row=4, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb36 = ttk.Label(
master=tab,
text='6. Mean of CGI positive symptom',
font=('Helvetica Neuw', 14),
width=35
)
lb36.grid(row=5, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb36_input = ttk.Entry(tab, width=10)
self.lb36_input.grid(row=5, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb37 = ttk.Label(
master=tab,
text='7. Months of poly drug uses',
font=('Helvetica Neuw', 14),
width=35
)
lb37.grid(row=6, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb37_input = ttk.Entry(tab, width=10)
self.lb37_input.grid(row=6, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb38 = ttk.Label(
master=tab,
text='8. Age at first service contact',
font=('Helvetica Neuw', 14),
width=35
)
lb38.grid(row=7, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb38_input = ttk.Entry(tab, width=10)
self.lb38_input.grid(row=7, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb39 = ttk.Label(
master=tab,
text='9. Months of hospitalization',
font=('Helvetica Neuw', 14),
width=35
)
lb39.grid(row=8, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb39_input = ttk.Entry(tab, width=10)
self.lb39_input.grid(row=8, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
lb40 = ttk.Label(
master=tab,
text='10. Months of substance abuse',
font=('Helvetica Neuw', 14),
width=35
)
lb40.grid(row=9, column=0, padx=5, pady=5,
ipadx=5, ipady=5, sticky='W')
self.lb40_input = ttk.Entry(tab, width=10)
self.lb40_input.grid(row=9, column=1, padx=5, pady=5,
ipadx=5, ipady=5, sticky='EW')
def calculate_prob(self):
output = self.save_data()
output_transformed = self.binary2dummy(output)
output_digits = self.check_digits(output_transformed)
if output_digits == FALSE:
self.meter.configure(amountused=0)
self.meter2.configure(amountused=0)
else:
prob = self.get_prob(output_digits)
self.meter.configure(amountused=prob)
def save_data(self):
selected_page = self.notebook.index(self.notebook.select())
nb1_output = [
self.lb1_input.get(),
self.lb2_options.get(),
self.lb3_input.get(),
self.lb4_input.get(),
self.lb5_input.get(),
self.lb6_input.get(),
self.lb7_input.get(),
self.lb8_input.get(),
self.lb9_input.get(),
self.lb10_input.get()
]
nb2_output = [
self.lb11_input.get(),
self.lb12_options.get(),
self.lb13_input.get(),
self.lb14_input.get(),
self.lb15_input.get(),
self.lb16_input.get(),
self.lb17_options.get(),
self.lb18_input.get(),
self.lb19_input.get(),
self.lb20_input.get()
]
nb3_output = [
self.lb21_input.get(),
self.lb22_input.get(),
self.lb23_options.get(),
self.lb24_input.get(),
self.lb25_input.get(),
self.lb26_input.get(),
self.lb27_input.get(),
self.lb28_input.get(),
self.lb29_input.get(),
self.lb30_input.get()
]
nb4_output = [
self.lb31_input.get(),
self.lb32_input.get(),
self.lb33_options.get(),
self.lb34_input.get(),
self.lb35_input.get(),
self.lb36_input.get(),
self.lb37_input.get(),
self.lb38_input.get(),
self.lb39_input.get(),
self.lb40_input.get()
]
if selected_page == 0:
output = nb1_output
elif selected_page == 1:
output = nb2_output
elif selected_page == 2:
output = nb3_output
elif selected_page == 3:
output = nb4_output
return output
def binary2dummy(self, a_list):
new_list = a_list
for i in range(len(a_list)):
# replace hardik with shardul
if a_list[i] == 'Yes':
new_list[i] = '1'
if a_list[i] == 'No':
new_list[i] = '0'
return new_list
def check_digits(self, a_list):
new_list = list()
for i in range(len(a_list)):
if a_list[i] == '':
self.warning_empty()
new_list = FALSE
break
elif self.isfloat(a_list[i]):
new_list.append(float(a_list[i]))
else:
self.warning_nonnumeric()
new_list = FALSE
break
return new_list
def warning_nonnumeric(self):
top = tkinter.Toplevel(self)
top.geometry('400x100')
top.title('Warning')
ttk.Label(
master=top,
text='Please make sure that all inputs are numeric!',
font=('Helvetica bold', 16)
).place(relx=0.5, rely=0.5, anchor='center')
def warning_empty(self):
top = tkinter.Toplevel(self)
top.geometry('400x100')
top.title('Warning')
ttk.Label(
master=top,
text='Please make sure that all inputs are filled!',
font=('Helvetica bold', 16)
).place(relx=0.5, rely=0.5, anchor='center')
def isfloat(self, num):
try:
float(num)
return True
except ValueError:
return False
def get_prob(self, te_x):
selected_page = self.notebook.index(self.notebook.select())
transformed_te_x = te_x
if selected_page == 0:
filename = Path(
'models', 'baseline_allsubjs_top10_finalized_model.sav')
# log transform DUP days
if transformed_te_x[3] > 0:
transformed_te_x[3] = np.log(transformed_te_x[3])
elif selected_page == 1:
filename = Path(
'models', '12m_allsubjs_top10_finalized_model.sav')
# log transform DUP days
if transformed_te_x[8] > 0:
transformed_te_x[8] = np.log(transformed_te_x[8])
elif selected_page == 2:
filename = Path(
'models', '24m_allsubjs_top10_finalized_model.sav')
elif selected_page == 3:
filename = Path(
'models', '36m_allsubjs_top10_finalized_model.sav')
model = pickle.load(open(filename, 'rb'))
prob = model.predict_proba(np.array([transformed_te_x]))[:, 1]
print(transformed_te_x)
print(prob)
prob_percent = round(prob.item() * 100, 1)
if prob_percent >= 60:
prob_percent = 60
return prob_percent
if __name__ == '__main__':
app = App()
app.mainloop()