More self-documenting code.
diff --git a/src/main/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClusterer.java b/src/main/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClusterer.java
index 7036ccb..806b248 100644
--- a/src/main/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClusterer.java
+++ b/src/main/java/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClusterer.java
@@ -58,7 +58,7 @@
}
/** The number of clusters. */
- private final int k;
+ private final int numberOfClusters;
/** The maximum number of iterations. */
private final int maxIterations;
@@ -143,7 +143,7 @@
final UniformRandomProvider random,
final EmptyClusterStrategy emptyStrategy) {
super(measure);
- this.k = k;
+ this.numberOfClusters = k;
this.maxIterations = maxIterations;
this.random = random;
this.emptyStrategy = emptyStrategy;
@@ -153,8 +153,8 @@
* Return the number of clusters this instance will use.
* @return the number of clusters
*/
- public int getK() {
- return k;
+ public int getNumberOfClusters() {
+ return numberOfClusters;
}
/**
@@ -182,8 +182,8 @@
MathUtils.checkNotNull(points);
// number of clusters has to be smaller or equal the number of data points
- if (points.size() < k) {
- throw new NumberIsTooSmallException(points.size(), k, false);
+ if (points.size() < numberOfClusters) {
+ throw new NumberIsTooSmallException(points.size(), numberOfClusters, false);
}
// create the initial clusters
@@ -328,7 +328,7 @@
}
}
- while (resultSet.size() < k) {
+ while (resultSet.size() < numberOfClusters) {
// Sum up the squared distances for the points in pointList not
// already taken.
@@ -382,7 +382,7 @@
// Mark it as taken.
taken[nextPointIndex] = true;
- if (resultSet.size() < k) {
+ if (resultSet.size() < numberOfClusters) {
// Now update elements of minDistSquared. We only have to compute
// the distance to the new center to do this.
for (int j = 0; j < numPoints; j++) {
diff --git a/src/main/java/org/apache/commons/math4/ml/clustering/MiniBatchKMeansClusterer.java b/src/main/java/org/apache/commons/math4/ml/clustering/MiniBatchKMeansClusterer.java
index e54f25d..a563fda 100644
--- a/src/main/java/org/apache/commons/math4/ml/clustering/MiniBatchKMeansClusterer.java
+++ b/src/main/java/org/apache/commons/math4/ml/clustering/MiniBatchKMeansClusterer.java
@@ -106,8 +106,8 @@
public List<CentroidCluster<T>> cluster(final Collection<T> points) {
// Sanity check.
MathUtils.checkNotNull(points);
- if (points.size() < getK()) {
- throw new NumberIsTooSmallException(points.size(), getK(), false);
+ if (points.size() < getNumberOfClusters()) {
+ throw new NumberIsTooSmallException(points.size(), getNumberOfClusters(), false);
}
final int pointSize = points.size();