# running scikit-learn on Sypder with Python 3.5

I am trying to print a accuracy score and get this message:

<function accuracy_score at 0x0000018A76046840>

So I am wondering if I am missing a package or is something installed incorrect?

Code:

from sklearn import datasets
from sklearn.metrics import accuracy_score
from sklearn import svm
X = iris.data
y= iris.target
#print (iris.keys)
print('**********')
#print (iris['feature names'])
print('**********')
#print (iris)
#print (iris['data'].shape,'legth: ',len(iris['target']))
clf = svm.SVC(gamma=0.001, C=100)
clf.fit(X,y)
y_hat=clf.predict(X)
accuracy_score(y, y_hat)
score = accuracy_score
print (score)

• Please post the code – trollster Jan 30 '18 at 16:31
• Not, here, in the question itself. Edit the question and add the code. – trollster Jan 30 '18 at 16:33

The reason is that you are printing the object of function. Instead call the function. Suppose the name of your function is func. You are doing something like

print(func)


print(func())


This is how it must be:

score = accuracy_score(y, y_hat)
print (score)


You assigned empty function to score.

Your entire code should now be:

from sklearn import datasets
from sklearn.metrics import accuracy_score
from sklearn import svm
X = iris.data
y= iris.target
#print (iris.keys)
print('**********')
#print (iris['feature names'])
print('**********')
#print (iris)
#print (iris['data'].shape,'legth: ',len(iris['target']))
clf = svm.SVC(gamma=0.001, C=100)
clf.fit(X,y)
y_hat=clf.predict(X)

score = accuracy_score(y, y_hat)
print (score)

• Worked perfect, thank you very much, sorry first question and should have read how to post code first! – Gregory Boyle Jan 30 '18 at 16:40
• Don't forget mark question answered (tick on best answer). – mico Jan 30 '18 at 19:53