I am trying to implement decision tree classifier to classify my data set. I am using Python. Now it is easy to implement in scikit learn, but how can I implement this in tensorflow.
-
$\begingroup$ Even if Decision Trees were offered for TensorFlow(which they don't), I wouldn't suggest using it. There is so much technical overhead with getting a tensorflow model going compared to sklearn... Pick the right tool for the job! <scikit-learn.org/stable/modules/tree.html> $\endgroup$– Michael HigginsCommented Mar 12, 2020 at 19:41
3 Answers
Basically I guess TensorFlow
does not support decision trees. I quote from here,
This is a big oversimplification, but there are essentially two types of machine learning libraries available today,
Deep learning
(CNN,RNN, fully connected nets, linear models) and Everything else (SVM, GBMs, Random Forests, Naive Bayes, K-NN, etc). The reason for this is that deep learning is much more computationally intensive than other more traditional training methods, and therefore requires intense specialization of the library (e.g., using a GPU and distributed capabilities). If you're using Python and are looking for a package with the greatest breadth of algorithms, try scikit-learn. In reality, if you want to use deep learning and more traditional methods you'll need to use more than one library. There is no "complete" package.
You can see from here that there are other learning algorithms implemented in TensorFlow
which are not deep models.
You can take a look at here for tracking algorithms implemented in TensorFlow
.
-
$\begingroup$ I'm torn on this: I'm aboard with the reasoning of your quote, but on the other hand: Random Forrest is a kind of tree learner. $\endgroup$ Commented Feb 20, 2018 at 13:19
-
$\begingroup$ @SvanBalen I don't understand what you mean. $\endgroup$ Commented Feb 20, 2018 at 13:57
-
$\begingroup$ Tensorflow supports random forrest (as documented by the link you gave), random forrest is a special kind of tree learner. So even though Tensorflow doenst seem to support common learners (CART or C45) and even though it is primarily a library for deep learning, and even though I too would use sklearn, it technically supports a tree learner, making your statement false. $\endgroup$ Commented Feb 20, 2018 at 14:06
-
2$\begingroup$ @SvanBalen I thank you if I really have made a mistake for announcing me but I don't know where I'm wrong. I've said
TensorFlow
does not support decision trees, which is really the case. Which part I'm wrong? $\endgroup$ Commented Feb 20, 2018 at 14:10 -
$\begingroup$ TF supports random forest, random forest is a decision tree (a specific type at that), hence TF supports decision trees. But like I said: I'm torn at whether your statement is wrong: Technically it is, but for all practical purposes it is not. $\endgroup$ Commented Feb 20, 2018 at 14:26
Similar to what I wrote on the other post, TensorFlow does in fact have implementations of Random Forest and Gradient Boosting, in addition to other non-deep learning algorithms. The links can be found at that post.
The main difference is that tensorflow is based on numerical methods (i.e., gradient descents). There is no gradient in tree-based methods. The exception is gradient regression tree.