02データセット取得および処理(iris)
2691 ワード
データの取得-iris、トレーニングセットとテストセットの分割
実行結果:
転載先:https://www.cnblogs.com/jumpkin1122/p/11520970.html
from sklearn.datasets import load_iris
# 1. (iris)
iris = load_iris()
# print("iris :", iris) # data,target,target_name
print(" :", iris.data.shape)
print(" :", iris.target.shape)
print(" :", iris.target_names)
# 2.
from sklearn.model_selection import train_test_split # test_size,train_size,random_stat
x_train, x_test, y_train, y_test = train_test_split(iris.data, iris.target,test_size=0.25)
print(" x-y:", x_train.shape, y_train.shape)
print(" x-y:", x_test.shape, y_test.shape)
実行結果:
: (150, 4)
: (150,)
: ['setosa' 'versicolor' 'virginica']
x-y: (112, 4) (112,)
x-y: (38, 4) (38,)
転載先:https://www.cnblogs.com/jumpkin1122/p/11520970.html