@@ -390,6 +390,24 @@ define([
390
390
{ name : 'random_state' , component : [ 'input_number' ] , placeholder : '123' , usePair : true } ,
391
391
{ name : 'importance_allocate' , label : 'Allocate to' , component : [ 'input' ] , placeholder : 'New variable' , value : 'importances' }
392
392
]
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
+ ]
393
411
}
394
412
}
395
413
switch ( category ) {
@@ -496,6 +514,7 @@ define([
496
514
]
497
515
} ,
498
516
'permutation_importance' : defaultInfos [ 'permutation_importance' ] ,
517
+ 'plot_feature_importances' : defaultInfos [ 'plot_feature_importances' ] ,
499
518
'Coefficient' : {
500
519
name : 'coef_' ,
501
520
label : 'Coefficient' ,
@@ -568,7 +587,8 @@ plt.show()",
568
587
{ name : 'auc_featureData' , label : 'Feature Data' , component : [ 'var_select' ] , var_type : [ 'DataFrame' , 'Series' , 'ndarray' , 'list' , 'dict' ] , value : 'X_test' }
569
588
]
570
589
} ,
571
- 'permutation_importance' : defaultInfos [ 'permutation_importance' ]
590
+ 'permutation_importance' : defaultInfos [ 'permutation_importance' ] ,
591
+ 'plot_feature_importances' : defaultInfos [ 'plot_feature_importances' ]
572
592
}
573
593
574
594
// use decision_function on ROC, AUC
0 commit comments