pydiodon.plot_quality¶
- pydiodon.plot_quality(Qual_axis, Qual_cum, r=2, cum=False, 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 (for permitting cumulated quality)
- sortboolean
- whether to sort or not the items according to their quality of projectiondefault value is False
- cuma boolean
- whether to use cumulated quality from axis 1 to r
- 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:
- a plot
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_axis, Qual_cum = dio.quality(Y) >>> dio.plot_quality(Y)
or, for sorting the items in decreasing quality, and with cumulated quality
>>> dio.plot_quality(Y, cum=True, sort=True)
af, revised 22.10.28, 23.01.18, 25.02.21