pydiodon.plot_cumulated_quality_per_item¶
- pydiodon.plot_cumulated_quality_per_item(Y, r=2, sort=False, col='blue', title=None, x11=True, plotfile=None, fmt='png')[source]¶
plots the quality per item
- Parameters
- Ya 2D \(n \times p\) numpy array
a matrix of principal components
- ran integer, the axis for plotting cumulated quality
default value is 2
- sortboolean
- whether to sort or not the items according to their quality of projectiondefault value is False
- cola string
- the color to use for plotting the qualitydefault value is blue
- titlestring
title of the plot
- x11boolean
the plot is displayed on the scvreen if x11=True
- plotfilestring
name of the file to save the plot
the plot is not saved if plotfile=None
- fmtstring
format of the file to save the plot.
accepted values are png, eps, pdf.
- Returns
- Qual1D \(r\) numpy array
the rowise cumulated quality per axis up to r.
Notes
The quality of the projection of the dataset on a subspace spanned by principal axis is a scalar giving a global estimate of the quality. However, the quality of projection may differ from item to item: some can be well projected on plane (1,2) and some other not. This function computes and plots the quality of projection of each item on subspace \(E_r\) spanned by r first axis.
More precisely, for each row i of the matrix of components Y
it computes Qual with \(Qual[i,r] = \sum_{j \leq r} Y[i,j]^2 / \sum_{k \leq p} Y[i,k]^2\) for \(1 \leq i \leq n\) and \(1 \leq r \leq p\)
once an axis r has been selected, it draws the plot of \((i, Q(i,r))\) for \(1 \leq i \leq n\) with i on x axis.
Example
>>> import pydiodon as dio >>> A, rn, cn = dio.load_dataset("diatoms_sweden") >>> Y, L, V = dio.pca(A) >>> Qual = dio.plot_cumulated_quality_per_item(Y)
or, for sorting the items in decreasing quality
>>> Qual = dio.plot_cumulated_quality_per_item(Y, sort=True)
af, revised 22.10.28, 23.01.18