1. 对测试数据集归一化的方法
2. 使用sklearn中的Scalar
(1)导入需要的包:
import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
(2)加载数据集,读取data和target作为X和y:
iris = datasets.load_iris()
X = iris.data
y = iris.target
(3)此时查看一下前10行内容:
(4)对数据集进行切分:
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0