Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1165

Rare case for updateMembershipMatrix() in FuzzyKMeansClusterer

Rank to TopRank to BottomBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersConvert to sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.3
    • 3.4
    • None

    Description

      The function updateMembershipMatrix() in FuzzyKMeansClusterer assigns the points to the cluster with the highest membership. Consider the following case:

      If the distance between a point and the cluster center is zero, then we will have a cluster membership of one, and all other membership values will be zero.

      So the if condition:
      if (membershipMatrix[i][j] > maxMembership) {
      maxMembership = membershipMatrix[i][j];
      newCluster = j;
      }
      will never be true during the for loop and newCluster will remain -1. This will throw an exception because of the line:
      clusters.get(newCluster)
      .addPoint(point);

      Adding the following condition can solve the problem:
      double d;
      if (sum == 0)
      d = 1;
      else
      d = 1.0/sum;

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            pasmod Pashutan Modaresi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified

                Slack

                  Issue deployment