0

is there any way I can get the feature names of the decision tree model as defined below using sklearn or any other packages in the Anaconda Jupyter Notebook? I'm trying to work on this issue for a long time now, but have not been able to search for exact work through.

Code snippet with the error

Latest Code for preparing model

Code for running the model

Code for visualizing the DT

Harsh780
  • 13
  • 5

1 Answers1

0

You just need to use a Pandas dataframe with the feature names when you train your decision tree model instead of a Numpy array with no feature names.

Scikit-learn decision tree documentation

Pierre-Loic
  • 1,524
  • 1
  • 6
  • 12
  • So, I tried using the method you suggested, but it didn't work for me. I used a pandas data frame with the string features names from the dataset on which I want to train the model. I'm posting the latest code snippets in the question above. – Harsh780 Jun 23 '22 at 07:12