简体   繁体   English

为什么 TF Boosted Trees 不接受数字数据作为输入?

[英]Why doesn't TF Boosted Trees accept numerical data as input?

For for tf.estimator.BoostedTreesClassifier , why do all feature columns required to be of type bucketsized or indicator column?对于tf.estimator.BoostedTreesClassifier ,为什么所有特征列都需要是bucketsizedindicator列的类型?

What is the best way to handle both the numerical, and categorical data that is used by the classifier?处理分类器使用的数值和分类数据的最佳方法是什么?

It just seems impossible to work with numerical data.处理数值数据似乎是不可能的。 Decision trees are perfect since I don't even need to scale my data.决策树是完美的,因为我什至不需要扩展我的数据。

My code is as follows:我的代码如下:

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)

However, this gives me:但是,这给了我:

ValueError: For now, only bucketized_column and indicator column are supported but got: _NumericColumn(key='active_time', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None) ValueError:目前,仅支持 bucketized_column 和指标列,但得到:_NumericColumn(key='active_time', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None)

Support for numeric features in tf.estimator.BoostedTreesClassifier has just been added in TensorFlow v1.13 ( source , commit ). TensorFlow v1.13 中刚刚添加了对tf.estimator.BoostedTreesClassifier数字特征的支持( sourcecommit )。 The first stable release is v1.13.1 .第一个稳定版本是v1.13.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python:为什么它不接受01或02或03的输入? - Python: Why doesn't it accept an input of 01 or 02 or 03 for month? 为什么我的脚本不接受有效日期作为用户输入? - Why doesn't my script accept a valid date as user input? 为什么字符串类型的tf.placeholder对于tf.string_input_producer()不起作用 - Why tf.placeholder of string type doesn't work for tf.string_input_producer() 为什么TF MNIST示例不能与原始数据一起使用? - Why doesn't the TF MNIST example work with original data? 为什么我的程序不接受Pandas数据系列作为输入? - Why won't my program accept a Pandas data series as input? 为什么 Sympy 不生成数字 output? - Why doesn't Sympy produce a numerical output? 如果这个 django 表单本身也生成选项,为什么它不接受我的输入? - Why doesn't this django form accept my input if it also generates the options itself? Python 3.8.2 | 为什么我的输入不接受我的答案,即使它是有效的? (功能) - Python 3.8.2 | Why does my input doesn't accept my answer even if it's a valid one? (function) 为什么reversed()不接受生成器? - Why doesn't reversed() accept a generator? 了解梯度提升回归树的部分相关性 - Understanding Partial Dependence for Gradient Boosted Regression trees
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM