Allegra-Cohen / grid

GNU General Public License v3.0
1 stars 3 forks source link

Documents that are used to seed multiple clusters may be lost to clusters #69

Open kwalcock opened 1 year ago

kwalcock commented 1 year ago

In code like this where d2s_extended is added, the values may not make the threshold if the document was included in two clusters. In that case, each gets 0.5 instead of the 1.0, so they will need some help from the seeded_matrix, but may not get it. If they are in three seeded clusters, they get 0.33 each, so it gets less probably that they will make it. This could be a bug or a features. If it is important that they stay in the seeded clusters, the condition might change. They can make the threshold or just be a non-zero in d2s_extended.

def assign_soft_labels(self, d2s_extended):
    # Replace the matrix with the appropriate assignments for the seeded documents:
    seeded_matrix = self.matrix.copy()
    if d2s_extended.size != 0:
        seeded_matrix += d2s_extended # Zeros won't affect non-seeded, but seeded will become greater than one and thus will always match the threshold
    self.clusters = list(map(lambda i: self.documents[np.where(seeded_matrix[:, i] >= self.threshold)[0]], range(seeded_matrix.shape[1])))