[mlpack-svn] r13885 - mlpack/trunk/src/mlpack/bindings/matlab/kmeans
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Nov 16 14:04:48 EST 2012
Author: rcurtin
Date: 2012-11-16 14:04:48 -0500 (Fri, 16 Nov 2012)
New Revision: 13885
Removed:
mlpack/trunk/src/mlpack/bindings/matlab/kmeans/Makefile
mlpack/trunk/src/mlpack/bindings/matlab/kmeans/test.m
Modified:
mlpack/trunk/src/mlpack/bindings/matlab/kmeans/kmeans.cpp
Log:
Remove unnecessary Makefile; add header comment, remove unnecessary headers, and
change tabs to spaces.
Deleted: mlpack/trunk/src/mlpack/bindings/matlab/kmeans/Makefile
===================================================================
--- mlpack/trunk/src/mlpack/bindings/matlab/kmeans/Makefile 2012-11-16 19:00:06 UTC (rev 13884)
+++ mlpack/trunk/src/mlpack/bindings/matlab/kmeans/Makefile 2012-11-16 19:04:48 UTC (rev 13885)
@@ -1,19 +0,0 @@
-kmeans: kmeans.o
- g++ -O -pthread -shared \
--Wl,--version-script,/opt/matlab/2010b/extern/lib/glnxa64/mexFunction.map \
--Wl,--no-undefined -o 'mex_kmeans.mexa64' kmeans.o \
--L../../build/lib -lmlpack \
--Wl,-rpath-link,/opt/matlab/2010b/bin/glnxa64 \
--L/opt/matlab/2010b/bin/glnxa64 -lmx -lmex -lmat -lm \
--Wl,-rpath=/net/hu19/pmason8/mlpack/trunk/build/lib \
--L/usr/lib64 -larmadillo \
-
-kmeans.o:
- g++ -c \
--I../../build/include \
--I../../build/include/mlpack/methods/kmeans \
--I/usr/include/libxml2 \
--I/opt/matlab/2010b/extern/include \
--DMATLAB_MEX_FILE \
--ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread \
--DMX_COMPAT_32 -O -DNDEBUG 'kmeans.cpp'
Modified: mlpack/trunk/src/mlpack/bindings/matlab/kmeans/kmeans.cpp
===================================================================
--- mlpack/trunk/src/mlpack/bindings/matlab/kmeans/kmeans.cpp 2012-11-16 19:00:06 UTC (rev 13884)
+++ mlpack/trunk/src/mlpack/bindings/matlab/kmeans/kmeans.cpp 2012-11-16 19:04:48 UTC (rev 13885)
@@ -1,52 +1,29 @@
+/**
+ * @file kmeans.cpp
+ * @author Patrick Mason
+ *
+ * MEX function for MATLAB k-means binding.
+ */
#include "mex.h"
#include <mlpack/core.hpp>
+#include <mlpack/methods/kmeans/kmeans.hpp>
+#include <mlpack/methods/kmeans/allow_empty_clusters.hpp>
-#include "kmeans.hpp"
-#include "allow_empty_clusters.hpp"
-
using namespace mlpack;
using namespace mlpack::kmeans;
using namespace std;
-/*
-// Define parameters for the executable.
-PROGRAM_INFO("K-Means Clustering", "This program performs K-Means clustering "
- "on the given dataset, storing the learned cluster assignments either as "
- "a column of labels in the file containing the input dataset or in a "
- "separate file. Empty clusters are not allowed by default; when a cluster "
- "becomes empty, the point furthest from the centroid of the cluster with "
- "maximum variance is taken to fill that cluster.");
-
-PARAM_STRING_REQ("inputFile", "Input dataset to perform clustering on.", "i");
-PARAM_INT_REQ("clusters", "Number of clusters to find.", "c");
-
-PARAM_FLAG("in_place", "If specified, a column of the learned cluster "
- "assignments will be added to the input dataset file. In this case, "
- "--outputFile is not necessary.", "p");
-PARAM_STRING("outputFile", "File to write output labels or labeled data to.",
- "o", "output.csv");
-PARAM_FLAG("allow_empty_clusters", "Allow empty clusters to be created.", "e");
-PARAM_FLAG("labels_only", "Only output labels into output file.", "l");
-PARAM_DOUBLE("overclustering", "Finds (overclustering * clusters) clusters, "
- "then merges them together until only the desired number of clusters are "
- "left.", "O", 1.0);
-PARAM_INT("max_iterations", "Maximum number of iterations before K-Means "
- "terminates.", "m", 1000);
-PARAM_INT("seed", "Random seed. If 0, 'std::time(NULL)' is used.", "s", 0);
-PARAM_FLAG("fast_kmeans", "Use the experimental fast k-means algorithm by Pelleg and Moore", "f")
-*/
-
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
// argument checks
- if (nrhs != 7)
+ if (nrhs != 7)
{
mexErrMsgTxt("Expecting seven arguments.");
}
- if (nlhs != 1)
+ if (nlhs != 1)
{
mexErrMsgTxt("Output required.");
}
@@ -109,10 +86,10 @@
const size_t numPoints = mxGetN(prhs[0]);
const size_t numDimensions = mxGetM(prhs[0]);
arma::mat dataset(numDimensions, numPoints);
-
- // setting the values.
+
+ // setting the values.
double * mexDataPoints = mxGetPr(prhs[0]);
- for (int i = 0, n = numPoints * numDimensions; i < n; ++i)
+ for (int i = 0, n = numPoints * numDimensions; i < n; ++i)
{
dataset(i) = mexDataPoints[i];
}
@@ -189,7 +166,7 @@
// setting the values
double * out = mxGetPr(plhs[0]);
- for (int i = 0, n = assignments.n_elem; i < n; ++i)
+ for (int i = 0, n = assignments.n_elem; i < n; ++i)
{
out[i] = assignments(i);
}
Deleted: mlpack/trunk/src/mlpack/bindings/matlab/kmeans/test.m
===================================================================
--- mlpack/trunk/src/mlpack/bindings/matlab/kmeans/test.m 2012-11-16 19:00:06 UTC (rev 13884)
+++ mlpack/trunk/src/mlpack/bindings/matlab/kmeans/test.m 2012-11-16 19:04:48 UTC (rev 13885)
@@ -1,6 +0,0 @@
-dataPoints = [0, 0; 1, 1; 3, 3; 0.5, 0; 1000, 0; 1001, 0];
-
-% running the emst computation with mlpack
-result = kmeans(dataPoints, 2)
-
-
More information about the mlpack-svn
mailing list