我想将7维的向量投影到3维的向量。我正在使用PCA方法:
double c[3][7] = { { 20614.520325, 14429.227642, 14319.951220, 14700.390244, 17404.300813, 13451.105691, 12444.788618 }, { 19054.388889, 13578.222222, 14286.500000, 17277.305556, 17107.555556, 23428.361111, 15735.083333 }, { 14431.971429, 5051.971429, 7382.857143, 15523.428571, 4925.828571, 5575.457143, 5175.885714 } };
cv::Mat pcaset(3,7, CV_32FC1);
for (int i=0;i<pcaset.rows;i++)
{
float* ptr = pcaset.ptr<float>(i);
for (int j=0;j<pcaset.cols;j++)
{
*ptr++ = c[i][j];
}
}
cv::PCA pca(pcaset, // pass the data
cv::Mat(), // we do not have a pre-computed mean vector,
// so let the PCA engine to compute it
cv::PCA::DATA_AS_ROW, // indicate that the vectors
// are stored as matrix rows
// (use PCA::DATA_AS_COL if the vectors are
// the matrix columns)
3 // specify, how many principal components to retain
);
cv::Mat p1 = pca.project(pcaset.row(1));
我将PCA应用于具有3个观察值和7个变量(3x7)的数据矩阵。然后,我将第一个观测值及其7个变量投影到一个较低的空间(3个维度)中。
但是,当我得到1x3 p1向量时,得到以下结果:-261082343354004313930203136.000000 0.000000 0.000000
。哪些值看似错误。我怎么了?