@@ -16,9 +16,11 @@ def warn(*args, **kwargs):
16
16
import logging
17
17
logging .getLogger ("param" ).setLevel (logging .ERROR )
18
18
import warnings
19
- #warnings.simplefilter(action='ignore', category=BokehUserWarning)
20
- warnings .filterwarnings ("ignore" )
21
19
from sklearn .exceptions import DataConversionWarning
20
+ warnings .filterwarnings ("ignore" )
21
+ ### These Bokeh warnings are useless => leave them alone for now!
22
+ ### from bokeh.util.warnings import BokehUserWarning
23
+ ## warnings.simplefilter(action='ignore', category=BokehUserWarning)
22
24
warnings .filterwarnings (action = 'ignore' , category = DataConversionWarning )
23
25
####################################################################################
24
26
import matplotlib
@@ -53,7 +55,7 @@ def warn(*args, **kwargs):
53
55
from .classify_method import classify_columns
54
56
##########################################################################################
55
57
def ensure_hvplot_imported ():
56
- global hv , opts , pn , pnw , INLINE , classify_columns
58
+ global hv , opts , pn , pnw , INLINE
57
59
try :
58
60
# Import main modules
59
61
import hvplot .pandas
@@ -211,6 +213,7 @@ def AutoViz_Holo(filename, sep=',', depVar='', dfte=None, header=0, verbose=0,
211
213
ls_objects .append (drawobj3 )
212
214
### kdeplot is the only time you send in ls_objects since it has to be returned with 2 objects ###
213
215
try :
216
+ #### This KDE draws only the distribution of the target variable!
214
217
drawobj4 = draw_kdeplot_hv (dfin , cats , nums , chart_format , problem_type , dep , ls_objects , mk_dir , verbose )
215
218
if not drawobj4 :
216
219
### if it is not blank, then treat it as ls_objects ###
@@ -322,6 +325,8 @@ def draw_kdeplot_hv(dfin, cats, nums, chart_format, problem_type, dep, ls_object
322
325
width_size = 600
323
326
height_size = 400
324
327
hv_all = None
328
+ transparent = 0.5
329
+ color = 'lightblue'
325
330
########################################################################################
326
331
def return_dynamic_objects (dfout , dep , title = 'Distribution of Target variable' ):
327
332
width_size = 600
@@ -332,14 +337,14 @@ def return_dynamic_objects(dfout, dep, title='Distribution of Target variable'):
332
337
height = height_size , width = width_size ,xrotation = 70 )
333
338
drawobj42 = pdf2 .hvplot (kind = 'bar' , color = 'lightgreen' , title = title )
334
339
return (drawobj41 + drawobj42 )
335
-
340
+
336
341
if problem_type .endswith ('Classification' ):
337
342
colors = cycle ('brycgkbyrcmgkbyrcmgkbyrcmgkbyr' )
338
343
dmap = hv .DynamicMap (return_dynamic_objects (dfin , dep , title = 'Percent Distribution of Target variable'
339
344
).opts (shared_axes = False ).opts (title = 'Histogram and KDE of Target = %s' % dep )).opts (
340
345
height = height_size , width = width_size )
341
346
dmap .opts (framewise = True ,axiswise = True ) ## both must be True for your charts to have dynamically varying axes!
342
- hv_all = pn .panel .HoloViews (dmap )#, sizing_mode="stretch_both")
347
+ hv_all = pn .pane .HoloViews (dmap )#, sizing_mode="stretch_both")
343
348
#ls_objects.append(drawobj41)
344
349
#ls_objects.append(drawobj42)
345
350
else :
@@ -349,9 +354,10 @@ def return_dynamic_objects(dfout, dep, title='Distribution of Target variable'):
349
354
### there is no target variable to draw ######
350
355
return ls_objects
351
356
else :
352
- dmap = hv .DynamicMap (return_dynamic_objects (dfin , dep , title = f'Histogram and KDE of Target = { dep } ' )).opts (width = width_size )
353
- dmap .opts (framewise = True ,axiswise = True ) ## both must be True for your charts to have dynamically varying axes!
354
- hv_all = pn .panel .HoloViews (dmap )
357
+ dmap = hv .Distribution (dfin [dep ]).opts (color = color ,
358
+ height = height_size , width = width_size , alpha = transparent ,
359
+ title = 'KDE (Distribution) Plot of Target Variable' )
360
+ hv_all = pn .pane .HoloViews (dmap )
355
361
#ls_objects.append(drawobj41)
356
362
#ls_objects.append(drawobj42)
357
363
#### In this case we are using multiple objects in panel ###
@@ -879,6 +885,7 @@ def draw_violinplot_hv(dft, dep, nums,chart_format, modeltype='Regression',
879
885
drawobjv_list = [] ## this keeps track of the actual values
880
886
drawobj_list = [] ## this keeps track of the names
881
887
counter = 0
888
+ string_size = 10
882
889
for i in range (0 ,df_p .shape [1 ],iter_limit ):
883
890
new_end = i + iter_limit
884
891
#print('i = ',i,"new end = ", new_end)
@@ -890,9 +897,10 @@ def draw_violinplot_hv(dft, dep, nums,chart_format, modeltype='Regression',
890
897
#print(title_string )
891
898
conti = nums [i :new_end ]
892
899
######################### Add Standard Scaling here ##################################
900
+ short_conti = [x [:string_size ] for x in conti ]
893
901
from sklearn .preprocessing import StandardScaler
894
902
SS = StandardScaler ()
895
- data = pd .DataFrame (SS .fit_transform (dft [conti ]),columns = conti )
903
+ data = pd .DataFrame (SS .fit_transform (dft [conti ]),columns = short_conti )
896
904
var_name = 'drawobjv_list[' + str (counter )+ ']'
897
905
drawobj_list .append (var_name )
898
906
drawobjv_list .append (var_name )
0 commit comments