Skip to content

Commit

Permalink
no bin occupancy for too many bins
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixWick committed Oct 16, 2023
1 parent 838c466 commit c01bb1c
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions cyclic_boosting/plots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,28 @@ def _format_groupname_with_type(feature_group, feature_type):
def _plot_one_feature_group(plot_observer, grid_item, feature, binners=None, use_tightlayout=True, plot_yp=True):
if len(feature.feature_group) == 1:
# treatment of one-dimensional features
gs = gridspec.GridSpecFromSubplotSpec(2, 1, subplot_spec=grid_item, height_ratios=[2.5, 0.4])
factor_plot = plt.subplot(gs[0, 0])
plot_factor_1d(
feature,
bin_bounds=get_bin_bounds(binners, feature.feature_group[0]),
link_function=plot_observer.link_function,
plot_yp=plot_yp,
)
plt.subplot(gs[1, 0], sharex=factor_plot)
bin_occupancies = np.bincount(feature.lex_binned_data)
plt.plot(range(len(bin_occupancies)), bin_occupancies)
plt.xticks(size="xx-small", rotation="vertical")
# no bin occupancy plot for too many bins
if len(feature.factors_link) > 400:
plt.subplot(grid_item)
plot_factor_1d(
feature,
bin_bounds=get_bin_bounds(binners, feature.feature_group[0]),
link_function=plot_observer.link_function,
plot_yp=plot_yp,
)
else:
gs = gridspec.GridSpecFromSubplotSpec(2, 1, subplot_spec=grid_item, height_ratios=[2.5, 0.4])
factor_plot = plt.subplot(gs[0, 0])
plot_factor_1d(
feature,
bin_bounds=get_bin_bounds(binners, feature.feature_group[0]),
link_function=plot_observer.link_function,
plot_yp=plot_yp,
)
plt.subplot(gs[1, 0], sharex=factor_plot)
bin_occupancies = np.bincount(feature.lex_binned_data)
plt.plot(range(len(bin_occupancies)), bin_occupancies)
plt.xticks(size="xx-small", rotation="vertical")
plt.grid(True, which="both")

elif len(feature.feature_group) == 2:
Expand Down

0 comments on commit c01bb1c

Please sign in to comment.