我可以在不拟合数据的情况下使用 R 中的 prcomp 或其他 PCA 函数转换数据吗?

Can I transform data with prcomp or some other PCA function in R, without fitting to the data?

我想做类似于 sklearn's PCA 的事情,我可以在其中使用 .fit_transform() 训练数据,然后将其用于 .transform() 测试数据,但在 R 中。到目前为止我我找到了 prcompprincomp,但我不知道如何使用这些函数来做到这一点。

你的意思是这样的吗? (我使用 iris 数据的两个子集进行训练和测试。)

pcs <- prcomp(iris[1:100, -5])
test_scores <- predict(pcs, newdata = iris[101:150, ])