# commons-issues mailing list archives

##### Site index · List index
Message view
Top
From "Thomas Neidhart (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (MATH-1165) Rare case for updateMembershipMatrix() in FuzzyKMeansClusterer
Date Fri, 07 Nov 2014 22:10:33 GMT
```
[ https://issues.apache.org/jira/browse/MATH-1165?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Thomas Neidhart resolved MATH-1165.
-----------------------------------
Resolution: Fixed

Yes, I realized this while working on the fix.

The implemented fix takes care of these cases too now, so I assume this issue can be closed
safely.

If you still encounter problems with the code in trunk, please let us know.

> Rare case for updateMembershipMatrix() in FuzzyKMeansClusterer
> --------------------------------------------------------------
>
>                 Key: MATH-1165
>                 URL: https://issues.apache.org/jira/browse/MATH-1165
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.3
>            Reporter: Pashutan Modaresi
>            Priority: Minor
>              Labels: easyfix
>             Fix For: 3.4
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> 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)
> Adding the following condition can solve the problem:
> double d;
> if (sum == 0)
> d = 1;
> else
> d = 1.0/sum;

--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

```
Mime
View raw message