Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How to plot Feature importance of any model in python

#Feature importance from any model can be plotted as follows:

importances = model.feature_importances_ 
idxs = np.argsort(importances) 
plt.title('Feature Importances')
plt.barh(range(len(idxs)), importances[idxs], align='center') 
plt.yticks(range(len(idxs)), [col_names[i] for i in idxs]) 
plt.xlabel('Model name Feature Importance') 
plt.show()
Comment

python model feature importance

model = XGBClassifier()
m = model.fit(X , y)
zip_iterator = zip(list(X.columns), m.feature_importances_)
feature_dict = dict(zip_iterator)
dict( sorted(feature_dict.items(), key=operator.itemgetter(1),reverse=True))
Comment

PREVIOUS NEXT
Code Example
Python :: how to get defintiion of pysspark teable 
Python :: NumPy rot90 Syntax 
Python :: NumPy bitwise_and Example When inputs are Boolean 
Python :: pandas listagg equivalent in python 
Python :: how to run string like normal code in python 
Python :: ignopre rankwarning pyton 
Python :: NumPy bitwise_or Code When inputs are numbers 
Python :: NumPy unpackbits Syntax 
Python :: django view - mixins and GenericAPIView (list or create - GET, POST) 
Python :: ttk.frame 
Python :: turn dictionary into flat list 
Python :: adjugate of 3x3 matrix in python 
Python :: xampp python 
Python :: bouton 
Python :: unauthorized vue django rest framework 
Python :: python raw strings 
Python :: genisim 4.0 words 
Python :: matrix implement 
Python :: how to access specific index of matrix in python 
Python :: Flask select which form to POST by button click 
Python :: python socket backlog 
Python :: python regex with f-string 
Python :: replace string in dictionary python 
Python :: store image in django postprocessimage in django storage 
Python :: echo linux with ANSI escape sequence for change output color 
Python :: python alphabet to number 
Python :: modules django 
Python :: python plot draw the goal line 
Python :: modwt python github code 
Python :: alterning format when reading from a text file 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =