plot_sequential_feature_selection: 可视化来自SequentialFeatureSelector的选定特征子集性能

一个用于可视化feature_selection.SequentialFeatureSelector结果的matplotlib工具函数。

来自 mlxtend.plotting 的 plot_sequential_feature_selection

概述

有关顺序特征选择的更多信息,请参见 feature_selection.SequentialFeatureSelector

示例 1 - 绘制来自顺序特征选择器的结果

from mlxtend.plotting import plot_sequential_feature_selection as plot_sfs
from mlxtend.feature_selection import SequentialFeatureSelector as SFS
import matplotlib.pyplot as plt
from sklearn.neighbors import KNeighborsClassifier
from sklearn.datasets import load_iris

iris = load_iris()
X = iris.data
y = iris.target
knn = KNeighborsClassifier(n_neighbors=4)

sfs = SFS(knn, 
          k_features=4, 
          forward=True, 
          floating=False,
          scoring='accuracy',
          cv=5)

sfs = sfs.fit(X, y)

fig1 = plot_sfs(sfs.get_metric_dict(),
                kind='std_dev',
                figsize=(6, 4))

plt.ylim([0.8, 1])
plt.title('Sequential Forward Selection (w. StdDev)')
plt.grid()
plt.show()

png

API

plot_sequential_feature_selection(metric_dict, figsize=None, kind='std_dev', color='blue', bcolor='steelblue', marker='o', alpha=0.2, ylabel='Performance', confidence_interval=0.95)

Plot feature selection results.

Parameters

Returns

Examples

For usage examples, please see https://rasbt.github.io/mlxtend/user_guide/plotting/plot_sequential_feature_selection/

ython