MCPcopy
hub / github.com/AutoViML/AutoViz / draw_violinplot

Function draw_violinplot

autoviz/AutoViz_Utils.py:963–1048  ·  view source on GitHub ↗
(df, dep, nums, verbose, chart_format, modeltype='Regression', mk_dir=None)

Source from the content-addressed store, hash-verified

961##### Standardize all the variables in One step. But be careful !
962#### All the variables must be numeric for this to work !!
963def draw_violinplot(df, dep, nums, verbose, chart_format, modeltype='Regression', mk_dir=None):
964 plot_name = 'Violin_Plots'
965 df = df[:]
966 number_in_each_row = 8
967 imgdata_list = list()
968 width_size = 15
969 height_size = 4
970 if type(dep) == str:
971 othernums = [x for x in nums if x not in [dep]]
972 else:
973 othernums = [x for x in nums if x not in dep]
974 # sns.color_palette("Set1")
975
976 sns.set_palette("Set1")
977 if modeltype == 'Regression' or dep is None or dep == '':
978 image_count = 0
979 if modeltype == 'Regression':
980 nums = nums + [dep]
981 numb = len(nums)
982 if numb > number_in_each_row:
983 rows = int((numb / number_in_each_row) + .99)
984 else:
985 rows = 1
986 plot_index = 0
987 for row in range(rows):
988 plot_index += 1
989 first_10 = number_in_each_row * row
990 next_10 = first_10 + number_in_each_row
991 num_10 = nums[first_10:next_10]
992 df10 = df[num_10]
993 df_norm = (df10 - df10.mean()) / df10.std()
994 if numb <= 5:
995 fig = plt.figure(
996 figsize=(min(width_size * len(num_10), width_size), min(height_size, height_size * len(num_10))))
997 else:
998 fig = plt.figure(
999 figsize=(min(width_size * len(num_10), width_size), min(height_size, height_size * len(num_10))))
1000 ax = fig.gca()
1001 # ax.set_xticklabels (df.columns, tolist(), size=10)
1002 #### Don't change this line since it works to best now Dec 20, 2023 #####
1003 sns.violinplot(data=df_norm, orient='v', scale='width',
1004 linewidth=3, ax=ax, inner='box')
1005 fig.suptitle('Violin Plot of all Continuous Variables', fontsize=15)
1006 fig.tight_layout()
1007 if verbose <= 1:
1008 plt.show()
1009 if verbose == 2:
1010 additional = '_' + str(plot_index) + '_'
1011 imgdata_list.append(save_image_data(fig, chart_format,
1012 plot_name, mk_dir, additional))
1013 image_count += 1
1014 else:
1015 plot_name = "Box_Plots"
1016 ###### This is for Classification problems only ##########################
1017 image_count = 0
1018 ######################### Add Box plots here ##################################
1019 # Styling...
1020 if len(othernums) >= 1:

Callers 1

AutoViz_MainMethod · 0.90

Calls 1

save_image_dataFunction · 0.85

Tested by

no test coverage detected