bestLabels gives the label for each data-point where the label refers to a possible cluster-index which were produced, e.g. you cluster your data with K=100, so you have cluster-labels 0-99, now each data vector gets one of these labels, i.e. you will get an output matrix w. 100 rows and 1 column.