def _first_interval(x, n_bins):
"""
Gets the first interval based on the percentiles,
either a closed interval containing the same value multiple times
or a closed-open interval with a different lower and upper bound.
"""
# calculate the percentiles
percentiles = np.linspace(0., 100., n_bins + 1)
bounds = np.percentile(x, q=percentiles, interpolation='higher')
lower = bounds[0]
upper = bounds[1]
if lower == upper:
return lower, upper, True, True
else:
return lower, upper, True, False
#------- private methods for categorical binnings-------#
评论列表
文章目录