[mlpack-svn] r15519 - mlpack/conf/jenkins-conf/benchmark/methods/matlab
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Mon Jul 22 06:39:08 EDT 2013
Author: marcus
Date: Mon Jul 22 06:39:06 2013
New Revision: 15519
Log:
Clean up matlab scripts.
Modified:
mlpack/conf/jenkins-conf/benchmark/methods/matlab/ALLKNN.m
mlpack/conf/jenkins-conf/benchmark/methods/matlab/KMEANS.m
mlpack/conf/jenkins-conf/benchmark/methods/matlab/LINEAR_REGRESSION.m
mlpack/conf/jenkins-conf/benchmark/methods/matlab/NBC.m
mlpack/conf/jenkins-conf/benchmark/methods/matlab/NMF.m
mlpack/conf/jenkins-conf/benchmark/methods/matlab/PCA.m
mlpack/conf/jenkins-conf/benchmark/methods/matlab/allknn.py
mlpack/conf/jenkins-conf/benchmark/methods/matlab/hmm_generate.py
mlpack/conf/jenkins-conf/benchmark/methods/matlab/hmm_viterbi.py
mlpack/conf/jenkins-conf/benchmark/methods/matlab/kmeans.py
mlpack/conf/jenkins-conf/benchmark/methods/matlab/linear_regression.py
mlpack/conf/jenkins-conf/benchmark/methods/matlab/nbc.py
mlpack/conf/jenkins-conf/benchmark/methods/matlab/nmf.py
mlpack/conf/jenkins-conf/benchmark/methods/matlab/pca.py
mlpack/conf/jenkins-conf/benchmark/methods/matlab/range_search.py
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/ALLKNN.m
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/ALLKNN.m (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/ALLKNN.m Mon Jul 22 06:39:06 2013
@@ -10,8 +10,8 @@
% reference and query set.
%
% Required options:
-% (-k) [int] Number of furthest neighbors to find.
-% (-t) [string] A file containing the training set.
+% (-k) [int] Number of nearest neighbors to find.
+% (-r) [string] File containing the reference dataset.
%
% Options:
% (-l) [int] Leaf size for tree building. Default value 20.
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/KMEANS.m
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/KMEANS.m (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/KMEANS.m Mon Jul 22 06:39:06 2013
@@ -4,15 +4,17 @@
% K-Means Clustering with matlab.
function KMEANS(cmd)
-% This program performs K-Means clustering on the given dataset
+% This program performs K-Means clustering on the given dataset.
%
% Required options:
% (-i) [string] Input dataset to perform clustering on.
+% (-I) [string] Start with the specified initial centroids.
+% Default value ''.
% Options:
-% (-c) [int] Number of clusters to find.
-% (-m) [int] Maximum number of iterations before K-Means
-% terminates. Default value 1000.
-% (-s) [int] Random seed. If 0, 'std::time(NULL)' is used.
+% (-c) [int] Number of clusters to find.
+% (-m) [int] Maximum number of iterations before K-Means terminates.
+% Default value 1000.
+% (-s) [int] Random seed.
% Load input dataset.
@@ -43,7 +45,7 @@
end
if ~isempty(seed)
- s = RandStream('mt19937ar','Seed', seed);
+ s = RandStream('mt19937ar', 'Seed', seed);
RandStream.setGlobalStream(s);
end
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/LINEAR_REGRESSION.m
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/LINEAR_REGRESSION.m (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/LINEAR_REGRESSION.m Mon Jul 22 06:39:06 2013
@@ -4,7 +4,7 @@
% Linear Regression with matlab.
function linear_regression(cmd)
-% Simple Linear Regression Prediction
+% Simple Linear Regression Prediction.
%
% Required options:
% (-i) [string] File containing X (regressors).
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/NBC.m
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/NBC.m (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/NBC.m Mon Jul 22 06:39:06 2013
@@ -4,7 +4,7 @@
% Naive Bayes Classifier with matlab.
function nbc(cmd)
-%This program trains the Naive Bayes classifier on the given labeled
+% This program trains the Naive Bayes classifier on the given labeled
% training set and then uses the trained classifier to classify the points
% in the given test set. Labels are expected to be the last row of the
% training set.
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/NMF.m
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/NMF.m (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/NMF.m Mon Jul 22 06:39:06 2013
@@ -5,8 +5,7 @@
function nmf(cmd)
% This program performs non-negative matrix factorization on the given
-% dataset, storing the resulting decomposed matrices in the specified
-% files. For an input dataset V, NMF decomposes V into two matrices W and H
+% dataset. For an input dataset V, NMF decomposes V into two matrices W and H
% such that
%
% V = W * H
@@ -17,13 +16,13 @@
% (-i) [string] Input dataset to perform NMF on.
% (-r) [int] Rank of the factorization.
% Options:
-% (-m) [int] Number of iterations before NMF terminates (0) runs
+% (-m) [int] Number of iterations before NMF terminates (0) runs
% until convergence. Default value 10000.
-% (-e) [double] The minimum root mean square residue allowed for
+% (-e) [double] The minimum root mean square residue allowed for
% each iteration, below which the program terminates.
% Default value 1e-05.
-% (-s) [int] Random seed.
-% (-u) [string] Update rules for each iteration; ( multdist | als ).
+% (-s) [int] Random seed.
+% (-u) [string] Update rules for each iteration; ( multdist | als ).
% Default value 'multdist'.
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/PCA.m
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/PCA.m (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/PCA.m Mon Jul 22 06:39:06 2013
@@ -1,3 +1,8 @@
+% @file PCA.m
+% @author Marcus Edel
+%
+% Principal Components Analysis with matlab.
+
function pca(cmd)
% This program performs principal components analysis on the given dataset.
% It will transform the data onto its principal components, optionally
@@ -7,20 +12,17 @@
% Required options:
% (-i) [string] Input dataset to perform PCA on.
% Options:
-% (-d) [int] Desired dimensionality of output dataset. If this
+% (-d) [int] Desired dimensionality of output dataset. If this
% option not set no dimensionality reduction is
% performed. Default value 0.
-% (-s) If set, the data will be scaled before running PCA,
+% (-s) If set, the data will be scaled before running PCA,
% such that the variance of each feature is 1.
inputFile = regexp(cmd, '.*?-i ([^\s]+)', 'tokens', 'once');
% Load input dataset.
-loading_data = tic;
-total_time = tic;
X = csvread(inputFile{:});
-disp(sprintf('[INFO ] loading_data: %fs', toc(loading_data)))
% Find out what dimension we want.
k = str2double(regexp(cmd,'.* -d.* (\d+)','tokens','once'));
@@ -36,6 +38,7 @@
end
end
+total_time = tic;
% Retrieve the dimensions of X.
[m, n] = size(X);
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/allknn.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/allknn.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/allknn.py Mon Jul 22 06:39:06 2013
@@ -33,19 +33,13 @@
Create the All K-Nearest-Neighbors benchmark instance.
@param dataset - Input dataset to perform ALLKNN on.
- @param path - Path to the mlpack executable.
+ @param path - Path to the matlab binary.
@param verbose - Display informational messages.
'''
- def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose = True):
+ def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose=True):
self.verbose = verbose
self.dataset = dataset
self.path = path
-
- '''
- Destructor to clean up at the end.
- '''
- def __del__(self):
- pass
'''
All K-Nearest-Neighbors. If the method has been successfully completed return
@@ -117,5 +111,4 @@
@return Elapsed time in seconds.
'''
def GetTime(self, timer):
- time = timer.total_time
- return time
+ return timer.total_time
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/hmm_generate.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/hmm_generate.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/hmm_generate.py Mon Jul 22 06:39:06 2013
@@ -33,10 +33,10 @@
Create the HMM Sequence Generator benchmark instance.
@param dataset - Input dataset to perform the HMM Sequence Generator on.
- @param path - Path to the mlpack executable.
+ @param path - Path to the matlab binary.
@param verbose - Display informational messages.
'''
- def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose = True):
+ def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose=True):
self.verbose = verbose
self.dataset = dataset
self.path = path
@@ -61,7 +61,7 @@
def RunMethod(self, options):
Log.Info("Perform HMM GENERATE.", self.verbose)
- # Open the HMM model file and extract the emis and trans values.
+ # Open the HMM xml model file and extract the emis and trans values.
fid = open(self.dataset, 'r')
line = fid.read()
fid.close()
@@ -88,7 +88,6 @@
m = m.split('\n')
m = m[0] + "," + m[1] + "\n"
fidEmis.write(m)
-
fidEmis.close()
fidTrans = open("trans_tmp.csv", "w")
@@ -150,5 +149,4 @@
@return Elapsed time in seconds.
'''
def GetTime(self, timer):
- time = timer.total_time
- return time
+ return timer.total_time
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/hmm_viterbi.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/hmm_viterbi.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/hmm_viterbi.py Mon Jul 22 06:39:06 2013
@@ -33,10 +33,10 @@
Create the HMM Sequence Log-Likelihood benchmark instance.
@param dataset - Input dataset to perform the HMM Sequence Log-Likelihood on.
- @param path - Path to the mlpack executable.
+ @param path - Path to the matlab binary.
@param verbose - Display informational messages.
'''
- def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose = True):
+ def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose=True):
self.verbose = verbose
self.dataset = dataset
self.path = path
@@ -62,11 +62,11 @@
Log.Info("Perform HMM VITERBI.", self.verbose)
if len(self.dataset) != 2:
- Log.Fatal("The method need two datasets.")
+ Log.Fatal("This method requires two datasets.")
return -1
# Open the HMM model file and extract the emis and trans values.
- fid = open(self.dataset[1], 'r')
+ fid = open(self.dataset[1], "r")
line = fid.read()
fid.close()
@@ -154,5 +154,4 @@
@return Elapsed time in seconds.
'''
def GetTime(self, timer):
- time = timer.total_time
- return time
+ return timer.total_time
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/kmeans.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/kmeans.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/kmeans.py Mon Jul 22 06:39:06 2013
@@ -33,19 +33,13 @@
Create the K-Means Clustering benchmark instance.
@param dataset - Input dataset to perform K-Means on.
- @param path - Path to the mlpack executable.
+ @param path - Path to the matlab binary.
@param verbose - Display informational messages.
'''
- def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose = True):
+ def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose=True):
self.verbose = verbose
self.dataset = dataset
self.path = path
-
- '''
- Destructor to clean up at the end.
- '''
- def __del__(self):
- pass
'''
K-Means Clustering benchmark instance. If the method has been successfully
@@ -117,5 +111,4 @@
@return Elapsed time in seconds.
'''
def GetTime(self, timer):
- time = timer.total_time
- return time
+ return timer.total_time
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/linear_regression.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/linear_regression.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/linear_regression.py Mon Jul 22 06:39:06 2013
@@ -33,19 +33,13 @@
Create the Linear Regression benchmark instance.
@param dataset - Input dataset to perform Linear Regression on.
- @param path - Path to the mlpack executable.
+ @param path - Path to the matlab binary.
@param verbose - Display informational messages.
'''
- def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose = True):
+ def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose=True):
self.verbose = verbose
self.dataset = dataset
self.path = path
-
- '''
- Destructor to clean up at the end.
- '''
- def __del__(self):
- pass
'''
Linear Regression benchmark instance. If the method has been successfully
@@ -117,5 +111,4 @@
@return Elapsed time in seconds.
'''
def GetTime(self, timer):
- time = timer.total_time
- return time
+ return timer.total_time
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/nbc.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/nbc.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/nbc.py Mon Jul 22 06:39:06 2013
@@ -33,19 +33,13 @@
Create the Naive Bayes Classifier benchmark instance.
@param dataset - Input dataset to perform NBC on.
- @param path - Path to the mlpack executable.
+ @param path - Path to the matlab binary.
@param verbose - Display informational messages.
'''
def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose=True):
self.verbose = verbose
self.dataset = dataset
self.path = path
-
- '''
- Destructor to clean up at the end.
- '''
- def __del__(self):
- pass
'''
Naive Bayes Classifier. If the method has been successfully completed return
@@ -111,5 +105,4 @@
@return Elapsed time in seconds.
'''
def GetTime(self, timer):
- time = timer.total_time
- return time
+ return timer.total_time
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/nmf.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/nmf.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/nmf.py Mon Jul 22 06:39:06 2013
@@ -33,19 +33,13 @@
Create the Non-negative Matrix Factorization benchmark instance.
@param dataset - Input dataset to perform NMF on.
- @param path - Path to the mlpack executable.
+ @param path - Path to the matlab binary.
@param verbose - Display informational messages.
'''
def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose=True):
self.verbose = verbose
self.dataset = dataset
self.path = path
-
- '''
- Destructor to clean up at the end.
- '''
- def __del__(self):
- pass
'''
Non-negative Matrix Factorization. If the method has been successfully
@@ -111,5 +105,4 @@
@return Elapsed time in seconds.
'''
def GetTime(self, timer):
- time = timer.total_time
- return time
+ return timer.total_time
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/pca.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/pca.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/pca.py Mon Jul 22 06:39:06 2013
@@ -33,19 +33,13 @@
Create the Principal Components Analysis benchmark instance.
@param dataset - Input dataset to perform PCA on.
- @param path - Path to the mlpack executable.
+ @param path - Path to the matlab binary.
@param verbose - Display informational messages.
'''
def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose=True):
self.verbose = verbose
self.dataset = dataset
self.path = path
-
- '''
- Destructor to clean up at the end.
- '''
- def __del__(self):
- pass
'''
Perform Principal Components Analysis. If the method has been successfully
@@ -91,7 +85,6 @@
# Compile the regular expression pattern into a regular expression object to
# parse the timer data.
pattern = re.compile(r"""
- .*?loading_data: (?P<loading_time>.*?)s.*?
.*?total_time: (?P<total_time>.*?)s.*?
""", re.VERBOSE|re.MULTILINE|re.DOTALL)
@@ -101,10 +94,9 @@
return -1
else:
# Create a namedtuple and return the timer data.
- timer = collections.namedtuple("timer", ["loading_time", "total_time"])
+ timer = collections.namedtuple("timer", ["total_time"])
- return timer(float(match.group("loading_time")),
- float(match.group("total_time")))
+ return timer(float(match.group("total_time")))
'''
Return the elapsed time in seconds.
@@ -113,5 +105,4 @@
@return Elapsed time in seconds.
'''
def GetTime(self, timer):
- time = timer.total_time - timer.loading_time
- return time
+ return timer.total_time
Modified: mlpack/conf/jenkins-conf/benchmark/methods/matlab/range_search.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/matlab/range_search.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/matlab/range_search.py Mon Jul 22 06:39:06 2013
@@ -33,19 +33,13 @@
Create the Range Search benchmark instance.
@param dataset - Input dataset to perform Range Search on.
- @param path - Path to the mlpack executable.
+ @param path - Path to the matlab binary.
@param verbose - Display informational messages.
'''
- def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose = True):
+ def __init__(self, dataset, path=os.environ["MATLAB_BIN"], verbose=True):
self.verbose = verbose
self.dataset = dataset
self.path = path
-
- '''
- Destructor to clean up at the end.
- '''
- def __del__(self):
- pass
'''
Perform Range Search. If the method has been successfully completed return the
@@ -117,5 +111,4 @@
@return Elapsed time in seconds.
'''
def GetTime(self, timer):
- time = timer.total_time
- return time
+ return timer.total_time
More information about the mlpack-svn
mailing list