Skip to content

Commit e0f67cf

Browse files
author
Matthew Stidham
committed
Fix undefined variables issue
Signed-off-by: Matthew Stidham <[email protected]>
1 parent cc2dc22 commit e0f67cf

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

autoviz/AutoViz_Holo.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from holoviews.ipython import display
2+
13
from autoviz.AutoViz_Utils import classify_print_vars, find_remove_duplicates
24
import numpy as np
35
import pandas as pd

autoviz/AutoViz_Utils.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ def draw_pivot_tables(dft, problem_type, verbose, chart_format, depVar='', mk_di
218218
def draw_pivot_tables_old(dft, verbose, chart_format, depVar='', mk_dir=None):
219219
#### Finally I have fixed the bugs in pivot tables due to "category" dtypes in data ##############
220220
plot_name = 'Bar_Plots_Pivots'
221+
cats = [i for i in dft.loc[:, dft.nunique() <= 15]]
221222
cats = copy.deepcopy(cats)
222223
cats = list(set(cats))
223224
dft = copy.deepcopy(dft)
@@ -226,8 +227,8 @@ def draw_pivot_tables_old(dft, verbose, chart_format, depVar='', mk_dir=None):
226227
# colormaps = ['summer', 'rainbow','viridis','inferno','magma','jet','plasma']
227228
# colormaps = ['Purples','Oranges','Reds','YlOrBr',
228229
# 'YlOrRd','OrRd','PuRd','RdPu','BuPu',]
229-
N = len(cats)
230-
if N == 0:
230+
len_cats = len(cats)
231+
if len_cats == 0:
231232
print('No categorical or boolean vars in data set. Hence no pivot plots...')
232233
return None
233234
#### You can set the number of subplots per row and the number of categories to display here cols = 2
@@ -236,17 +237,17 @@ def draw_pivot_tables_old(dft, verbose, chart_format, depVar='', mk_dir=None):
236237
height_size = 5
237238
stringlimit = 20
238239
combos = combinations(cats, 2)
239-
N = len(cats)
240+
len_cats = len(cats)
240241
sns.set_palette("Set1")
241-
if N <= 1:
242+
if len_cats <= 1:
242243
### if there are not many categorical variables, there is nothing to plot
243244
return imgdata_list
244-
if len(nums) == 0:
245+
if len(cats) == 0:
245246
### if there are no numeric variables, there is nothing to plot
246247
return imgdata_list
247248
if depVar is not None or not depVar == '' or not depVar == []:
248249
########### This works equally well for classification as well as Regression ###
249-
noplots = int((N ** 2 - N) / 2)
250+
noplots = int((len_cats ** 2 - len_cats) / 2)
250251
dicti = {}
251252
counter = 1
252253
cols = 2
@@ -1247,8 +1248,7 @@ def catscatter(data, colx, coly, ax, ratio=10):
12471248

12481249

12491250
############################################################################
1250-
def draw_catscatterplots(dft, cats, verbose,
1251-
chart_format, mk_dir=None):
1251+
def draw_catscatterplots(dft, cats, verbose, chart_format, mk_dir=None):
12521252
"""
12531253
The function draws catscatter plots for pairs of categorical variables in a data frame.
12541254
A catscatter plot is a type of scatter plot that shows the frequency of each combination
@@ -1266,6 +1266,7 @@ def draw_catscatterplots(dft, cats, verbose,
12661266
"""
12671267
imgdata_list = list()
12681268
cat_len = len(cats)
1269+
plot_name = "catscatter plot"
12691270
if len(cats) == 0:
12701271
#### If there are no categorical variables, nothing to plot here ######
12711272
return imgdata_list
@@ -1680,7 +1681,7 @@ def classify_print_vars(filename: str or pd.DataFrame, sep, max_rows_analyzed, m
16801681
print('Could not find given target var in data set. Please check input')
16811682
### return the data frame as is ############
16821683
return (dfte, depVar, id_cols, bool_vars, categorical_vars, continuous_vars, discrete_string_vars,
1683-
date_vars, classes, problem_type, cols_list)
1684+
date_vars)
16841685
cols_list = list_difference(list(dft), depVar)
16851686
if dft[depVar].dtype == object:
16861687
classes = dft[depVar].unique().tolist()

0 commit comments

Comments
 (0)