sk_feature_process.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:python_utils 作者: Jayhello 项目源码 文件源码
def sk_feature_ref():
    # load the iris datasets
    dataset = datasets.load_iris()
    # create a base classifier used to evaluate a subset of attributes
    model_lr = LogisticRegression()
    # create the RFE model and select 3 attributes
    rfe = RFE(model_lr, 3)
    rfe = rfe.fit(dataset.data, dataset.target)
    # summarize the selection of the attributes
    print rfe.support_
    # [False  True  True  True]
    print rfe.ranking_
    # [2 1 1 1]
    print sorted(zip(map(lambda x: round(x, 4), rfe.ranking_), dataset.feature_names))
    # [(1.0, 'petal length (cm)'), (1.0, 'petal width (cm)'), (1.0, 'sepal width (cm)'), (2.0, 'sepal length (cm)')]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号