我正在尝试使用Weka工具进行PCA算法的特征选择。
我的原始数据包含大约9000个属性和2700个样本。
我尝试使用以下代码来降低数据的维度:
AttributeSelection selector = new AttributeSelection();
PrincipalComponents pca = new PrincipalComponents();
Ranker ranker = new Ranker();
selector.setEvaluator(pca);
selector.setSearch(ranker);
Instances instances = SamplesManager.asWekaInstances(trainSet);
try {
selector.SelectAttributes(instances);
return SamplesManager.asSamplesList(selector.reduceDimensionality(instances));
} catch (Exception e ) {
...
}
然而,它没有在12小时内完成运行。它在方法selector.SelectAttributes(instances);
中卡住了。
我的问题是: weka的PCA是否预计具有如此长的计算时间?或者我使用PCA的方式不正确吗?
如果长时间运行时间是预期的:
我该如何调整PCA算法以使其运行更快?您能建议一个替代方案吗?(+如何使用它的示例代码)?
如果不是:
我错在哪里?我应该如何调用使用weka进行PCA并获得降维后的数据?
更新:评论证实了我的怀疑,它花费了比预期更多的时间。
我想知道:如何在Java中使用weka或其他库获得PCA。
为此添加了奖励。