Rajat Varyani
Rajat Varyani

Reputation: 3

How to solve error in python program named: AttributeError: 'module' object has no attribute 'TensorFlowLinearClassifier'

This is the code which uses tensorflow library.

import tensorflow.contrib.learn as skflow
from sklearn import datasets, metrics

iris = datasets.load_iris()

print iris

classifier = skflow.TensorFlowLinearClassifier(n_classes=3)

classifier.fit(iris.data, iris.target)
score=metrics.accuracy_score(iris.target,classifier.predict(iris.data))            

print ("Accracy: %f" % score)  

I have created a python virtual environment and installed tensorflow in it. I tried to use conda as well this results in similar error

Upvotes: 0

Views: 988

Answers (2)

Hamza Zubair
Hamza Zubair

Reputation: 1410

They have changed the name to LinearClassifier, therefore this will work

classifier = skflow.LinearClassifier(n_classes=3)

Upvotes: 2

Akash Chandra
Akash Chandra

Reputation: 51

try using from tensorflow.contrib.learn import TensorFlowLinearClassifier

Upvotes: -1

Related Questions