1
$\begingroup$

I would like to use the weighted sum method to select the best number of clusters out of the 34 options. As weights I would like to use 0.5 for each criterion. The coverage criterion is to minimize and the production criterion is to maximize.

This question is similar to this question: Use the Weighted Sum Method in R

I solved the question, but I would like to know if it is correct.

library(dplyr)

df1<-structure(list(nclusters = c(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 
28, 29, 30, 31, 32, 33, 34, 35), Coverage = c(0.0363201192049018, 
0.0315198954715543, 0.112661460735583, 0.112661460735583, 0.112661460735583, 
0.0813721071219816, 0.0862146652218061, 0.0697995564757394, 0.0599194966471805, 
0.0507632014547115, 0.052076958349629, 0.052076958349629, 0.052076958349629, 
0.052076958349629, 0.052076958349629, 0.052076958349629, 0.0410332568832433, 
0.0389940601722214, 0.0441742111970355, 0.0441742111970355, 0.0441742111970355, 
0.0438099091238968, 0.0409906284310306, 0.0409906284310306, 0.035480410134286, 
0.035480410134286, 0.035480410134286, 0.035480410134286, 0.035480410134286, 
0.035480410134286, 0.035480410134286, 0.0345381204372174, 0.0287729883480053, 
0.0287729883480053), Production = c(1635156.04305, 474707.64025, 
170773.40775, 64708.312, 64708.312, 64708.312, 949.72635, 949.72635, 
949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 
949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 
949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 
949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 949.72635, 
949.72635, 949.72635)), class = "data.frame", row.names = c(NA,-34L))

weights <- c(0.5,0.5) 

scaled <- df1 |>
  mutate(Coverage = min(Coverage) / Coverage,
         Production = Production / max(Production))

scaled <- scaled |>
  rowwise() |>
  mutate(`Performance Score` = weighted.mean(c(Coverage, Production), w = weights))

scaled$Rank <- (nrow(scaled) + 1) - rank(scaled$`Performance Score`)

scaled
# A tibble: 34 x 5
# Rowwise: 
   nclusters Coverage Production `Performance Score`  Rank
       <dbl>    <dbl>      <dbl>               <dbl> <dbl>
 1         2    0.792   1                     0.958    1  
 2         3    0.913   0.290                 0.415    2  
 3         4    0.255   0.104                 0.135   17  
 4         5    0.255   0.0396                0.0827  32.5
 5         6    0.255   0.0396                0.0827  32.5
 6         7    0.354   0.0396                0.102   29  
 7         8    0.334   0.000581              0.0672  34  
 8         9    0.412   0.000581              0.0829  31  
 9        10    0.480   0.000581              0.0965  30  
10        11    0.567   0.000581              0.114   22  
# ... with 24 more rows
$\endgroup$

1 Answer 1

3
$\begingroup$

The GeeksForGeeks page linked in your previous question provides one possible way to scale your attributes. Using that scaling method, your code is correct and two clusters has the highest performance score. I tried a couple of other common scaling methods (such as normalizing each column) and it seemed pretty consistent that two clusters won, three clusters came in second, and 34 and 35 clusters tied for third.

$\endgroup$
3
  • $\begingroup$ Thanks for the answer! @prubin, do you know if I can use other multicriteria methods on this dataset? In this question I used WSM but I've also done it using TOPSIS and both gave very similar results. Now I need two other different methods, but I don't know which one to use.. Got any tips? And if so, do you know how you can do it? Can I ask a new question about this. $\endgroup$
    – Antonio
    Commented Feb 16, 2022 at 18:35
  • 1
    $\begingroup$ There are lots of multicriteria methods, and choosing among them seems to be mainly a matter of taste. Most if not all of them would be applicable in the sense that it is possible to implement them. I would suggest a new question (not necessarily specific to R), explaining what you want in general terms (balancing two measures one where you want a maximum and the other where you want a minimum), and specifying whether the "best" choice would be best in terms of one person's preferences, the collective preferences of multiple decision makers, or what. $\endgroup$
    – prubin
    Commented Feb 16, 2022 at 19:08
  • 1
    $\begingroup$ There's one rather "low-tech" alternative that should not be ignored. Plot the (unscaled) coverage and production values, one point for each value of "nClusters". Show the plot to the boss and say "pick one". (You might want to find a more tactful phrasing.) $\endgroup$
    – prubin
    Commented Feb 16, 2022 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.