I want to use sklearns DecisionTreeClassifier for sentiment analysis. I am fully aware that a decision tree is probably not a good model for this kind of task, but I want to try it anyways for the purpose of comparison.
My text data will be vectorized by one-hot endcoding. This of course means that the data will be very high-dimensional. For that reason, I am interested in how one would set the parameters of the DecisionTreeClassifier (especially the max_depth
parameter) so that the classifier works reasonably well and the tree does not become enormous.
Here is my code:
from sklearn.tree import DecisionTreeClassifier
from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer(max_df=0.90, min_df = 2, stop_words='english', binary = True)
model = DecisionTreeClassifier()
X_train = vectorizer.fit_transform(text_data)
y_train = target_values
model.fit(X_train, y_train)