Lnan95
Myunison
采纳率0%
2017-04-01 10:31

用sklearn在图片分类中数据降维遇到的一些问题

50

我在用isomap、pca和MDS对原始矩阵处理后,发现分类成功率反而大大小于没有降维前,为什么会这样子。。
好像不是参数的问题,怎么调效果都不好。。是我的姿势不对吗

# pca
pca = PCA(n_components=30).fit(x)
x2 = pca.transform(x)
x_train, x_test, y_train, y_test = train_test_split(x2, y, train_size=0.9)
model = RandomForestClassifier(n_estimators=20)
model.fit(x_train, y_train)
predict = model.predict(x_test)
accuracy_pca = metrics.accuracy_score(y_test, predict)

# MDS
mds = manifold.MDS(n_components=30, eps=1e-10)
X_r = mds.fit(x).embedding_
x_train, x_test, y_train, y_test = train_test_split(X_r, y, train_size=0.9)
model.fit(x_train, y_train)
predict = model.predict(x_test)
accuracy_MDS = metrics.accuracy_score(y_test, predict)

# isomap
isomap = manifold.Isomap(15, n_components=30).fit_transform(x)
x_train, x_test, y_train, y_test = train_test_split(isomap, y, train_size=0.9)
model.fit(x_train, y_train)
predict = model.predict(x_test)
accuracy_isomap = metrics.accuracy_score(y_test, predict)
print accuracy_isomap

图片是100×100像素
x是数据矩阵(165×10000)
y是标签,从1到15

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

相关推荐