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 ''
评论列表
文章目录