【问题标题】:Find selected features by RandomizedLogisticRegression通过 RandomizedLogisticRegression 查找选定的特征
【发布时间】:2015-09-13 17:55:05
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

    你应该使用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]
    

    【讨论】:

    • 谢谢。这很有帮助。
    猜你喜欢
    • 2017-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-10
    • 1970-01-01
    • 2011-01-28
    • 2018-12-13
    • 1970-01-01
    相关资源
    最近更新 更多