Grouping data in segments of two and three variables
Now, we are going to segment data with two variables. Several real-world problems need to group two or more variables to classify data where one variable influences the other. For example, we can use the month number and the sales revenue dataset to find out the time of the year with higher and lower sales. We will use online marketing and sales revenue. Figure 1.8 shows the four segments of the data and the relationship between online marketing investment and revenue. We can see that segments 1, 2, and 4 are relatively compact. The exception is segment 3 because it has a point that appears to be an outlier. This outlier will affect the average and the standard deviation of the segment:
Segment 4 appears to have the smallest standard deviation. This group looks compact. Segment 2 also appears to be compact and it has a high value of revenue.
In Figure 1.9, we will find out the mean and the standard deviation of segment 2:
As we are analyzing two variables, the centroid of the segment has two coordinates: the online marketing spend and the revenue.
The mean has the following coordinates:
- Online marketing: 5.04
- Revenue: 204.11
In Figure 1.9, the centroid is at these coordinates.
The standard deviation of online marketing is 1.53, and for revenue, it is 76.63.
The limits of the revenue are the black lines. They are 160 and 280. So, segment two is not compact because the majority of points are between 160 and 210 with an outlier close to 280.
When we analyze data with three variables, the mean and the standard deviation are represented by three coordinates. Figure 1.10 shows data with three variables and the segment that each of them belongs to:
The mean and standard deviation have three coordinates. For example, for segment three, these are the coordinates:
The standard deviation of revenue is large, 13.73. This means the points are widely scattered from the centroid, 15.8. This segment probably does not give accurate information because the points are not compact.