AI Glossary / Data science and analytics / Intermediate
Heatmap
Definition
A heatmap is a visualization that represents numerical values using color. In a common matrix heatmap, each cell belongs to a row and column, and its color indicates a value for that combination. The term is also used for geographic or screen-based displays of intensity. A heatmap encodes data visually; it does not, by itself, explain causes or establish statistical significance.
What it means
A large table can contain patterns that are difficult to notice by reading individual numbers. Color can make concentrations, contrasts, and unusual cells easier to spot. A support dashboard might place days in columns and hours in rows, with each cell showing the number of incoming requests. The meaning of the picture depends on what the cells measure, how values are aggregated, and how the color scale is defined.
How it works
Choose the row and column dimensions, calculate one clearly defined value for each cell, and map those values to colors. A legend or colorbar connects color to numerical meaning. A sequential palette can represent an ordered range such as low to high counts. A diverging palette can show departures on either side of a meaningful midpoint, such as zero change. The transformation from values to colors may be linear or nonlinear and should be disclosed when it affects interpretation. Missing observations need a distinct treatment so readers do not mistake them for measured zeros.
Three practical examples
- Service operations: a day-by-hour heatmap displays request volume to help investigate recurring peaks before adjusting staffing.
- Model evaluation: a colored confusion matrix highlights which actual classes are most often assigned to other classes.
- Performance monitoring: a product-by-region heatmap displays a consistent measure, such as average response time, across many combinations.
Think of it this way
Think of coloring the cells of a timetable according to how busy each period is. The colors let the eye scan for patterns before reading exact numbers. The analogy does not imply literal heat, and a strongly colored cell is not automatically an emergency. Its significance depends on the measurement, scale, and decision context.
Worked example
Consider two departments over three days. Department A receives 10, 20, and 30 requests; department B receives 100, 200, and 300. With one common linear scale from 0 to 300, A's values occupy the low end and B's final day reaches the high end. This display helps compare absolute workloads.
Now normalize each row separately by dividing by that row's maximum. Both rows become approximately 0.33, 0.67, and 1.00. Their colors can therefore look identical, even though B handles ten times as many requests on each day. This second view helps compare the within-row pattern, but it cannot support a comparison of absolute volume from color alone. If the normalized view is used, its title and legend should say what was transformed. Keeping the original counts in cell labels or an accompanying table can preserve context. Neither representation is inherently wrong; each answers a different question.
Illustrative case study
In a fictional customer-support project, a manager sees a dark patch in a weekly heatmap and assumes service quality has deteriorated. The analyst explains that the cells show total complaints, while the number of completed transactions has also increased. The team adds a separate complaints-per-transaction view, displays the underlying denominators, and marks low-volume cells for cautious interpretation. It keeps the count view for staffing decisions. The case illustrates how the same records can support different useful measures without establishing a cause for the observed pattern.
Common misconceptions and mistakes
Heatmap colors are not universal: darker, brighter, or redder can mean different things in different displays. Comparing panels with independently scaled colors can be misleading. Row normalization may remove the magnitude differences that matter to a decision. A correlation heatmap shows pairwise association, not causation, and a bright cell does not imply a statistically reliable effect. Interpolating or smoothing values can suggest detail that was not directly observed. Category ordering can also change visible patterns even when all underlying numbers remain the same.
Business use
Use a heatmap when many comparable values must be scanned for a pattern. State the metric, unit, aggregation period, and denominator where relevant. Keep a shared scale when the purpose is to compare magnitudes across panels. Provide readable labels, a clear legend, and access to values when exact comparisons matter. Choose a palette that remains interpretable for the intended audience, including readers with color-vision differences. Test the display with the question it is meant to answer: finding the busiest hour may require a different measure from finding the highest failure rate.
People also ask
Does a heatmap have to show temperature?
No. Color can encode many numerical measures.
Can two equal colors mean different numbers?
Yes, if the plots use different scales or values were normalized separately.
Is a heatmap an AI explanation?
Sometimes it is used in an explanation method, but color alone does not validate that method or prove why a model made a decision.
Check your understanding
Why do departments A and B look identical after dividing each row by its maximum?
Answer: Both have the same relative pattern of one-third, two-thirds, and one times their own maximum. The normalization removes their tenfold difference in absolute workload from the color encoding.
Related terms
- Data visualization
- Normalization
- Confusion matrix
- Correlation matrix
- Missing data
- color scale
- spatial density
- dashboard
Learn next
Build a small matrix view with a shared scale and then with row-wise normalization. Write down which questions each view can answer. Next, compare sequential and diverging color scales using data with a meaningful midpoint. Learn to distinguish raw counts from rates before using heatmaps to compare groups of different sizes.
More in Data science and analytics
- Goodness-of-fit - Goodness of fit describes how well a statistical model agrees with the data being examined.
- Greedy algorithms - Greedy algorithms build a solution by repeatedly choosing the option that looks best according to a specified local rule.
- Harking - HARKing means hypothesizing after the results are known and presenting the resulting hypothesis as though it had been proposed before examining those results.
- Histogram - A histogram displays the distribution of numerical observations by dividing their range into intervals, called bins, and drawing a bar for each interval.
- Immutable Data Types - Immutable data types are types whose objects do not support changes to their own value after creation.
- Independent Events - Independent events are events for which the probability of their joint occurrence equals the product of their individual probabilities: P(A and B) = P(A)...
Sources
Matplotlib, scalar-image rendering and color mapping: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.imshow.html Matplotlib, choosing color maps and accessibility considerations: https://matplotlib.org/stable/users/explain/colors/colormaps.html Matplotlib, normalization between values and colors: https://matplotlib.org/stable/users/explain/colors/colormapnorms.html
Previous: Hearst patterns Next: Heavy-tailed distribution