作者:欧新宇(Xinyu OU)
本文档所展示的测试结果,均运行于:Intel Core i7-7700K CPU 4.2GHz
【作业提交】
将分类结果保存到文本文档进行提交(写上每一题的题号和题目,然后再贴答案),同时提交源代码。
*结果文件,要求每小题标注题号,两题之间要求空一行*
要求在 "MNIST人脸识别" 数据集上完成以下任务,要求如下:
solver='lbfgs', hidden_layer_sizes=[100, 100], activation='relu', alpha=1e-5, random_state=62,
methods = ['StandardScaler', 'MinMaxScaler', 'MaxAbsScaler', 'RobustScaler', 'Normalizer', 'Binarizer']
在完成了六种预处理方法的性能输出后,对比预处理结果和原始数据的结果,从7种结果中选出性能最好的一种方法完成后续的实验。
num=20
scores = np.zeros([3,num])
scores[0,:] = np.linspace(0.40, 0.99, num)
import sys
import os
sys.path.append(os.path.join(os.getcwd(), '..', 'Modules'))
import load_MNIST
import time
start = time.time()
train_images = load_MNIST.load_train_images()
train_labels = load_MNIST.load_train_labels()
test_images = load_MNIST.load_test_images()
test_labels = load_MNIST.load_test_labels()
print("载入数据集共耗时: {:.3f}s".format(time.time() - start))
# 标准调整形态的方法
# X_train = train_images.reshape(train_images.shape[0], train_images.shape[1]*train_images.shape[2])/255
# 此处,因为我们已经知道的样本的形态,所以可以直接书写值
X_train = train_images.reshape(60000, 28*28)/255
y_train = train_labels
X_test = test_images.reshape(10000, 28*28)/255
y_test = test_labels
# 为了提高训练速度,我们只提取10%的样本进行演示
X_train_lite = X_train[0:5999,:]
y_train_lite = y_train[0:5999]
X_test_lite = X_test[0:999,:]
y_test_lite = y_test[0:999]