format.py 文件源码

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

项目:treecat 作者: posterior 项目源码 文件源码
def guess_feature_type(count, values):
    """Guess the type of a feature, given statistics about the feature.

    Args:
        count: Total number of observations of the feature.
        values: A list of uniqe observed values of the feature.

    Returns:
        One of: 'ordinal', 'categorical', or ''
    """
    if len(values) <= 1:
        return ''  # Feature is useless.
    if len(values) <= MAX_CATEGORIES:
        if all(is_small_int(v) for (v, c) in values):
            return ORDINAL
    if len(values) <= min(count / 2, MAX_CATEGORIES):
        return CATEGORICAL
    return ''
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号