I believe I have a simple if not trivial question. I have a background in statistics and I tend to use Stata and R quite a bit. I am interested in learning Python. I used it for a while now and recently came into contact with scikit-learn.
I am trying to reproduce a simple example.
from sklearn import tree
features = [[140, 1],[130, 1], [150, 0], [170, 0]]
labels = [0 , 0 , 1 , 1]
clf = tree.DecisionTreeClassifier()
clf = clf.fit(features, labels)
print clf.predict([[150, 0]])
As you can see, the tiny script tries to predict - by the means of a decision tree - wether a object with the properties [150, 0]
is likely a type 1
or 0
.
I run the script and get following error:
File "clf_decision_tree.py", line 6
print clf.predict([[150, 0]])
^
SyntaxError: invalid syntax
I realy don't get what is wrong... Can you help me out? Best /R
PS: I not sure if Cross Validated or Stackoverflow are better places to ask. Let me know. Thanks.