【问题标题】:Why doesn't TF Boosted Trees accept numerical data as input?为什么 TF Boosted Trees 不接受数值数据作为输入?
【发布时间】:2018-12-28 17:18:53
【问题描述】:

对于tf.estimator.BoostedTreesClassifier,为什么所有特征列都需要为bucketsizedindicator 列类型?

处理分类器使用的数字和分类数据的最佳方法是什么?

使用数字数据似乎是不可能的。决策树是完美的,因为我什至不需要扩展我的数据。

我的代码如下:

def _parse_record():
    # do something
    return {'feature_1': array[0], 'feature_2': array[190.98]}, label

def input_fn():
    # parse record
    return dataset

feature_cols = []
for _ in numerical_features:
    feature_cols.append(tf.feature_column.numeric_column(key=_))
for _ in cat:
    c = tf.feature_column.categorical_column_with_hash_bucket(key=_, hash_bucket_size=100)
    ind = tf.feature_column.indicator_column(c)
    feature_cols.append(ind)

classifier = tf.estimator.BoostedTreesClassifier(
    feature_columns=feature_cols,
    n_batches_per_layer=100,
    n_trees=100,
)

f=lambda: input_fn()
classifier.train(input_fn=f)

但是,这给了我:

ValueError: 目前只有 bucketized_column 和指标列 支持但得到:_NumericColumn(key='active_time', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None)

【问题讨论】:

    标签: python tensorflow


    【解决方案1】:

    TensorFlow v1.13(sourcecommit)刚刚添加了对 tf.estimator.BoostedTreesClassifier 中数字特征的支持。第一个稳定版本是v1.13.1

    【讨论】:

      猜你喜欢
      • 2019-07-14
      • 2020-06-25
      • 2017-11-17
      • 2013-05-12
      • 2016-03-05
      • 2020-05-13
      • 2020-04-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多