[mlpack-svn] r14236 - mlpack/branches/mlpack-1.x/src/mlpack/methods/kmeans
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Feb 8 15:27:34 EST 2013
Author: rcurtin
Date: 2013-02-08 15:27:34 -0500 (Fri, 08 Feb 2013)
New Revision: 14236
Modified:
mlpack/branches/mlpack-1.x/src/mlpack/methods/kmeans/
mlpack/branches/mlpack-1.x/src/mlpack/methods/kmeans/kmeans_impl.hpp
mlpack/branches/mlpack-1.x/src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp
Log:
Minor code changes and style updates.
Property changes on: mlpack/branches/mlpack-1.x/src/mlpack/methods/kmeans
___________________________________________________________________
Added: svn:mergeinfo
+ /mlpack/trunk/src/mlpack/methods/kmeans:13981-14235
Modified: mlpack/branches/mlpack-1.x/src/mlpack/methods/kmeans/kmeans_impl.hpp
===================================================================
--- mlpack/branches/mlpack-1.x/src/mlpack/methods/kmeans/kmeans_impl.hpp 2013-02-08 20:27:12 UTC (rev 14235)
+++ mlpack/branches/mlpack-1.x/src/mlpack/methods/kmeans/kmeans_impl.hpp 2013-02-08 20:27:34 UTC (rev 14236)
@@ -148,7 +148,7 @@
// Add the root node of the tree to the stack.
stack.push(&tree);
// Set the top level whitelist.
- tree.Stat().whiteList.resize(centroids.n_cols, true);
+ tree.Stat().Whitelist().resize(centroids.n_cols, true);
// Traverse the tree.
while (!stack.empty())
@@ -169,7 +169,7 @@
// the centroids to every point the node contains.
if (node->IsLeaf())
{
- for (size_t i = mrkd.begin; i < mrkd.count + mrkd.begin; ++i)
+ for (size_t i = mrkd.Begin(); i < mrkd.Count() + mrkd.Begin(); ++i)
{
// Initialize minDistance to be nonzero.
double minDistance = metric::SquaredEuclideanDistance::Evaluate(
@@ -179,7 +179,7 @@
for (size_t j = 1; j < centroids.n_cols; ++j)
{
// If this centroid is not in the whitelist, skip it.
- if (!mrkd.whiteList[j])
+ if (!mrkd.Whitelist()[j])
{
++skip;
continue;
@@ -222,7 +222,7 @@
bool noDomination = false;
// Calculate the center of mass of this hyperrectangle.
- arma::vec center = mrkd.centerOfMass / mrkd.count;
+ arma::vec center = mrkd.CenterOfMass() / mrkd.Count();
// Set the minDistance to the maximum value of a double so any value
// must be smaller than this.
@@ -239,7 +239,7 @@
for (size_t i = 0; i < centroids.n_cols; ++i)
{
// If this centroid is not in the whitelist, skip it.
- if (!mrkd.whiteList[i])
+ if (!mrkd.Whitelist()[i])
{
++skip;
continue;
@@ -349,7 +349,7 @@
continue;
// If this centroid is blacklisted for this hyperrectangle, then
// we skip it.
- if (!mrkd.whiteList[i])
+ if (!mrkd.Whitelist()[i])
{
++skip;
continue;
@@ -382,8 +382,8 @@
double distanceMin = 0.0;
for (size_t k = 0; k < dimensionality; ++k)
{
- double ci = centroids(k,i);
- double cm = centroids(k,minIndex);
+ double ci = centroids(k, i);
+ double cm = centroids(k, minIndex);
if (ci > cm)
{
double hi = bound[k].Hi();
@@ -412,14 +412,14 @@
}
}
- if(distanceMin >= distancei)
+ if (distanceMin >= distancei)
{
noDomination = true;
break;
}
else
{
- mrkd.whiteList[i] = false;
+ mrkd.Whitelist()[i] = false;
}
}
}
@@ -430,10 +430,10 @@
{
// Adjust the new centroid sum for the min distance point to this
// hyperrectangle by the center of mass of this hyperrectangle.
- newCentroids.col(minIndex) += mrkd.centerOfMass;
+ newCentroids.col(minIndex) += mrkd.CenterOfMass();
// Increment the counts for this centroid.
- counts(minIndex) += mrkd.count;
+ counts(minIndex) += mrkd.Count();
// Update all assignments for this node.
const size_t begin = node->Begin();
@@ -448,7 +448,7 @@
assignments(j) = minIndex;
}
}
- mrkd.dominatingCentroid = minIndex;
+ mrkd.DominatingCentroid() = minIndex;
// Keep track of the number of times we found a dominating centroid.
++dominations;
@@ -463,8 +463,8 @@
stack.push(node->Right());
// (Re)Initialize the whiteList for the children.
- node->Left()->Stat().whiteList = mrkd.whiteList;
- node->Right()->Stat().whiteList = mrkd.whiteList;
+ node->Left()->Stat().Whitelist() = mrkd.Whitelist();
+ node->Right()->Stat().Whitelist() = mrkd.Whitelist();
}
}
Modified: mlpack/branches/mlpack-1.x/src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp
===================================================================
--- mlpack/branches/mlpack-1.x/src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp 2013-02-08 20:27:12 UTC (rev 14235)
+++ mlpack/branches/mlpack-1.x/src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp 2013-02-08 20:27:34 UTC (rev 14236)
@@ -33,7 +33,7 @@
for (size_t i = 0; i < data.n_cols; i++)
{
variances[assignments[i]] += arma::as_scalar(
- var(data.col(i) - centroids.col(assignments[i])));
+ arma::var(data.col(i) - centroids.col(assignments[i])));
}
// Now find the cluster with maximum variance.
@@ -48,7 +48,7 @@
if (assignments[i] == maxVarCluster)
{
double distance = arma::as_scalar(
- var(data.col(i) - centroids.col(maxVarCluster)));
+ arma::var(data.col(i) - centroids.col(maxVarCluster)));
if (distance > maxDistance)
{
More information about the mlpack-svn
mailing list