[mlpack-svn] r15662 - mlpack/conf/jenkins-conf/benchmark/methods/scikit
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Mon Aug 26 06:17:46 EDT 2013
Author: marcus
Date: Mon Aug 26 06:17:46 2013
New Revision: 15662
Log:
Use the new timeout function for the scikit methods.
Modified:
mlpack/conf/jenkins-conf/benchmark/methods/scikit/allknn.py
mlpack/conf/jenkins-conf/benchmark/methods/scikit/gmm.py
mlpack/conf/jenkins-conf/benchmark/methods/scikit/ica.py
mlpack/conf/jenkins-conf/benchmark/methods/scikit/kernel_pca.py
mlpack/conf/jenkins-conf/benchmark/methods/scikit/kmeans.py
mlpack/conf/jenkins-conf/benchmark/methods/scikit/lars.py
mlpack/conf/jenkins-conf/benchmark/methods/scikit/linear_regression.py
mlpack/conf/jenkins-conf/benchmark/methods/scikit/nbc.py
mlpack/conf/jenkins-conf/benchmark/methods/scikit/nmf.py
mlpack/conf/jenkins-conf/benchmark/methods/scikit/pca.py
mlpack/conf/jenkins-conf/benchmark/methods/scikit/sparse_coding.py
Modified: mlpack/conf/jenkins-conf/benchmark/methods/scikit/allknn.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/scikit/allknn.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/scikit/allknn.py Mon Aug 26 06:17:46 2013
@@ -46,9 +46,7 @@
@return - Elapsed time in seconds or -1 if the method was not successful.
'''
def AllKnnScikit(self, options):
-
- @timeout(self.timeout, os.strerror(errno.ETIMEDOUT))
- def RunAllKnnScikit():
+ def RunAllKnnScikit(q):
totalTimer = Timer()
# Load input dataset.
@@ -68,12 +66,14 @@
if not k:
Log.Fatal("Required option: Number of furthest neighbors to find.")
+ q.put(-1)
return -1
else:
k = int(k.group(1))
if (k < 1 or k > referenceData.shape[0]):
Log.Fatal("Invalid k: " + k.group(1) + "; must be greater than 0 and "
+ "less ")
+ q.put(-1)
return -1
if not leafSize:
@@ -81,6 +81,7 @@
elif int(leafSize.group(1)) < 0:
Log.Fatal("Invalid leaf size: " + str(leafSize.group(1)) + ". Must be " +
"greater than or equal to 0.")
+ q.put(-1)
return -1
else:
l = int(leafSize.group(1))
@@ -94,13 +95,11 @@
else:
out = model.kneighbors(referenceData, k, return_distance=True)
- return totalTimer.ElapsedTime()
+ time = totalTimer.ElapsedTime()
+ q.put(time)
+ return time
- try:
- return RunAllKnnScikit()
- except TimeoutError as e:
- Log.Warn("Script timed out after " + str(self.timeout) + " seconds")
- return -2
+ return timeout(RunAllKnnMlpy, self.timeout)
'''
Perform All K-Nearest-Neighbors. If the method has been successfully completed
Modified: mlpack/conf/jenkins-conf/benchmark/methods/scikit/gmm.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/scikit/gmm.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/scikit/gmm.py Mon Aug 26 06:17:46 2013
@@ -46,8 +46,6 @@
@return - Elapsed time in seconds or -1 if the method was not successful.
'''
def GMMScikit(self, options):
-
- @timeout(self.timeout, os.strerror(errno.ETIMEDOUT))
def RunGMMScikit():
totalTimer = Timer()
@@ -69,13 +67,11 @@
with totalTimer:
model.fit(dataPoints)
- return totalTimer.ElapsedTime()
+ time = totalTimer.ElapsedTime()
+ q.put(time)
+ return time
- try:
- return RunGMMScikit()
- except TimeoutError as e:
- Log.Warn("Script timed out after " + str(self.timeout) + " seconds")
- return -2
+ return timeout(RunAllKnnMlpy, self.timeout)
'''
Perform Gaussian Mixture Model. If the method has been successfully completed
Modified: mlpack/conf/jenkins-conf/benchmark/methods/scikit/ica.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/scikit/ica.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/scikit/ica.py Mon Aug 26 06:17:46 2013
@@ -46,8 +46,6 @@
@return - Elapsed time in seconds or -1 if the method was not successful.
'''
def ICAScikit(self, options):
-
- @timeout(self.timeout, os.strerror(errno.ETIMEDOUT))
def RunICAScikit():
totalTimer = Timer()
@@ -63,13 +61,11 @@
ic = model.fit(data).transform(data)
mixing = model.get_mixing_matrix()
- return totalTimer.ElapsedTime()
+ time = totalTimer.ElapsedTime()
+ q.put(time)
+ return time
- try:
- return RunICAScikit()
- except TimeoutError as e:
- Log.Warn("Script timed out after " + str(self.timeout) + " seconds")
- return -2
+ return timeout(RunAllKnnMlpy, self.timeout)
'''
Perform independent component analysis. If the method has been successfully
Modified: mlpack/conf/jenkins-conf/benchmark/methods/scikit/kernel_pca.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/scikit/kernel_pca.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/scikit/kernel_pca.py Mon Aug 26 06:17:46 2013
@@ -46,8 +46,6 @@
@return - Elapsed time in seconds or -1 if the method was not successful.
'''
def KPCAScikit(self, options):
-
- @timeout(self.timeout, os.strerror(errno.ETIMEDOUT))
def RunKPCAScikit():
totalTimer = Timer()
@@ -65,6 +63,7 @@
if (d > data.shape[1]):
Log.Fatal("New dimensionality (" + str(d) + ") cannot be greater "
+ "than existing dimensionality (" + str(data.shape[1]) + ")!")
+ q.put(-1)
return -1
# Get the kernel type and make sure it is valid.
@@ -72,6 +71,7 @@
if not kernel:
Log.Fatal("Choose kernel type, valid choices are 'linear', 'hyptan' " +
"and 'polynomial'.")
+ q.put(-1)
return -1
elif kernel.group(1) == "linear":
model = KernelPCA(n_components=d, kernel="linear")
@@ -85,17 +85,16 @@
else:
Log.Fatal("Invalid kernel type (" + kernel.group(1) + "); valid " +
"choices are 'linear', 'hyptan' and 'polynomial'.")
+ q.put(-1)
return -1
out = model.fit_transform(data)
- return totalTimer.ElapsedTime()
+ time = totalTimer.ElapsedTime()
+ q.put(time)
+ return -1
- try:
- return RunKPCAScikit()
- except TimeoutError as e:
- Log.Warn("Script timed out after " + str(self.timeout) + " seconds")
- return -2
+ return timeout(RunAllKnnMlpy, self.timeout)
'''
Perform Kernel Principal Components Analysis. If the method has been
Modified: mlpack/conf/jenkins-conf/benchmark/methods/scikit/kmeans.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/scikit/kmeans.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/scikit/kmeans.py Mon Aug 26 06:17:46 2013
@@ -46,8 +46,6 @@
@return - Elapsed time in seconds or -1 if the method was not successful.
'''
def KMeansScikit(self, options):
-
- @timeout(self.timeout, os.strerror(errno.ETIMEDOUT))
def RunKMeansScikit():
totalTimer = Timer()
@@ -69,10 +67,12 @@
# Now do validation of options.
if not clusters and len(self.dataset) != 2:
Log.Fatal("Required option: Number of clusters or cluster locations.")
+ q.put(-1)
return -1
elif (not clusters or int(clusters.group(1)) < 1) and len(self.dataset) != 2:
Log.Fatal("Invalid number of clusters requested! Must be greater than or "
+ "equal to 1.")
+ q.put(-1)
return -1
m = 1000 if not maxIterations else int(maxIterations.group(1))
@@ -92,13 +92,11 @@
labels = kmeans.labels_
centers = kmeans.cluster_centers_
- return totalTimer.ElapsedTime()
+ time = totalTimer.ElapsedTime()
+ q.put(time)
+ return time
- try:
- return RunKMeansScikit()
- except TimeoutError as e:
- Log.Warn("Script timed out after " + str(self.timeout) + " seconds")
- return -2
+ return timeout(RunAllKnnMlpy, self.timeout)
'''
Perform K-Means Clustering. If the method has been successfully completed
Modified: mlpack/conf/jenkins-conf/benchmark/methods/scikit/lars.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/scikit/lars.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/scikit/lars.py Mon Aug 26 06:17:46 2013
@@ -46,8 +46,6 @@
@return - Elapsed time in seconds or -1 if the method was not successful.
'''
def LARSScikit(self, options):
-
- @timeout(self.timeout, os.strerror(errno.ETIMEDOUT))
def RunLARSScikit():
totalTimer = Timer()
@@ -66,13 +64,11 @@
model.fit(inputData, responsesData)
out = model.coef_
- return totalTimer.ElapsedTime()
+ time = totalTimer.ElapsedTime()
+ q.put(time)
+ return time
- try:
- return RunLARSScikit()
- except TimeoutError as e:
- Log.Warn("Script timed out after " + str(self.timeout) + " seconds")
- return -2
+ return timeout(RunAllKnnMlpy, self.timeout)
'''
Perform Least Angle Regression. If the method has been successfully completed
Modified: mlpack/conf/jenkins-conf/benchmark/methods/scikit/linear_regression.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/scikit/linear_regression.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/scikit/linear_regression.py Mon Aug 26 06:17:46 2013
@@ -46,8 +46,6 @@
@return - Elapsed time in seconds or -1 if the method was not successful.
'''
def LinearRegressionScikit(self, options):
-
- @timeout(self.timeout, os.strerror(errno.ETIMEDOUT))
def RunLinearRegressionScikit():
totalTimer = Timer()
@@ -69,13 +67,11 @@
model.fit(X, y, n_jobs=-1)
b = model.coef_
- return totalTimer.ElapsedTime()
+ time = totalTimer.ElapsedTime()
+ q.put(time)
+ return time
- try:
- return RunLinearRegressionScikit()
- except TimeoutError as e:
- Log.Warn("Script timed out after " + str(self.timeout) + " seconds")
- return -2
+ return timeout(RunAllKnnMlpy, self.timeout)
'''
Perform Linear Regression. If the method has been successfully completed
Modified: mlpack/conf/jenkins-conf/benchmark/methods/scikit/nbc.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/scikit/nbc.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/scikit/nbc.py Mon Aug 26 06:17:46 2013
@@ -46,8 +46,6 @@
@return - Elapsed time in seconds or -1 if the method was not successful.
'''
def NBCScikit(self, options):
-
- @timeout(self.timeout, os.strerror(errno.ETIMEDOUT))
def RunNBCScikit():
totalTimer = Timer()
@@ -67,13 +65,11 @@
# Run Naive Bayes Classifier on the test dataset.
nbc.predict(testData)
- return totalTimer.ElapsedTime()
+ time = totalTimer.ElapsedTime()
+ q.put(time)
+ return time
- try:
- return RunNBCScikit()
- except TimeoutError as e:
- Log.Warn("Script timed out after " + str(self.timeout) + " seconds")
- return -2
+ return timeout(RunAllKnnMlpy, self.timeout)
'''
Perform Naive Bayes Classifier. If the method has been successfully
Modified: mlpack/conf/jenkins-conf/benchmark/methods/scikit/nmf.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/scikit/nmf.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/scikit/nmf.py Mon Aug 26 06:17:46 2013
@@ -46,8 +46,6 @@
@return - Elapsed time in seconds or -1 if the method was not successful.
'''
def NMFScikit(self, options):
-
- @timeout(self.timeout, os.strerror(errno.ETIMEDOUT))
def RunNMFScikit():
totalTimer = Timer()
@@ -69,6 +67,7 @@
u = updateRule.group(1)
if u != 'alspgrad':
Log.Fatal("Invalid update rules ('" + u + "'); must be 'alspgrad'.")
+ q.put(-1)
return -1
# Perform NMF with the specified update rules.
@@ -81,13 +80,11 @@
W = model.fit_transform(data)
H = model.components_
- return totalTimer.ElapsedTime()
+ time = totalTimer.ElapsedTime()
+ q.put(time)
+ return time
- try:
- return RunNMFScikit()
- except TimeoutError as e:
- Log.Warn("Script timed out after " + str(self.timeout) + " seconds")
- return -2
+ return timeout(RunAllKnnMlpy, self.timeout)
'''
Perform Non-negative Matrix Factorization. If the method has been successfully
Modified: mlpack/conf/jenkins-conf/benchmark/methods/scikit/pca.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/scikit/pca.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/scikit/pca.py Mon Aug 26 06:17:46 2013
@@ -46,8 +46,6 @@
@return - Elapsed time in seconds or -1 if the method was not successful.
'''
def PCAScikit(self, options):
-
- @timeout(self.timeout, os.strerror(errno.ETIMEDOUT))
def RunPCAScikit():
totalTimer = Timer()
@@ -66,6 +64,7 @@
if (k > data.shape[1]):
Log.Fatal("New dimensionality (" + str(k) + ") cannot be greater "
+ "than existing dimensionality (" + str(data.shape[1]) + ")!")
+ q.put(-1)
return -1
# Get the options for running PCA.
@@ -76,13 +75,11 @@
pca.fit(data)
score = pca.transform(data)
- return totalTimer.ElapsedTime()
+ time = totalTimer.ElapsedTime()
+ q.put(time)
+ return time
- try:
- return RunPCAScikit()
- except TimeoutError as e:
- Log.Warn("Script timed out after " + str(self.timeout) + " seconds")
- return -2
+ return timeout(RunAllKnnMlpy, self.timeout)
'''
Perform Principal Components Analysis. If the method has been successfully
Modified: mlpack/conf/jenkins-conf/benchmark/methods/scikit/sparse_coding.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/scikit/sparse_coding.py (original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/scikit/sparse_coding.py Mon Aug 26 06:17:46 2013
@@ -46,8 +46,6 @@
@return - Elapsed time in seconds or -1 if the method was not successful.
'''
def SparseCodingScikit(self, options):
-
- @timeout(self.timeout, os.strerror(errno.ETIMEDOUT))
def RunSparseCodingScikit():
totalTimer = Timer()
@@ -65,13 +63,11 @@
transform_alpha=l)
code = model.transform(inputData)
- return totalTimer.ElapsedTime()
+ time = totalTimer.ElapsedTime()
+ q.put(time)
+ return time
- try:
- return RunSparseCodingScikit()
- except TimeoutError as e:
- Log.Warn("Script timed out after " + str(self.timeout) + " seconds")
- return -2
+ return timeout(RunAllKnnMlpy, self.timeout)
'''
Perform Sparse Coding. If the method has been successfully completed
More information about the mlpack-svn
mailing list