Hi Gilles,
I just realized that the version of scikit-learn when I wrote the original
email is 0.15.2. To follow your suggestion, I updated the scikit-learn to
version 0.16.1 and tried the following commands. Finally it worked and here
is what I found:
clf.apply(X_train), which gives the error message below
---------------------------------------------------------------------------AttributeError
Traceback (most recent call
last)<ipython-input-12-eefdba2eebd4> in <module>()----> 1
clf.apply(X_train)
AttributeError: 'DecisionTreeClassifier' object has no attribute 'apply'
Next, I tried this, but still got a different error message.
clf.tree_.apply(X_train)
---------------------------------------------------------------------------ValueError
Traceback (most recent call
last)<ipython-input-10-2ecc95213752> in <module>()----> 1
clf.tree_.apply(X_train)
sklearn/tree/_tree.pyx in sklearn.tree._tree.Tree.apply
(sklearn/tree/_tree.c:24665)()
sklearn/tree/_tree.pyx in sklearn.tree._tree.Tree.apply
(sklearn/tree/_tree.c:24612)()
sklearn/tree/_tree.pyx in sklearn.tree._tree.Tree._apply_dense
(sklearn/tree/_tree.c:24805)()
ValueError: X.dtype should be np.float32, got float64
Finally, I converted the input array from float64 to float32, then ran the
previous command and it worked.
X_train = X_train.astype('float32')
clf.tree_.apply(X_train)
array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2])
Thanks so much again for your help, Gilles!
Kittipat
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general