Tensorflow实现数据分档操作

数据分档当意义,参考这篇博客
借助tensorflow的:

tf.feature_column.bucketized_column(
    source_column,
    boundaries
)

进行操作。source_column表示数据列,boundaries表示分组的边界。比如boundaries=[0., 1., 2.] 产生(-inf, 0.), [0., 1.), [1., 2.), 和 [2., +inf)。
例如:

boundaries = [0, 10, 100]
input tensor = [[-5, 10000]
                [150,   10]
                [5,    100]]

数据分档为:(-inf, 0)为0,[0, 10)为1,[10, 100)为2,[100, +inf)为3。
结果:

output = [[0, 3]
          [3, 2]
          [1, 3]]

猜你喜欢

转载自blog.csdn.net/qq_35976351/article/details/80893350