from scipy.sparse import hstack X_tr1 = hstack((X_train_cc_ohe, X_train_csc_ohe, X_train_grade_ohe, X_train_price_norm, X_train_tnppp_norm, X_train_essay_bow, X_train_pt_bow)).tocsr() X_te1 = hstack((X_test_cc_ohe, X_test_csc_ohe, X_test_grade_ohe, X_test_price_norm, X_test_tnppp_norm, X_test_essay_bow, X_test_pt_bow)).tocsr()
X_train_cc_ohe and all are vectorized categorical data, and
X_train_pt_bow is bag of words vectorized text data.
Now, I applied a decision tree classifier on this model and got this:
max_depth as 3 just for visualization purposes.
My question is: I would like to get feature names in my output instead of index as X2599, X4 etc. I know I can do it by
vect.get_feature_names() as input to
export_graphviz, vect is object of
CountVectorizer(), since I already merged this vectorized data using hstack. Now how do you get feature names in this decision tree?