Diagnostics¶
diagnostics ¶
Diagnostics for a fitted qlPCA (thesis section 3.1.4 and 3.1.5; docs/SPEC.md section 5).
vaf ¶
vaf(loadings)
Variance accounted for by each component, sum_j a_js^2.
Equals the s-th eigenvalue of the correlation matrix F'F / n of the transformed variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loadings
|
array-like of shape (m, p)
|
Loadings. |
required |
Returns:
| Type | Description |
|---|---|
ndarray of shape (p,)
|
VAF of each component. |
vaf_percent ¶
vaf_percent(loadings)
VAF of each component as a percentage of the number of variables (VAF_s * 100 / m).
It refers to the transformed variables; comparing it with PCA percentages needs caution (thesis pp. 60-61).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loadings
|
array-like of shape (m, p)
|
Loadings. |
required |
Returns:
| Type | Description |
|---|---|
ndarray of shape (p,)
|
Percentages. |
communalities ¶
communalities(loadings)
Communality of each variable, sum_s a_js^2 (rule of thumb: keep variables >= 0.25).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loadings
|
array-like of shape (m, p)
|
Loadings. |
required |
Returns:
| Type | Description |
|---|---|
ndarray of shape (m,)
|
Communalities. |
piecewise_loadings ¶
piecewise_loadings(model, X, min_points=3)
Piecewise loadings of a degree-1 qlPCA (thesis eqs. 3.7-3.8).
For every variable j and every segment between consecutive distinct knots, the vectors are truncated to the observations whose h_j lies in the (closed) segment, and the loading on component s is the correlation of the scores x_s with the original variable on that segment. Because f_j is linear on the segment, corr(x_s, h_j) = sign(slope) corr(x_s, f_j) on the truncated vectors, so the sign of the slope tells whether the original variable is positively or negatively related to the component there.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
QLPCA
|
A fitted degree-1 model. |
required |
X
|
array-like of shape (n_samples, n_features)
|
Data (usually the training data). |
required |
min_points
|
int
|
Segments with fewer observations get NaN loadings. |
3
|
Returns:
| Type | Description |
|---|---|
list of dict
|
One dict per variable with |