i am tring to learn supervised learning in logistic regression from the http://www.dummies.com/programming/big-data/data-science/how-to-create-a-supervised-learning-model-with-logistic-regression/
but i get this error
TypeError: 'list' object is not callable
there are other error as well. i've searched i came to know i've to use square brackets to access the list but that didnt worked.
can any one tell me what is wrong with code. i am using anaconda(spyder 3.6)
here is my code
from sklearn.datasets import load_iris
from sklearn import linear_model
from sklearn import cross_validation
from sklearn import metrics
iris = load_iris()
X_train, X_test, y_train, y_test=cross_validation.train_test_split(iris.data,iris.target,test_size=0.10,random_state=111)
logClassifier = linear_model.LogisticRegression(random_state=111)
logClassifier.fit(X_train, y_train)
predicted = logClassifier.predict(X_test)
predictedarray=([0, 0, 2, 2, 1, 0, 0, 2, 2, 1, 2, 0, 2, 2, 2])
y_testarray=([0, 0, 2, 2, 1, 0, 0, 2, 2, 1, 2, 0, 2, 2, 2])
metrics.accuracy_score(y_test, predicted)
predicted == y_testarray([ True, True, True, True, True, True, True, True,True, True, True, True, True, True, True], dtype=bool)
in the link you provided, it looks like some of the lines are input and some lines are output (which is not made very clear), and so not all the lines are actual code but also contain output of what would happen if you ran the code
to clarify, the line
predictedarray=([0, 0, 2, 2, 1, 0, 0, 2, 2, 1, 2, 0, 2, 2, 2])
is the ouput of the line
predicted = logClassifier.predict(X_test)
which is shown to illustrate the ouput of the predict function, but the line predictedarray=([0, 0, 2, 2, 1, 0, 0, 2, 2, 1, 2, 0, 2, 2, 2])
itself is output and should not be added to the code
the same goes for the last line : predicted == y_testarray([ True, True, True, True, True, True, True, True,True, True, True, True, True, True, True], dtype=bool)
although in the link it is not made clear in the link, I think this is to show that the results of running
predicted == y_testarray
would be equal to an array containing only True
as the two arrays are indeed the same, so you also don't need this last line