# How do I find similarities between two sets of data

I have a group of data with 12 different football players, and they are rated for 11 different skills (speed, skill, flair, etc).

I am looking to pair up individuals based on similar footballers, and was thinking of just taking the average for each player and matching them up.

Does anyone have any better suggestions, i.e. a statistical test to see which players are best matched. And from this we can have fair teams...

Hope this makes sense,

+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
|             |player|player|player|player|player|player|player|player|player|player|player|player|
|             |     1|     2|     3|     4|     5|     6|     7|     8|     9|    10|    11|    12|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
| Speed       |  12.1|  15.9|  10.9|  12.4|   7.6|  13.6|   9.3|   6.9|  13.4|   8.6|   4.7|  13.1|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
| Skill       |   8.1|  14.1|  13.6|   7.7|   6.0|  10.4|   8.1|   7.0|  13.1|   9.7|  17.4|  14.7|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
| Flair       |   6.6|  13.3|  11.3|   7.4|   5.9|  10.0|   8.1|   8.4|  13.6|   8.1|  16.6|  15.0|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
| Finishing   |   9.4|  13.3|  11.3|   7.4|   7.4| 12.00|  10.6|  11.9|  13.4|  17.4|  13.6|  12.3|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
| Long  Shots |  10.1|  13.1|  11.6|   7.4|   6.6|   8.7|  10.7|  13.6|  13.4|  15.6|  12.4|   9.6|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
| Crossing    |  10.0|  12.7|  15.7|   9.6|   6.6|  10.3|  11.3|   9.9|  11.7|   8.9|  13.6|  11.1|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
| Dribbling   |  12.0|  15.0|  13.3|   9.3|   7.1|  11.0|  10.6|   8.4|  12.7|  10.3|  16.1|  13.9|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
| Tackling    |  18.4|  14.7|   8.3|  15.1|   9.3|   5.0|  14.6|  11.9|  13.0|   7.4|   9.6|   5.9|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
| Heading     |  14.7|  15.9|   8.4|  11.6|   7.7|   5.0|  13.1|   9.6|  13.1|  13.1|   8.0|   6.3|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
|Determination|  19.0|  14.9|   9.1|  15.6|  11.7|   7.9|  14.4|  10.9|  12.9|  12.1|  11.4|   5.1|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
| Passing     |  12.9|  15.1|  15.9|   9.6|   9.3|  11.3|  12.1|  10.9|  16.3|  11.1|  17.6|  13.3|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
| Total       | 121.3| 142.1| 118.4| 100.7|  77.6|  91.6| 113.7| 102.3| 133.3| 113.9| 136.3| 107.1|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
| Maximum     |   220|   220|   220|   220|   220|   220|   220|   220|   220|   220|   220|   220|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+
| Index rating| 55.13| 64.61| 53.83| 45.78| 35.26| 41.62| 51.69| 46.49| 60.58| 51.75| 61.95| 48.70|
+-------------+------+------+------+------+------+------+------+------+------+------+------+------+

-
You could try a clustering algorithm. It may even be enough to look at the first dimension returned by PCA to get an idea of how the players are differing. –  Max Aug 21 '12 at 16:32
add comment

## Nominal solution

For pairings, you have to decide how much to weight the different characteristics. Having done that, a hierarchical clustering can be informative: you can read good pairings right off the dendrogram. Using this flexible, visual approach might be more useful in the field--and for adjusting to dynamic situations, such as the absences of some players--than more formal methods would.

For instance, with no weights (that is, equal weights), we can do the computation starting with data in transposed format:

Player,Speed,Skill,Flair,Finishing,Long,Crossing,Dribbling,Tackling,Heading,Determination,Passing
1,12.1,8.1,6.6,9.4,10.1,10,12,18.4,14.7,19,12.9
2,15.9,14.1,13.3,13.3,13.1,12.7,15,14.7,15.9,14.9,15.1
...
12,13.1,14.7,15,12.3,9.6,11.1,13.9,5.9,6.3,5.1,13.3


Here is R code to carry out the clustering:

data <- read.table("f:/temp/football.csv", header=TRUE, sep=",")
fit <- hclust(dist(data[,-1])) # Excludes player number from the calculation!
plot(fit)


Starting at the bottom, we see that players 2 and 9, 4 and 7, 6 and 12, and 8 and 10 ought to be paired. Then, 3 and 11 might go together, leaving 5 and 1 as partners.

In addition to the weights, the clustering method can affect results. If there are not too many players to pair, a little experimentation might give some further guidance: look for pairs who tend to stay together no matter what technique is used.

## Focused solution

The question, however, does not seem to be about pairings of individuals: it appears to concern forming teams of nearly equal strength. We can formulate this version of the question by assuming the strength of a team is the sum of strengths of its individuals. Then, noting that the number of players is small (12), we can do a brute-force search over all possible six-person teams to find the pair that are most evenly matched.

Bearing in mind the importance of weighting the attributes, a simple way to compare two teams is in terms of some vector distance between their strengths. Using the sum of absolute differences (the $L^1$ metric) gives the following solution:

library(gtools)
s <- apply(data[,-1], 2, sum)
f <- function(i) {
x <- apply(data[i,-1], 2, sum)
sum(abs(s - 2*x))
}
n <- length(data[[1]])
teams <- combinations(n, floor(n/2))
dist <- apply(teams, 1, f)
i.min <- which.min(dist)
teams[i.min, ]
f(teams[i.min,])


This search reports a team comprised of players 1, 3, 5, 9, 10, and 12 ("team.1"); the remaining players form the other team ("team.2"). Their average skills are

       Speed Skill Flair Finishing Long Crossing Dribbling Tackling Heading Determination Passing
team.1  11.0  10.9  10.1      11.9 11.2     10.7      11.5     10.4    10.5          11.6    13.1
team.2  10.5  10.8  10.6      11.5 11.0     11.2      11.7     11.8    10.5          12.5    12.8

-
add comment

One possibility is for each player to compute his average squared deviation in score with the other players over the 11 categories. Then match the player with the one that has the smallest average squared deviation. You can pair up players this way to match them on skill level. There might need to be a method chosen for breaking ties.

-
add comment