quantlab.analysis.factor_correlation.FactorCorrelationFigure#
- class quantlab.analysis.factor_correlation.FactorCorrelationFigure(label_limit=800, top_pairs=20, top_clusters=12)[source]#
Bases:
objectDraw a
FactorCorrelationso that hundreds of variables stay readable.The main panel is the mean correlation in cluster order on a fixed
-1..1diverging scale (red negative, gray none, blue positive), so redundant factors form blocks on the diagonal; every cluster of two or more variables is outlined, and the diagonal, always 1, is left blank. Up tolabel_limitvariables every row and column is named: the heatmap grows so each row is at least 6.5 points high, and past about a hundred variables the names are meant to be read zoomed in (the saved PNG is written atFIGURE_DPI). Beyondlabel_limitthe axes name the clusters of two or more variables instead, andfactor_clusters.csvmaps every variable to its cluster and position. Beside it: the strongest pairs by|correlation|, the largest clusters with their first members, and the distribution of all pairs on a log count scale so the few strong pairs stay visible.- Parameters:
- label_limitint, default 800
Most variables whose names are written on the heatmap axes. At 800 the heatmap is about 72 inches, some 10,800 pixels at
FIGURE_DPI.- top_pairsint, default 20
Strongest pairs listed beside the heatmap.
- top_clustersint, default 12
Largest clusters listed beside the heatmap.
Examples
>>> fig = FactorCorrelationFigure().render(corr) >>> fig.savefig("factor_correlation.png")