def __init__(self, bin_type, *repr_args):
"""
Constructor for a bin object.
:param id: identifier (e.g. bin number) of the bin
:param bin_type: "numerical" or "categorical"
:param repr_args: arguments to represent this bin.
args for numerical bin includes lower, upper, lower_closed, upper_closed
args for categorical bin includes a list of categories for this bin.
"""
if bin_type == "numerical" and len(repr_args) != 4:
raise ValueError("args for numerical bin are lower, upper, lower_closed, upper_closed.")
if bin_type == "categorical" and len(repr_args) != 1 and type(repr_args[0]) is not list:
raise ValueError("args for categorical bin is a list of categorical values for this bin.")
self.bin_type = bin_type
if bin_type == "numerical":
self.representation = NumericalRepresentation(*repr_args)
elif bin_type == "categorical":
self.representation = CategoricalRepresentation(*repr_args)
评论列表
文章目录