我目前正在使用tf 1.4,我需要帮助查看tf.contrib.factorization.KMeansClustering
估算器的预测。我目前的代码段如下:
km = KMeansClustering(num_clusters=8,initial_clusters=KMeansClustering.KMEANS_PLUS_PLUS_INIT,model_dir=MODEL,relative_tolerance=0.01)
result = km.train(input_fn=lambda: gen_input(body))
input_fn = tf.estimator.inputs.pandas_input_fn(x={'x':tst}, shuffle=False)
y = result.predict(input_fn)
body和tst是pandas数据帧。 print(y)
给出:
<generator object Estimator.predict at 0x11ebecba0>
尝试我搜索的内容,例如调用print(list(y))
,print(next(y))
或迭代y,如:
for i in y:
...
for i in y.items():
...
for i in enumerate(y):
...
等,给出错误TypeError: data must be either a numpy array or pandas DataFrame if pandas is installed; got dict
。我找不到任何其他方法来尝试在线打印。感谢