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 :: add a row at a specific index pandas 
Python :: aiohttp set port 
Python :: structural pattern matching python 
Python :: convert blocks to mb python 
Python :: declare array python 
Python :: how to skip number in while loop python 
Python :: assert in selenium python 
Python :: Object of type datetime is not JSON serializable 
Python :: django pass list of fields to values 
Python :: how to adda vaslues to data frame 
Python :: most occurring element in array python 
Python :: python plot normal distribution 
Python :: get image image memeory size in url inpyton requests 
Python :: max of empty list python 
Python :: python bot ban script 
Python :: python sum only numbers 
Python :: check if element is in list 
Python :: validating credit card numbers 
Python :: get first not null value from column dataframe 
Python :: python windows api 
Python :: update dataframe based on value from another dataframe 
Python :: with open python print file name 
Python :: Converting categorical variable to numeric variable in python 
Python :: aws django bucket setting 
Python :: python string formatting - padding 
Python :: tkinter asksaveasfile 
Python :: warnings.warn("DateTimeField %s received a naive datetime (%s)" 
Python :: update in django orm 
Python :: str remove except alphabets 
Python :: how to use return python 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =