Skip to content

Correlation Coefficient and Visualization ​

This page covers the correlation coefficient, which shows the relationship between variables as a number, and how to pick the right chart for a question.

Correlation Coefficient ​

A value from -1 to 1 that shows how much two variables move together (Pearson correlation coefficient). Close to 1 means they increase together, close to -1 means one decreases as the other increases, and close to 0 means there is almost no linear relationship. A high correlation does not mean one causes the other.

In A1-1, the correlation coefficient between unit price and quantity was -0.379, showing a tendency to buy more of cheaper products. Image mean and amount was -0.012, almost 0. Since the images were attached at random, this was the expected result.

6 Visualization Types ​

ChartUse it whenWhat was drawn in A1-1
HistogramShowing the shape of one value's distributionQuantity and unit price distributions
Box plotQuartiles and outliers, comparing before and after processingQuantity before and after clipping
Bar chartComparing counts by categoryNumber of customers per segment
HeatmapShowing table-shaped values as colorsCorrelation matrix between variables
Scatter plotRelationship between two numeric variablesUnit price and quantity (sample of 5,000)
Line chartChange over timeMonthly sales trend

Interview Questions ​

Q. If the correlation coefficient between unit price and quantity is -0.379, how do you interpret it? ​

This checks whether you go beyond reading the number and also know what the correlation coefficient doesn't tell you.

It is a negative correlation, so there is some tendency for order quantities to be smaller as the unit price gets higher. However, the correlation coefficient only looks at linear relationships. Also, in A1-1 it was calculated with outlier-clipped values, so the number could be different if calculated with the original values. You can't go as far as claiming a causal relationship that people buy more because the unit price is low.

Follow-up Questions ​

  • If the correlation coefficient is high, is one variable the cause of the other? → No. It only means they move together, and there may be another factor affecting both variables.

Source: dubu-alt/A1-1 (Codyssey AI Advanced A1-1 mission)