1
$\begingroup$

I am doing some clustering analysis with Weka and decided to apply the k-means algorithm (the clusterer SimpleKMeans).

On my first analysis I ran the algorithm with 2 clusters.

Then, after finding the optimal K, using the EM Clustering (using -1 in numCluster, which forces it to find the number of clusters), I have changed the number of clusters to that optimum value (in this case it was 6).

Then, when reading an article on clustering, I have came across to the term MSE (mean squared error) and was wondering how can I calculate it from the output (I'll leave the output bellow)? Does that correspond to the "Within cluster sum of squared errors"?


Output

=== Run information ===
Scheme:       weka.clusterers.SimpleKMeans -init 0 -max-candidates 100 -periodic-pruning 10000 -min-density 2.0 -t1 -1.25 -t2 -1.0 -N 6 -A "weka.core.EuclideanDistance -R first-last" -I 500 -num-slots 1 -S 10
Relation:     bank
Instances:    600
Attributes:   11
              age
              sex
              region
              income
              married
              children
              car
              save_act
              current_act
              mortgage
              pep
Test mode:    evaluate on training data
=== Clustering model (full training set) ===
kMeans
======
Number of iterations: 6
Within cluster sum of squared errors: 1604.7416693522332
Initial starting points (random):
Cluster 0: 25,FEMALE,RURAL,14505.3,NO,3,NO,YES,YES,NO,NO
Cluster 1: 61,FEMALE,RURAL,22942.9,YES,2,NO,YES,YES,NO,NO
Cluster 2: 54,FEMALE,INNER_CITY,31095.6,YES,2,NO,NO,YES,NO,YES
Cluster 3: 36,FEMALE,TOWN,26920.8,YES,0,NO,NO,YES,NO,NO
Cluster 4: 42,MALE,INNER_CITY,15499.9,YES,0,YES,NO,YES,YES,YES
Cluster 5: 50,MALE,TOWN,40972.9,NO,2,YES,YES,YES,YES,YES
Missing values globally replaced with mean/mode
Final cluster centroids:
                           Cluster#
Attribute      Full Data          0          1          2          3          4          5
                 (600.0)     (77.0)     (76.0)     (77.0)    (147.0)    (106.0)    (117.0)
==========================================================================================
age               42.395    37.1299    44.2763    48.3117    39.1156    39.3019    47.6667
sex               FEMALE     FEMALE     FEMALE     FEMALE     FEMALE       MALE       MALE
region        INNER_CITY INNER_CITY      RURAL INNER_CITY       TOWN INNER_CITY       TOWN
income        27524.0312 23377.7604 27772.3746 27668.4396 24047.3865    26359.8 35419.2842
married              YES         NO        YES        YES        YES        YES         NO
children               0          3          2          1          0          0          2
car                   NO         NO         NO         NO         NO        YES        YES
save_act             YES        YES        YES         NO        YES         NO        YES
current_act          YES        YES        YES        YES        YES        YES        YES
mortgage              NO         NO         NO         NO         NO        YES         NO
pep                   NO         NO         NO        YES         NO        YES        YES
Time taken to build model (full training data) : 0.01 seconds
=== Model and evaluation on training set ===
Clustered Instances
0       77 ( 13%)
1       76 ( 13%)
2       77 ( 13%)
3      147 ( 25%)
4      106 ( 18%)
5      117 ( 20%)
$\endgroup$
2
$\begingroup$

Obviously the mean squared error is the total sum of errors divided by the number of instances n, the number of variables p, or their product n*p. You can easily compute either with a calculator.

Beware that k-mrans on categoricial variables tends to produce pretty meaningless results. It is also sensitive to scaling. Given your variable names, I doubt that the result will be sound.

$\endgroup$
  • $\begingroup$ Considering that the output that I get is "Within cluster sum of squared errors", should I divide by the number of clusters or the number of instances? Also, would you suggest to run the algorithm with all the numeric values normalized? $\endgroup$ – Goncalo Peres supports Monica May 5 at 7:57
  • 1
    $\begingroup$ Depends on which version you want. Also beware that Weka uses a built-in normalization. So the values will likely not be comparable anyway. $\endgroup$ – Anony-Mousse May 6 at 2:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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