binning.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:expan 作者: zalando 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号