[mlpack-svn] r14925 - mlpack/trunk/src/mlpack/methods/kmeans
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Apr 18 20:54:20 EDT 2013
Author: rcurtin
Date: 2013-04-18 20:54:20 -0400 (Thu, 18 Apr 2013)
New Revision: 14925
Modified:
mlpack/trunk/src/mlpack/methods/kmeans/kmeans_main.cpp
Log:
Oh yeah -- actually allow the user-specified parameters to *do* something...
Modified: mlpack/trunk/src/mlpack/methods/kmeans/kmeans_main.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/kmeans/kmeans_main.cpp 2013-04-19 00:05:11 UTC (rev 14924)
+++ mlpack/trunk/src/mlpack/methods/kmeans/kmeans_main.cpp 2013-04-19 00:54:20 UTC (rev 14925)
@@ -124,8 +124,19 @@
{
if (CLI::HasParam("refined_start"))
{
+ const int samplings = CLI::GetParam<int>("samplings");
+ const double percentage = CLI::GetParam<int>("percentage");
+
+ if (samplings < 0)
+ Log::Fatal << "Number of samplings (" << samplings << ") must be "
+ << "greater than 0!" << std::endl;
+ if (percentage <= 0.0 || percentage > 1.0)
+ Log::Fatal << "Percentage for sampling (" << percentage << ") must be "
+ << "greater than 0.0 and less than or equal to 1.0!" << std::endl;
+
KMeans<metric::SquaredEuclideanDistance, RefinedStart, AllowEmptyClusters>
- k(maxIterations, overclustering);
+ k(maxIterations, overclustering, metric::SquaredEuclideanDistance(),
+ RefinedStart(samplings, percentage));
Timer::Start("clustering");
if (CLI::HasParam("fast_kmeans"))
@@ -151,9 +162,20 @@
{
if (CLI::HasParam("refined_start"))
{
- KMeans<metric::SquaredEuclideanDistance, RefinedStart> k(maxIterations,
- overclustering);
+ const int samplings = CLI::GetParam<int>("samplings");
+ const double percentage = CLI::GetParam<int>("percentage");
+ if (samplings < 0)
+ Log::Fatal << "Number of samplings (" << samplings << ") must be "
+ << "greater than 0!" << std::endl;
+ if (percentage <= 0.0 || percentage > 1.0)
+ Log::Fatal << "Percentage for sampling (" << percentage << ") must be "
+ << "greater than 0.0 and less than or equal to 1.0!" << std::endl;
+
+ KMeans<metric::SquaredEuclideanDistance, RefinedStart, AllowEmptyClusters>
+ k(maxIterations, overclustering, metric::SquaredEuclideanDistance(),
+ RefinedStart(samplings, percentage));
+
Timer::Start("clustering");
if (CLI::HasParam("fast_kmeans"))
k.FastCluster(dataset, clusters, assignments);
More information about the mlpack-svn
mailing list