python - 通过 RandomizedLogisticRegression 查找选定的特征

标签 python scikit-learn logistic-regression feature-selection

我正在对 300K 样本和 19 个特征进行二元分类。 我在 scikit 中使用 RandomizedLogisticRegression() 进行特征选择。 我想知道如何找到 RandomizedLogisticRegression() 选择了哪些特征。

最佳答案

你应该使用 get_support功能:

from sklearn.datasets import load_iris
from sklearn.linear_model import RandomizedLogisticRegression

iris = load_iris()
X, y = iris.data, iris.target

clf = RandomizedLogisticRegression()
clf.fit(X,y)
print clf.get_support()

#prints [False  True  True  True]

或者,您可以获得支持功能的索引:

print clf.get_support(indices=True)
#prints [1 2 3]

关于python - 通过 RandomizedLogisticRegression 查找选定的特征,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31078921/

相关文章:

python-3.x - 如何构建一个神经网络来将两个数字相乘

scikit-learn - scikit-learn 中的分类器报告告诉我们什么?

python - Scikit-learn 中逻辑回归的第一次迭代的初始估计是多少?

python - 如何使用 Rust 使用默认程序启动任何文件(如 Python 的 `os.startfile()` )

python - Cython 编译正常,但找不到符号 : __ZNSs4_Rep20_S_empty_rep_storageE when running on Mac OS

python - 将 Sklearn GridSearchCV 与 Pipeline 结合使用时如何传递权重

python - Scikit Learn 逻辑回归中预测的逆是正确的

tensorflow - TensorFlow的逻辑回归

python - python 中的 xmlrpcserver 实现能够注册整个模块吗?

python - 在 postgis 中存储多边形和几何图形