from sklearn.datasets import load_iris
# return DataFrame with features and target
df = load_iris(as_frame=True)['frame']
df.head(3)
sepal length (cm) | sepal width (cm) | petal length (cm) | petal width (cm) | target | |
---|---|---|---|---|---|
0 | 5.1 | 3.5 | 1.4 | 0.2 | 0 |
1 | 4.9 | 3.0 | 1.4 | 0.2 | 0 |
2 | 4.7 | 3.2 | 1.3 | 0.2 | 0 |
# return DataFrame with features and Series with target
X, y = load_iris(as_frame=True, return_X_y=True)
X.head(3)
sepal length (cm) | sepal width (cm) | petal length (cm) | petal width (cm) | |
---|---|---|---|---|
0 | 5.1 | 3.5 | 1.4 | 0.2 |
1 | 4.9 | 3.0 | 1.4 | 0.2 |
2 | 4.7 | 3.2 | 1.3 | 0.2 |
y.head(3)
0 0 1 0 2 0 Name: target, dtype: int64
© 2020 Data School. All rights reserved.