# How to understand 3X3 confusion matrix in R from prediction results?

I am trying to cluster my data points in 3 groups using k-means for a time series. Let's say at time t=T, I have 3 clusters A, B, and C. Taking this as reference, I march forward in time cluster the datapoints at t= T+1, T+2 and so on.. and I create a confusion matrix using CrossTable for the predictions and actual clusters in R. I need help to understand the confusion matrix generated. Here is one output:

       Cell Contents
|-------------------------|
|                       N |
| Chi-square contribution |
|           N / Row Total |
|           N / Col Total |
|         N / Table Total |
|-------------------------|

Total Observations in Table:  1803

| vel1\$clus
predictions |         1 |         2 |         3 | Row Total |
-------------|-----------|-----------|-----------|-----------|
1 |       528 |         0 |         0 |       528 |
|   901.622 |   159.015 |   214.363 |           |
|     1.000 |     0.000 |     0.000 |     0.293 |
|     1.000 |     0.000 |     0.000 |           |
|     0.293 |     0.000 |     0.000 |           |
-------------|-----------|-----------|-----------|-----------|
2 |         0 |       543 |         1 |       544 |
|   159.308 |   877.519 |   218.863 |           |
|     0.000 |     0.998 |     0.002 |     0.302 |
|     0.000 |     1.000 |     0.001 |           |
|     0.000 |     0.301 |     0.001 |           |
-------------|-----------|-----------|-----------|-----------|
3 |         0 |         0 |       731 |       731 |
|   214.070 |   220.151 |   635.316 |           |
|     0.000 |     0.000 |     1.000 |     0.405 |
|     0.000 |     0.000 |     0.999 |           |
|     0.000 |     0.000 |     0.405 |           |
-------------|-----------|-----------|-----------|-----------|
Column Total |       528 |       543 |       732 |      1803 |
|     0.293 |     0.301 |     0.406 |           |
-------------|-----------|-----------|-----------|-----------|


What I know:

The first numerical value in each cell (528, 0, 0, 0, 543, 1, 0, 0, 731) represents the number of data points that are there in reference clusters and have gone to some other cluster. For example 1 data point from cluster 3 has gone to cluster 2 (indicated by numerical value 1 in cell (2,3)).

It also gives the probability that each observation belongs to a particular class rather than predicted class.

What I don't know:

Which ones are the probability values?

What do the other 4 numerical values represent?

Is there any other crucial information here that I need to understand?

Thank You.

• I also figured that the last number in each cell is the probability of a data point to be in group 1, 2 or 3. For example, in the cell (1,1), 0.293 is the probability of a data point to be in group 1 (528/1803) and so on for other cells. Also, in Row total, 544 is the number of data points predicted to be in cluster 2 along with its probability to be in cluster 2?? What are the other 3 numbers in each cell? Commented Apr 5, 2018 at 12:43
• I am voting to leave this open. This sort of matrix is not at all specific to R. Commented Apr 5, 2018 at 14:13