|
||||||||
Generating Heatmaps for Grouped Data Occurrences - Python Automation and Machine Learning for ICs - - An Online Book: Python Automation and Machine Learning for ICs by Yougui Liao - |
||||||||
| Python Automation and Machine Learning for ICs http://www.globalsino.com/ICs/ | ||||||||
| Chapter/Index: Introduction | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | Appendix | ||||||||
================================================================================= Generating heatmaps for grouped data occurrences. Code: This script is designed to visualize data from a CSV file by generating heatmaps that display the occurrences of "X" and "Y" pairs within specific subgroups of the dataset. The data is grouped by three columns: 'Name', 'Z', and 'Grades', creating subgroups within the dataset. For each subgroup, it computes a pivot table to aggregate the occurrences of each "X" and "Y" pair, using 'X' values as columns, 'Y' values as rows, and counting the number of occurrences as the cell values. Missing pairs (i.e., those not appearing in the subgroup) are filled with 0 to indicate their absence. A heatmap is then plotted for each subgroup with seaborn, using the viridis color map to visually represent the count of occurrences. Annotations on the heatmap display the exact counts, making it easy to identify the frequency of each "X" and "Y" pair within the subgroup. Each heatmap is accompanied by a title that includes the subgroup's 'Name', 'Z', and 'Grades' values, along with labels for the 'X' and 'Y' axes, enhancing clarity and interpretability. =========================================== Cells with a value of 0 have no color fill and no text annotation when generating heatmaps for grouped data occurrences. Code:
=========================================== Plot heatmap under condition that any missing pairs in the data are represented with 0 occurrences. Code:
=========================================== Plot heatmap under condition that any missing pairs in the data are represented with 0 occurrences, and the 'X' values are shifted 5 units in the negative direction and the 'Y' values are shifted 5 units in the positive direction by applying transformations to these columns after generating the xy_grid DataFrame but before merging it with the grouped data. Code:
|
||||||||
| ================================================================================= | ||||||||
|
|
||||||||