-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.py
66 lines (47 loc) · 1.74 KB
/
functions.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
import pandas
def plot_selected(i):
'''Plotting transaction details i.e. Global/Local view or SHAP values based on dropdown value for selected case'''
clear_output()
lc = lk.LightCurve(flux=case_interest_lc.iloc[i])
if dropdown.value == 'Global View':
printmd(f'### Global View for index: {i}')
show_global_view(lc, i)
if dropdown.value == 'Folded View':
printmd(f'### Folded View for index: {i}')
show_local_view(lc, i)
if dropdown.value == 'SHAP Values':
printmd(f'### SHAP Values for index: {i}')
plot_shap_values(case_interest_lc, i)
def show_global_view(lc, i):
'''Plotting Global View for selected trx'''
lc.plot()
plt.title(f'Global View: {i}', fontsize=16)
show_inline_matplotlib_plots()
def show_local_view(lc, i):
'''Plotting Local View for selected trx'''
lc.fold(period=500).plot()
plt.title(f'Folded View: {i}', fontsize=16)
show_inline_matplotlib_plots()
def plot_shap_values(case_interest_lc, i):
'''Dispalying SHAP value plot for the concerned case'''
plt.figure(figsize=(15,10))
dd = predicted_planets_shaps.iloc[i][1:]
dd = dd.sort_values(ascending=False)
dd[:10].sort_values(ascending=True).plot(kind='barh')
plt.title(f'Shap Value Plot: {i}', fontsize=16)
show_inline_matplotlib_plots()
def next_button_clicked(b):
'''change of global index when next button is toggles'''
with out:
global ix
ix += 1
def prev_button_clicked(b):
'''change of global index when prev button is toggles'''
with out:
global ix
ix -= 1
if ix<0: ix=0
def refresh_button_clicked(b):
with out:
global ix
plot_selected(ix)