PCA 모델을 사용하여 retain_PC의
PCA 공간에서 X 공간으로 돌아가려면 다음을 계산해야합니다.
예언 = 점수 * 로딩 '
'절약 예측'출력에 대한 수식을 살펴볼 때마다 위의 개념을 나타내는 선형 방정식이 있습니까?
감사
추신 : 나는 PCA가 예측 모델링을위한 것이 아니라는 것을 알고, 궁극적으로 Hotelling의 T2 및 SPE 출력을 사용하여 결함 감지에 사용하고 있습니다. 내 SPE (제곱 예측 오차)는 예측 된 출력에 달려 있습니다.
PCA 플랫폼에서 점수 매트릭스에 직접 액세스하지 못하는 것처럼 보입니다. 그러나 아래의 코드는 예측 공식이 있어야하는 것처럼 확신 할 수 있습니다. 3 개의 변수에 대한 무작위 다 변수 가우시안 데이터를 생성하며 3 개의 주요 구성 요소를 사용할 때 (즉, 차원 감소가없는 경우) 예측은 원래 데이터와 동일합니다.
Names Default To Here( 1 );
// Function to generate n independant samples from a multivariate Gaussian
// m is the row vector of means
// v is the (square) variance-covariance matrix
// (Dimensions of m and v have to conform)
randomMultiGaussian = Function( {m, v, n},
{Default Local},
nDim = N Row( m );
If( (N Row( v ) != nDim) | (N Col( v ) != nDim),
Beep();
Print( "ERROR in randomMultiGaussian" );
Throw();
);
// Simulate random values . . .
t = Cholesky( v );
d = J( n, nDim, Random Normal() ) * t`;
// Build mean values columnwise . . .
mu = [];
For( i = 1, i <= nDim, i++,
mu ||= J( n, 1, m[i] )
);
// . . . and add the mean to get the final result
d = mu + d;
);
// Make some data
nPts = 100;
m = [0, 0, 0];
v = [1.0 0.2 0.8, 0.2 1.0 0.5, 0.8 0.5 1.0];
dMat = randomMultiGaussian(m, v, nPts);
dt = AsTable(dMat, << Column Names({"x1", "x2", "x3"}));
dt << setName("Sample from Multvariate Gaussian");
// Use PCA
pca = dt << Principal Components(Y( Eval(dt << getColumnNames) ));
// Save predictions
pca << savePredicteds(1); // Predictions with 1 PC
pca << savePredicteds(2); // Predictions with 2 PCs
pca << savePredicteds(3); // Predictions with 3 PCs
// See how the predicted x1 value varies with the number of PCs
dt << Graph Builder(
Show Control Panel( 0 ),
Variables(
X( :x1 ),
Y( :Predicted x1 3 ),
Y( :Predicted x1 2 ),
Y( :Predicted x1 )
)
);
// For 3 PCs compare the predicted values with the original data values
Print(
Maximum(
Maximum(Column(dt, "x1")[1::nPts] - Column(dt, "Predicted x1 3")[1::nPts]),
Maximum(Column(dt, "x2")[1::nPts] - Column(dt, "Predicted x2 3")[1::nPts]),
Maximum(Column(dt, "x3")[1::nPts] - Column(dt, "Predicted x3 3")[1::nPts])
)
);