[mlpack-svn] r15259 - mlpack/conf/jenkins-conf/benchmark/methods/mlpack

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue Jun 18 15:37:34 EDT 2013


Author: marcus
Date: 2013-06-18 15:37:34 -0400 (Tue, 18 Jun 2013)
New Revision: 15259

Modified:
   mlpack/conf/jenkins-conf/benchmark/methods/mlpack/pca.py
Log:
Add regex to get the description.

Modified: mlpack/conf/jenkins-conf/benchmark/methods/mlpack/pca.py
===================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/mlpack/pca.py	2013-06-18 17:49:13 UTC (rev 15258)
+++ mlpack/conf/jenkins-conf/benchmark/methods/mlpack/pca.py	2013-06-18 19:37:34 UTC (rev 15259)
@@ -33,28 +33,28 @@
 		self.dataset = dataset
 		self.path = path
 
-		description = '''Principal Components Analysis, or simply PCA is a 
-											statistical procedure that uses an orthogonal
-											transformation to convert a set of observations
-											of possibly correlated variables into a set of values
-											of linearly uncorrelated variables called principal 
-											components. In particular it allows us to identify 
-											the principal directions in which the data varies.
-											These statistical procedure has found application 
-											in fields such as face recognition and image 
-											compression, and is a common technique for finding
-											patterns in data of high dimension. In case where a
-											graphical representation is not available, PCA is a
-											powerful tool for analysing data, without much loss
-											of information.'''
+		# Get description from executable.
+		cmd = shlex.split(self.path + "pca -h")
+		s = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=False)	
+
+		# Use regular expression pattern to get the description.
+		pattern = re.compile(r"""(.*?)Required.*?options:""", 
+				re.VERBOSE|re.MULTILINE|re.DOTALL)
 		
+		match = pattern.match(s)
+		if not match:
+			Log.Fatal("Can't parse description", self.verbose)
+			description = ''
+		else:
+			description = match.group(1)
+		
 		# Show method informations.
-		#Log.Notice(description)
-		#Log.Notice('\n')
+		# Log.Notice(description)
+		# Log.Notice('\n')
 
 	# Remove created files.
 	def __del__(self):		
-		Log.Info('Clean up.')
+		Log.Info('Clean up.', self.verbose)
 		filelist = ['gmon.out', 'output.csv']
 		for f in filelist:
 			if os.path.isfile(f):
@@ -75,7 +75,7 @@
 		# Return the elapsed time.
 		timer = self.parseTimer(s)
 		if not timer:
-			Log.Fatal("can't parse the timer", self.verbose)
+			Log.Fatal("Can't parse the timer", self.verbose)
 			return 0
 		else:
 			time = self.GetTime(timer)




More information about the mlpack-svn mailing list