私はPCAモデルを使用して、元の入力変数の予測値を保持するテクニックを、retain_PCの
私はそれを読みました、PCAスペースからXスペースに戻るために、あなたは計算する必要があるでしょう:
予測=スコア*負荷
「予測の保存」出力の式を調べるときはいつでも、この線形方程式は上記の概念を表しているのでしょうか。
ありがとう
PS私はPCAが予測モデリングのためのものではないことを知っています、私は最終的にホテリングのT2とSPE出力による故障検出のためにそれを使っています。私のSPE(2乗予測誤差)は、この予測された出力に依存します。
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])
)
);