databricks-industry-solutions / segmentation

Create advanced customer segments to drive better purchasing predictions based on behaviors. Using sales data, campaigns and promotions systems, this solution helps derive a number of features that capture the behavior of various households. Build useful customer clusters to target with different promos and offers.
https://www.databricks.com/solutions/accelerators/customer-segmentation
Other
6 stars 4 forks source link

TypeError: Image data of dtype object cannot be converted to float #1

Closed dbbnicole closed 1 year ago

dbbnicole commented 1 year ago

Error running notebook 02 with


TypeError Traceback (most recent call last)

in 1 # generate heatmap with Theil's U ----> 2 _ = dython.nominal.associations( 3 features_pd[b_feature_names], 4 nominal_columns='all', 5 #theil_u=True, /local_disk0/.ephemeral_nfs/envs/pythonEnv-d3e80c54-9454-4eb9-b3fa-93e0cda93d95/lib/python3.8/site-packages/dython/nominal.py in associations(dataset, nominal_columns, numerical_columns, mark_columns, nom_nom_assoc, num_num_assoc, nom_num_assoc, symmetric_nom_nom, symmetric_num_num, display_rows, display_columns, hide_rows, hide_columns, cramers_v_bias_correction, nan_strategy, nan_replace_value, ax, figsize, annot, fmt, cmap, sv_color, cbar, vmax, vmin, plot, compute_only, clustering, title, filename, multiprocessing, max_cpu_cores) 775 else 0.0 776 ) --> 777 ax = sns.heatmap( 778 corr, 779 cmap=cmap, /databricks/python/lib/python3.8/site-packages/seaborn/_decorators.py in inner_f(*args, **kwargs) 44 ) 45 kwargs.update({k: arg for k, arg in zip(sig.parameters, args)}) ---> 46 return f(**kwargs) 47 return inner_f 48 /databricks/python/lib/python3.8/site-packages/seaborn/matrix.py in heatmap(data, vmin, vmax, cmap, center, robust, annot, fmt, annot_kws, linewidths, linecolor, cbar, cbar_kws, cbar_ax, square, xticklabels, yticklabels, mask, ax, **kwargs) 546 if square: 547 ax.set_aspect("equal") --> 548 plotter.plot(ax, cbar_ax, kwargs) 549 return ax 550 /databricks/python/lib/python3.8/site-packages/seaborn/matrix.py in plot(self, ax, cax, kws) 296 297 # Draw the heatmap --> 298 mesh = ax.pcolormesh(self.plot_data, cmap=self.cmap, **kws) 299 300 # Set the axis limits /local_disk0/.ephemeral_nfs/envs/pythonEnv-d3e80c54-9454-4eb9-b3fa-93e0cda93d95/lib/python3.8/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs) 1421 def inner(ax, *args, data=None, **kwargs): 1422 if data is None: -> 1423 return func(ax, *map(sanitize_sequence, args), **kwargs) 1424 1425 bound = new_sig.bind(ax, *args, **kwargs) /local_disk0/.ephemeral_nfs/envs/pythonEnv-d3e80c54-9454-4eb9-b3fa-93e0cda93d95/lib/python3.8/site-packages/matplotlib/axes/_axes.py in pcolormesh(self, alpha, norm, cmap, vmin, vmax, shading, antialiased, *args, **kwargs) 6137 kwargs.setdefault('snap', mpl.rcParams['pcolormesh.snap']) 6138 -> 6139 collection = mcoll.QuadMesh( 6140 coords, antialiased=antialiased, shading=shading, 6141 array=C, cmap=cmap, norm=norm, alpha=alpha, **kwargs) /local_disk0/.ephemeral_nfs/envs/pythonEnv-d3e80c54-9454-4eb9-b3fa-93e0cda93d95/lib/python3.8/site-packages/matplotlib/collections.py in __init__(self, *args, **kwargs) 1986 # super init delayed after own init because array kwarg requires 1987 # self._coordinates and self._shading -> 1988 super().__init__(**kwargs) 1989 self.set_mouseover(False) 1990 /local_disk0/.ephemeral_nfs/envs/pythonEnv-d3e80c54-9454-4eb9-b3fa-93e0cda93d95/lib/python3.8/site-packages/matplotlib/_api/deprecation.py in wrapper(*args, **kwargs) 452 "parameter will become keyword-only %(removal)s.", 453 name=name, obj_type=f"parameter of {func.__name__}()") --> 454 return func(*args, **kwargs) 455 456 # Don't modify *func*'s signature, as boilerplate.py needs it. /local_disk0/.ephemeral_nfs/envs/pythonEnv-d3e80c54-9454-4eb9-b3fa-93e0cda93d95/lib/python3.8/site-packages/matplotlib/collections.py in __init__(self, edgecolors, facecolors, linewidths, linestyles, capstyle, joinstyle, antialiaseds, offsets, offset_transform, norm, cmap, pickradius, hatch, urls, zorder, **kwargs) 200 201 self._path_effects = None --> 202 self._internal_update(kwargs) 203 self._paths = None 204 /local_disk0/.ephemeral_nfs/envs/pythonEnv-d3e80c54-9454-4eb9-b3fa-93e0cda93d95/lib/python3.8/site-packages/matplotlib/artist.py in _internal_update(self, kwargs) 1184 The lack of prenormalization is to maintain backcompatibility. 1185 """ -> 1186 return self._update_props( 1187 kwargs, "{cls.__name__}.set() got an unexpected keyword argument " 1188 "{prop_name!r}") /local_disk0/.ephemeral_nfs/envs/pythonEnv-d3e80c54-9454-4eb9-b3fa-93e0cda93d95/lib/python3.8/site-packages/matplotlib/artist.py in _update_props(self, props, errfmt) 1160 raise AttributeError( 1161 errfmt.format(cls=type(self), prop_name=k)) -> 1162 ret.append(func(v)) 1163 if ret: 1164 self.pchanged() /local_disk0/.ephemeral_nfs/envs/pythonEnv-d3e80c54-9454-4eb9-b3fa-93e0cda93d95/lib/python3.8/site-packages/matplotlib/collections.py in set_array(self, A) 2048 f"X ({width}) and/or Y ({height})") 2049 -> 2050 return super().set_array(A) 2051 2052 def get_datalim(self, transData): /local_disk0/.ephemeral_nfs/envs/pythonEnv-d3e80c54-9454-4eb9-b3fa-93e0cda93d95/lib/python3.8/site-packages/matplotlib/cm.py in set_array(self, A) 500 A = cbook.safe_masked_invalid(A, copy=True) 501 if not np.can_cast(A.dtype, float, "same_kind"): --> 502 raise TypeError(f"Image data of dtype {A.dtype} cannot be " 503 "converted to float") 504 TypeError: Image data of dtype object cannot be converted to float
dbbnicole commented 1 year ago

Fixed with https://github.com/databricks-industry-solutions/segmentation/pull/2