@@ -390,6 +390,24 @@ define([
390390 { name : 'random_state' , component : [ 'input_number' ] , placeholder : '123' , usePair : true } ,
391391 { name : 'importance_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'importances' }
392392 ]
393+ } ,
394+ 'plot_feature_importances' : {
395+ name : 'plot_feature_importances' ,
396+ label : 'Plot feature importances' ,
397+ import : '' ,
398+ code : "def plot_feature_importances(model):\n\
399+ n_features = len(model.feature_importances_)\n\
400+ feature_names = [ 'X{}'.format(i) for i in range(n_features) ]\n\
401+ plt.barh(np.arange(n_features), model.feature_importances_, align='center')\n\
402+ plt.yticks(np.arange(n_features), feature_names)\n\
403+ plt.xlabel('Feature importance')\n\
404+ plt.ylabel('Features')\n\
405+ plt.ylim(-1, n_features)\n\n\
406+ plot_feature_importances(${model})" ,
407+ description : '' ,
408+ options : [
409+
410+ ]
393411 }
394412 }
395413 switch ( category ) {
@@ -496,6 +514,7 @@ define([
496514 ]
497515 } ,
498516 'permutation_importance' : defaultInfos [ 'permutation_importance' ] ,
517+ 'plot_feature_importances' : defaultInfos [ 'plot_feature_importances' ] ,
499518 'Coefficient' : {
500519 name : 'coef_' ,
501520 label : 'Coefficient' ,
@@ -568,7 +587,8 @@ plt.show()",
568587 { name : 'auc_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' , 'ndarray' , 'list' , 'dict' ] , value : 'X_test' }
569588 ]
570589 } ,
571- 'permutation_importance' : defaultInfos [ 'permutation_importance' ]
590+ 'permutation_importance' : defaultInfos [ 'permutation_importance' ] ,
591+ 'plot_feature_importances' : defaultInfos [ 'plot_feature_importances' ]
572592 }
573593
574594 // use decision_function on ROC, AUC
0 commit comments