Merge pull request #233 from 3286138832/patch-1

参数调优
This commit is contained in:
片刻 2018-05-25 10:50:08 +08:00 committed by GitHub
commit 93238d0fbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -60,7 +60,7 @@ def dRPCA(x_train, x_test, COMPONENT_NUM):
0 < n_components < 1 0 < n_components < 1
n_components=0.99 设置阈值总方差占比 n_components=0.99 设置阈值总方差占比
''' '''
pca = PCA(n_components=COMPONENT_NUM, whiten=True) pca = PCA(n_components=COMPONENT_NUM, whiten=False)
pca.fit(trainData) # Fit the model with X pca.fit(trainData) # Fit the model with X
pcaTrainData = pca.transform(trainData) # Fit the model with X and 在X上完成降维. pcaTrainData = pca.transform(trainData) # Fit the model with X and 在X上完成降维.
pcaTestData = pca.transform(testData) # Fit the model with X and 在X上完成降维. pcaTestData = pca.transform(testData) # Fit the model with X and 在X上完成降维.
@ -85,7 +85,7 @@ def dRecognition_knn():
print('load data time used:%f' % (stop_time_l - start_time)) print('load data time used:%f' % (stop_time_l - start_time))
# 降维处理 # 降维处理
trainData, testData = dRPCA(trainData, testData, 35) trainData, testData = dRPCA(trainData, testData, 0.8)
# 模型训练 # 模型训练
knnClf = knnClassify(trainData, trainLabel) knnClf = knnClassify(trainData, trainLabel)