1
$\begingroup$

I've created a list of associations composed of userId's and average times for different sessions:

data =
  {<|"userId" -> 5311, "AverageS1Time" -> 4691/9, "AverageS2Time" -> 9489/7, "AverageS3Time" -> 1345.08|>,
   <|"userId" -> 5312, "AverageS1Time" -> 53/2, "AverageS2Time" -> 0, "AverageS3Time" -> 0.|>,
   <|"userId" -> 5313, "AverageS1Time" -> 5, "AverageS2Time" -> 169/2, "AverageS3Time" -> 0|>,
   <|"userId" -> 5314, "AverageS1Time" -> 21958/13, "AverageS2Time" -> 889/10, "AverageS3Time" -> 957.154|>,
   <|"userId" -> 5315, "AverageS1Time" -> 50127/10, "AverageS2Time" -> 302954/17, "AverageS3Time" -> 218.278|>}

I would now like to—based on all of the average times in the sessions—find clusters of similar behavior, i.e., finding people who spent similar amounts of time in the same session on average and group them together.

Applying:

FindClusters[
 data[All,  
   N[{"userId", "AverageS1Time", "AverageS2Time", "AverageS3Time"}]] // 
  Normal, 5]

just gives me a list of clusters dependent on the userId.

Could someone give me a hint, how you can cluster based on behavior in different sessions (i.e., average scored time in subsequent sessions over time)?

Thanks a lot

$\endgroup$

1 Answer 1

2
$\begingroup$

There is a syntax, which is documented, that clusters one set of elements and returns another set of elements. This is what you'll want to use.

elements = #[[{"AverageS1Time", "AverageS2Time", "AverageS3Time"}]] -> # & /@ data;
FindClusters[elements]
$\endgroup$
1
  • $\begingroup$ Or simply FindClusters[#[[{"AverageS1Time", "AverageS2Time", "AverageS3Time"}]] -> #[["userId"]] & /@ data] if you are looking for the clusters of userId values. This returns {{5311, 5314}, {5312, 5313}, {5315}}. $\endgroup$
    – Roman
    May 5, 2019 at 11:46

Your Answer

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

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