[mlpack-svn] r14956 - mlpack/trunk/src/mlpack/methods/kmeans

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Apr 25 00:16:55 EDT 2013


Author: rcurtin
Date: 2013-04-25 00:16:55 -0400 (Thu, 25 Apr 2013)
New Revision: 14956

Modified:
   mlpack/trunk/src/mlpack/methods/kmeans/kmeans.hpp
   mlpack/trunk/src/mlpack/methods/kmeans/kmeans_impl.hpp
Log:
Change DistanceMetric to MetricType to be more in line with the rest of the
mlpack codebase.


Modified: mlpack/trunk/src/mlpack/methods/kmeans/kmeans.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/kmeans/kmeans.hpp	2013-04-24 21:59:05 UTC (rev 14955)
+++ mlpack/trunk/src/mlpack/methods/kmeans/kmeans.hpp	2013-04-25 04:16:55 UTC (rev 14956)
@@ -43,7 +43,7 @@
  * k.Cluster(data, 6, assignments); // 6 clusters.
  * @endcode
  *
- * @tparam DistanceMetric The distance metric to use for this KMeans; see
+ * @tparam MetricType The distance metric to use for this KMeans; see
  *     metric::LMetric for an example.
  * @tparam InitialPartitionPolicy Initial partitioning policy; must implement a
  *     default constructor and 'void Cluster(const arma::mat&, const size_t,
@@ -54,7 +54,7 @@
  *
  * @see RandomPartition, RefinedStart, AllowEmptyClusters, MaxVarianceNewCluster
  */
-template<typename DistanceMetric = metric::SquaredEuclideanDistance,
+template<typename MetricType = metric::SquaredEuclideanDistance,
          typename InitialPartitionPolicy = RandomPartition,
          typename EmptyClusterPolicy = MaxVarianceNewCluster>
 class KMeans
@@ -75,7 +75,7 @@
    *     (0 is valid, but the algorithm may never terminate).
    * @param overclusteringFactor Factor controlling how many extra clusters are
    *     found and then merged to get the desired number of clusters.
-   * @param metric Optional DistanceMetric object; for when the metric has state
+   * @param metric Optional MetricType object; for when the metric has state
    *     it needs to store.
    * @param partitioner Optional InitialPartitionPolicy object; for when a
    *     specially initialized partitioning policy is required.
@@ -84,7 +84,7 @@
    */
   KMeans(const size_t maxIterations = 1000,
          const double overclusteringFactor = 1.0,
-         const DistanceMetric metric = DistanceMetric(),
+         const MetricType metric = MetricType(),
          const InitialPartitionPolicy partitioner = InitialPartitionPolicy(),
          const EmptyClusterPolicy emptyClusterAction = EmptyClusterPolicy());
 
@@ -158,9 +158,9 @@
   size_t& MaxIterations() { return maxIterations; }
 
   //! Get the distance metric.
-  const DistanceMetric& Metric() const { return metric; }
+  const MetricType& Metric() const { return metric; }
   //! Modify the distance metric.
-  DistanceMetric& Metric() { return metric; }
+  MetricType& Metric() { return metric; }
 
   //! Get the initial partitioning policy.
   const InitialPartitionPolicy& Partitioner() const { return partitioner; }
@@ -179,7 +179,7 @@
   //! Maximum number of iterations before giving up.
   size_t maxIterations;
   //! Instantiated distance metric.
-  DistanceMetric metric;
+  MetricType metric;
   //! Instantiated initial partitioning policy.
   InitialPartitionPolicy partitioner;
   //! Instantiated empty cluster policy.

Modified: mlpack/trunk/src/mlpack/methods/kmeans/kmeans_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/kmeans/kmeans_impl.hpp	2013-04-24 21:59:05 UTC (rev 14955)
+++ mlpack/trunk/src/mlpack/methods/kmeans/kmeans_impl.hpp	2013-04-25 04:16:55 UTC (rev 14956)
@@ -19,16 +19,16 @@
 /**
  * Construct the K-Means object.
  */
-template<typename DistanceMetric,
+template<typename MetricType,
          typename InitialPartitionPolicy,
          typename EmptyClusterPolicy>
 KMeans<
-    DistanceMetric,
+    MetricType,
     InitialPartitionPolicy,
     EmptyClusterPolicy>::
 KMeans(const size_t maxIterations,
        const double overclusteringFactor,
-       const DistanceMetric metric,
+       const MetricType metric,
        const InitialPartitionPolicy partitioner,
        const EmptyClusterPolicy emptyClusterAction) :
     maxIterations(maxIterations),
@@ -49,12 +49,12 @@
   }
 }
 
-template<typename DistanceMetric,
+template<typename MetricType,
          typename InitialPartitionPolicy,
          typename EmptyClusterPolicy>
 template<typename MatType>
 void KMeans<
-    DistanceMetric,
+    MetricType,
     InitialPartitionPolicy,
     EmptyClusterPolicy>::
 FastCluster(MatType& data,
@@ -488,12 +488,12 @@
  * centroids too.  If this is properly inlined, there shouldn't be any
  * performance penalty whatsoever.
  */
-template<typename DistanceMetric,
+template<typename MetricType,
          typename InitialPartitionPolicy,
          typename EmptyClusterPolicy>
 template<typename MatType>
 inline void KMeans<
-    DistanceMetric,
+    MetricType,
     InitialPartitionPolicy,
     EmptyClusterPolicy>::
 Cluster(const MatType& data,
@@ -509,12 +509,12 @@
  * Perform k-means clustering on the data, returning a list of cluster
  * assignments and the centroids of each cluster.
  */
-template<typename DistanceMetric,
+template<typename MetricType,
          typename InitialPartitionPolicy,
          typename EmptyClusterPolicy>
 template<typename MatType>
 void KMeans<
-    DistanceMetric,
+    MetricType,
     InitialPartitionPolicy,
     EmptyClusterPolicy>::
 Cluster(const MatType& data,




More information about the mlpack-svn mailing list