X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=clusterer.cc;h=5bf04aa68f5d5a86c6c0b85dca17bcef448aaa25;hb=60785fe128e964f3d124e9b49cce9154501e53cb;hp=54183416cd7f34a81d54ebb3ac78d88ee6ccc9e8;hpb=30a7eaeed7e34e69b62d2920e074a113a6e850fc;p=clueless-kmeans.git diff --git a/clusterer.cc b/clusterer.cc index 5418341..5bf04aa 100644 --- a/clusterer.cc +++ b/clusterer.cc @@ -1,17 +1,17 @@ /* - * clueless-kmean is a variant of k-mean which enforces balanced + * clueless-kmeans is a variant of k-means which enforces balanced * distribution of classes in every cluster * * Copyright (c) 2013 Idiap Research Institute, http://www.idiap.ch/ * Written by Francois Fleuret * - * This file is part of clueless-kmean. + * This file is part of clueless-kmeans. * - * clueless-kmean is free software: you can redistribute it and/or + * clueless-kmeans is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 3 as published by the Free Software Foundation. * - * clueless-kmean is distributed in the hope that it will be useful, + * clueless-kmeans is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. @@ -35,8 +35,6 @@ Clusterer::~Clusterer() { } scalar_t Clusterer::distance_to_centroid(scalar_t *x, int k) { - // We take the variance into account + the normalization term. This - // is between k-mean and EM with a diagonal covariance scalar_t dist = 0; for(int d = 0; d < _dim; d++) { dist += sq(_cluster_means[k][d] - x[d]) / (2 * _cluster_var[k][d]); @@ -208,14 +206,17 @@ scalar_t Clusterer::uninformative_lp_cluster_association(int nb_points, scalar_t glp_add_cols(lp, nb_points * _nb_clusters); + // The column for gamma[n][k] point 1<=n<=nb_points and cluster + // 1<=k<=_nb_clusters is nb_points * (k - 1) + n; + // The constraints (A) will be expressed by putting directly bounds // on the variables (i.e. one per column). So we need one row per // (B) constraint, and one per (C) constraint. glp_add_rows(lp, nb_points + _nb_clusters * nb_classes); - // First, we set the weights for the objective function, and the - // constraint on the individual gammas + // First, we set the weights for the objective function, and the (A) + // constraints on the individual gammas for(int k = 1; k <= _nb_clusters; k++) { for(int n = 1; n <= nb_points; n++) {