可以从sklearn获取“列标题” Bunch 作为 Bunch.feature_names . 但是,这并没有给出目标变量的“列标题”。如何获得目标变量的“列标题”?
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 束 有办法获得目标的“列标题”,例如“物种”?
data.target_names
array(['setosa', 'versicolor', 'virginica'], dtype='<U10')
束
你想要的东西是不可能的。但是,您可以执行以下操作:
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.