python iris 数据集
from sklearn.datasets import load_iris iris = load_iris() print(iris.keys()) n_samples, n_features = iris.data.shape print((n_samples, n_features)) print(iris.data[0]) print(iris.target.shape) print(iris.target) print(iris.target_names) print("feature_names:",iris.feature_names)
sklearn中的iris数据集有5个key:
- [‘target_names’, ‘data’, ‘target’, ‘DESCR’, ‘feature_names’]
- target_names : 分类名称
- [‘setosa’ ‘versicolor’ ‘virginica’]
- target:分类(150个)
- (150L,)
- [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
2 2]
- feature_names: 特征名称
- (‘feature_names:’, [‘sepal length (cm)’, ‘sepal width (cm)’, ‘petal length (cm)’, ‘petal width (cm)’])
- data : 特征值
- (150L, 4L)
- data[0]:[ 5.1 3.5 1.4 0.2]
- target_names : 分类名称