Aug-01-2022, 04:20 PM
I get the following error when I run some python code.
What is wrong? The variable is defined.
Thanks in advance.
Respectfully,
LZ
Error:NameError Traceback (most recent call last)
Input In [115], in <cell line: 2>()
1 # Plotting a Bar Graph to compare models
----> 2 plt.bar(X.columns, feature_importances_)
3 plt.xlabel( "Feature Labels")
4 plt.ylabel( "Feature Importance" )
NameError: name 'feature_importances_' is not defined
It says that feature_importances_ is not defined. In the code one can see that it is.model = ExtraTreesClassifier() model.fit(X, y) print(model.feature_importances_) ext=pd.DataFrame(model.feature_importances_,columns=["extratrees"]) ext ext.sort_values(['extra-trees'], ascending=True) # Plotting a Bar Graph to compare models plt.bar(X.columns, feature_importances_) plt.xlabel( "Feature Labels") plt.ylabel( "Feature Importance" ) plt.title( "Comparison of Different Feature Importances" ) plt.shw()
What is wrong? The variable is defined.
Thanks in advance.
Respectfully,
LZ