[mlpack-svn] r10353 - in mlpack/trunk/src/mlpack/methods: emst gmm hmm nca neighbor_search neighbor_search/sort_policies
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Nov 23 01:57:00 EST 2011
Author: rcurtin
Date: 2011-11-23 01:56:59 -0500 (Wed, 23 Nov 2011)
New Revision: 10353
Modified:
mlpack/trunk/src/mlpack/methods/emst/dtb.hpp
mlpack/trunk/src/mlpack/methods/gmm/kmeans.cpp
mlpack/trunk/src/mlpack/methods/hmm/support.cpp
mlpack/trunk/src/mlpack/methods/nca/nca.h
mlpack/trunk/src/mlpack/methods/nca/nca_main.cc
mlpack/trunk/src/mlpack/methods/neighbor_search/neighbor_search.h
mlpack/trunk/src/mlpack/methods/neighbor_search/sort_policies/furthest_neighbor_sort_impl.hpp
mlpack/trunk/src/mlpack/methods/neighbor_search/sort_policies/nearest_neighbor_sort_impl.hpp
mlpack/trunk/src/mlpack/methods/neighbor_search/typedef.h
Log:
Update kernels to metrics (where applicable).
Modified: mlpack/trunk/src/mlpack/methods/emst/dtb.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/emst/dtb.hpp 2011-11-23 06:56:20 UTC (rev 10352)
+++ mlpack/trunk/src/mlpack/methods/emst/dtb.hpp 2011-11-23 06:56:59 UTC (rev 10353)
@@ -1,13 +1,13 @@
/**
-* @file dtb.h
+ * @file dtb.hpp
*
* @author Bill March (march at gatech.edu)
*
* Contains an implementation of the DualTreeBoruvka algorithm for finding a
* Euclidean Minimum Spanning Tree using the kd-tree data structure.
*
- * Citation: March, W. B.; Ram, P.; and Gray, A. G. Fast Euclidean Minimum Spanning
- * Tree: Algorithm, Analysis, Applications. In KDD, 2010.
+ * Citation: March, W. B.; Ram, P.; and Gray, A. G. Fast Euclidean Minimum
+ * Spanning Tree: Algorithm, Analysis, Applications. In KDD, 2010.
*
*/
@@ -19,7 +19,7 @@
#include <mlpack/core.h>
#include <mlpack/core/tree/bounds.hpp>
#include <mlpack/core/tree/binary_space_tree.hpp>
-#include <mlpack/core/kernels/lmetric.hpp>
+#include <mlpack/core/metrics/lmetric.hpp>
namespace mlpack {
namespace emst {
@@ -35,7 +35,7 @@
* points in this node. If points in this node are in different components,
* this value will be negative.
*/
-
+
class DTBStat {
private:
double max_neighbor_distance_;
@@ -229,7 +229,7 @@
arma::vec reference_point = data_points_.col(reference_index);
- double distance = mlpack::kernel::LMetric<2>::Evaluate(query_point,
+ double distance = mlpack::metric::LMetric<2>::Evaluate(query_point,
reference_point);
if (distance < neighbors_distances_[query_component_index]) {
@@ -277,7 +277,7 @@
//pruned by component membership
mlpack::Log::Assert(reference_node->stat().component_membership() >= 0);
-
+
mlpack::Log::Info << query_node->stat().component_membership() << "q mem\n";
mlpack::Log::Info << reference_node->stat().component_membership() << "r mem\n";
@@ -432,12 +432,12 @@
if (!do_naive_) {
for (size_t i = 0; i < (number_of_points_ - 1); i++) {
- // Make sure the edge list stores the smaller index first to
+ // Make sure the edge list stores the smaller index first to
// make checking correctness easier
size_t ind1, ind2;
ind1 = old_from_new_permutation_[edges_[i].lesser_index()];
ind2 = old_from_new_permutation_[edges_[i].greater_index()];
-
+
edges_[i].set_lesser_index(std::min(ind1, ind2));
edges_[i].set_greater_index(std::max(ind1, ind2));
@@ -542,9 +542,9 @@
mlpack::Log::Info << "number_r_recursions" << std::endl;
mlpack::Log::Info << "number_both_recursions" << std::endl;
*/
-
+
mlpack::CLI::GetParam<double>("dtb/total_squared_length") = total_dist_;
-
+
} // OutputResults_
/////////// Public Functions ///////////////////
@@ -580,13 +580,13 @@
tree_ = new DTBTree(data_points_, old_from_new_permutation_);
Timers::StopTimer("emst/tree_building");
-
+
}
else {
-
+
tree_ = NULL;
old_from_new_permutation_.resize(0);
-
+
}
number_of_points_ = data_points_.n_cols;
@@ -618,14 +618,14 @@
Timers::StartTimer("emst/MST_computation");
while (number_of_edges_ < (number_of_points_ - 1)) {
-
+
ComputeNeighbors_();
AddAllEdges_();
Cleanup_();
-
+
Log::Info << "Finished loop number: " << number_of_loops_ << std::endl;
Log::Info << number_of_edges_ << " edges found so far.\n\n";
/*
@@ -636,7 +636,7 @@
Log::Info << number_q_recursions_ << " query recursions.\n";
Log::Info << number_both_recursions_ << " dual recursions.\n\n";
*/
-
+
}
Timers::StopTimer("emst/MST_computation");
Modified: mlpack/trunk/src/mlpack/methods/gmm/kmeans.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/gmm/kmeans.cpp 2011-11-23 06:56:20 UTC (rev 10352)
+++ mlpack/trunk/src/mlpack/methods/gmm/kmeans.cpp 2011-11-23 06:56:59 UTC (rev 10353)
@@ -7,7 +7,7 @@
*/
#include "kmeans.hpp"
-#include <mlpack/core/kernels/lmetric.hpp>
+#include <mlpack/core/metrics/lmetric.hpp>
namespace mlpack {
namespace gmm {
@@ -62,7 +62,7 @@
for (size_t j = 0; j < value_of_k; j++)
{
- double distance = kernel::SquaredEuclideanDistance::Evaluate(
+ double distance = metric::SquaredEuclideanDistance::Evaluate(
data.unsafe_col(i), centroids.unsafe_col(j));
if (distance < min_distance)
@@ -115,7 +115,7 @@
{
if (assignments[j] == cluster)
{
- double d = kernel::SquaredEuclideanDistance::Evaluate(
+ double d = metric::SquaredEuclideanDistance::Evaluate(
data.unsafe_col(j), centroids.unsafe_col(cluster));
if (d >= distance)
Modified: mlpack/trunk/src/mlpack/methods/hmm/support.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/hmm/support.cpp 2011-11-23 06:56:20 UTC (rev 10352)
+++ mlpack/trunk/src/mlpack/methods/hmm/support.cpp 2011-11-23 06:56:59 UTC (rev 10353)
@@ -1,5 +1,5 @@
#include <mlpack/core.h>
-#include <mlpack/core/kernels/lmetric.hpp>
+#include <mlpack/core/metrics/lmetric.hpp>
#include "support.hpp"
@@ -138,7 +138,8 @@
for (j = 0; j < num_clusters; j++) {
double distance =
- mlpack::kernel::LMetric<2>::Evaluate(data_i_Vec, centroids_[j]);
+ mlpack::metric::LMetric<2>::Evaluate(data_i_Vec,
+ centroids_[j]);
if (distance < min_distance) {
labels_[i] = j;
@@ -212,7 +213,7 @@
for (j = 0; j < num_clusters; j++) {
double distance =
- mlpack::kernel::LMetric<2>::Evaluate(data_i_Vec, centroids_[j]);
+ mlpack::metric::LMetric<2>::Evaluate(data_i_Vec, centroids_[j]);
if (distance < min_distance) {
labels_[i] = j;
min_distance = distance;
Modified: mlpack/trunk/src/mlpack/methods/nca/nca.h
===================================================================
--- mlpack/trunk/src/mlpack/methods/nca/nca.h 2011-11-23 06:56:20 UTC (rev 10352)
+++ mlpack/trunk/src/mlpack/methods/nca/nca.h 2011-11-23 06:56:59 UTC (rev 10353)
@@ -8,7 +8,7 @@
#define __MLPACK_METHODS_NCA_NCA_H
#include <mlpack/core.h>
-#include <mlpack/core/kernels/lmetric.hpp>
+#include <mlpack/core/metrics/lmetric.hpp>
namespace mlpack {
namespace nca {
Modified: mlpack/trunk/src/mlpack/methods/nca/nca_main.cc
===================================================================
--- mlpack/trunk/src/mlpack/methods/nca/nca_main.cc 2011-11-23 06:56:20 UTC (rev 10352)
+++ mlpack/trunk/src/mlpack/methods/nca/nca_main.cc 2011-11-23 06:56:59 UTC (rev 10353)
@@ -5,7 +5,7 @@
* Executable for Neighborhood Components Analysis.
*/
#include <mlpack/core.h>
-#include <mlpack/core/kernels/lmetric.hpp>
+#include <mlpack/core/metrics/lmetric.hpp>
#include "nca.h"
@@ -18,7 +18,7 @@
using namespace mlpack;
using namespace mlpack::nca;
-using namespace mlpack::kernel;
+using namespace mlpack::metric;
using namespace std;
int main(int argc, char* argv[]) {
Modified: mlpack/trunk/src/mlpack/methods/neighbor_search/neighbor_search.h
===================================================================
--- mlpack/trunk/src/mlpack/methods/neighbor_search/neighbor_search.h 2011-11-23 06:56:20 UTC (rev 10352)
+++ mlpack/trunk/src/mlpack/methods/neighbor_search/neighbor_search.h 2011-11-23 06:56:59 UTC (rev 10353)
@@ -13,7 +13,7 @@
#include <vector>
#include <string>
-#include <mlpack/core/kernels/lmetric.hpp>
+#include <mlpack/core/metrics/lmetric.hpp>
#include "sort_policies/nearest_neighbor_sort.hpp"
namespace mlpack {
@@ -54,7 +54,7 @@
* @tparam Kernel The kernel function; see kernel::ExampleKernel.
* @tparam SortPolicy The sort policy for distances; see NearestNeighborSort.
*/
-template<typename Kernel = mlpack::kernel::SquaredEuclideanDistance,
+template<typename Kernel = mlpack::metric::SquaredEuclideanDistance,
typename SortPolicy = NearestNeighborSort>
class NeighborSearch {
Modified: mlpack/trunk/src/mlpack/methods/neighbor_search/sort_policies/furthest_neighbor_sort_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/neighbor_search/sort_policies/furthest_neighbor_sort_impl.hpp 2011-11-23 06:56:20 UTC (rev 10352)
+++ mlpack/trunk/src/mlpack/methods/neighbor_search/sort_policies/furthest_neighbor_sort_impl.hpp 2011-11-23 06:56:59 UTC (rev 10353)
@@ -8,8 +8,6 @@
#ifndef __MLPACK_NEIGHBOR_FURTHEST_NEIGHBOR_SORT_IMPL_HPP
#define __MLPACK_NEIGHBOR_FURTHEST_NEIGHBOR_SORT_IMPL_HPP
-#include <mlpack/core/kernels/lmetric.hpp>
-
namespace mlpack {
namespace neighbor {
Modified: mlpack/trunk/src/mlpack/methods/neighbor_search/sort_policies/nearest_neighbor_sort_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/neighbor_search/sort_policies/nearest_neighbor_sort_impl.hpp 2011-11-23 06:56:20 UTC (rev 10352)
+++ mlpack/trunk/src/mlpack/methods/neighbor_search/sort_policies/nearest_neighbor_sort_impl.hpp 2011-11-23 06:56:59 UTC (rev 10353)
@@ -8,8 +8,6 @@
#ifndef __MLPACK_NEIGHBOR_NEAREST_NEIGHBOR_SORT_IMPL_HPP
#define __MLPACK_NEIGHBOR_NEAREST_NEIGHBOR_SORT_IMPL_HPP
-#include <mlpack/core/kernels/lmetric.hpp>
-
namespace mlpack {
namespace neighbor {
Modified: mlpack/trunk/src/mlpack/methods/neighbor_search/typedef.h
===================================================================
--- mlpack/trunk/src/mlpack/methods/neighbor_search/typedef.h 2011-11-23 06:56:20 UTC (rev 10352)
+++ mlpack/trunk/src/mlpack/methods/neighbor_search/typedef.h 2011-11-23 06:56:59 UTC (rev 10353)
@@ -12,7 +12,7 @@
// In case someone included this directly.
#include "neighbor_search.h"
-#include <mlpack/core/kernels/lmetric.hpp>
+#include <mlpack/core/metrics/lmetric.hpp>
#include "sort_policies/nearest_neighbor_sort.hpp"
#include "sort_policies/furthest_neighbor_sort.hpp"
@@ -26,7 +26,7 @@
* neighbors. Squared distances are used because they are slightly faster than
* non-squared distances (they have one fewer call to sqrt()).
*/
-typedef NeighborSearch<kernel::SquaredEuclideanDistance, NearestNeighborSort>
+typedef NeighborSearch<metric::SquaredEuclideanDistance, NearestNeighborSort>
AllkNN;
/**
@@ -35,7 +35,7 @@
* neighbors. Squared distances are used because they are slightly faster than
* non-squared distances (they have one fewer call to sqrt()).
*/
-typedef NeighborSearch<kernel::SquaredEuclideanDistance, FurthestNeighborSort>
+typedef NeighborSearch<metric::SquaredEuclideanDistance, FurthestNeighborSort>
AllkFN;
}; // namespace neighbor
More information about the mlpack-svn
mailing list