代码之家  ›  专栏  ›  技术社区  ›  Him

如何从sklearn'bunch中获取目标功能名称`

  •  1
  • Him  · 技术社区  · 7 年前

    可以从sklearn获取“列标题” Bunch 作为 Bunch.feature_names . 但是,这并没有给出目标变量的“列标题”。如何获得目标变量的“列标题”?

    例如,对于iris数据集:

    >>> data.feature_names 
    ['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width(cm)']
    

    本着这种精神,目标变量的“列标题”类似于“种类”(因为 data.target_names 给予 array(['setosa', 'versicolor', 'virginica'], dtype='<U10') . 做一个sklearn 有办法获得目标的“列标题”,例如“物种”?

    1 回复  |  直到 7 年前
        1
  •  2
  •   Him    7 年前

    你想要的东西是不可能的。但是,您可以执行以下操作:

    from sklearn.datasets import load_iris
    
    data = load_iris()
    print(data.DESCR)
    

    并阅读描述

    The data set contains 3 classes of 50 instances each, where each class refers to a type of iris plant.

    推荐文章