我正在尝试实现分类器-鸢尾花-经典问题
我正在使用Python3.6
import tensorflow as tf
from sklearn import datasets, metrics
from tensorflow.contrib.learn.python import SKCompat
iris = datasets.load_iris()
classifier = SKCompat(tf.contrib.learn.LinearClassifier(
feature_columns=[tf.contrib.layers.real_valued_column("",dimension=iris.data.shape[1])],
n_classes=3))
classifier.fit(iris.data, iris.target)
score = metrics.accuracy_score(iris.target,classifier.predict(iris.data))
print("Accuracy: %f" %score)
Instructions for updating:
Please use tensorflow/transform or tf.data.
check_array (from tensorflow.contrib.learn.python.learn.learn_io.data_feeder) is deprecated and will be removed in a future version.
Instructions for updating:
Please convert numpy dtypes explicitly.
WARNING:tensorflow:float64 is not supported by many models, consider casting to float32.
ModelFnOps.__new__ (from tensorflow.contrib.learn.python.learn.estimators.model_fn) is deprecated and will be removed in a future version.
Instructions for updating:
When switching to tf.estimator.Estimator, use tf.estimator.EstimatorSpec. You can use the `estimator_spec` method to create an equivalent one.
让我知道是否需要延长的错误代码。如果需要,我将其添加。