Ejemplo n.º 1
0
	def test(self,lstSamples,model):
		"""Test the libSVM classifier on the sample set and return the ClassificationResults."""
		
		classification_results = ClassificationResults()
		print "Testing on %d samples"%(len(lstSamples))
		for sample in lstSamples:
			#if sample.get_class_label() != self.null_flag:	# RVF
			if True: # RVF. Also classify the sample, if the class is previously unknown
				best_class = self.classify(sample,model)
				classification_results.add_classification(sample.id,best_class,sample.get_class_label())
		return classification_results
Ejemplo n.º 2
0
	def test(self,lstSamples,model,confusionMatrix={}):
		"""Test the CPAR classifier on the sample set and return the ClassificationResults."""
		self.rules = model
		self.rules.set_target_accuracy(self.parameters["accuracy_measure"])
		lstRules = self.rules.remap_feature_to_index(lstSamples)
		if len(lstRules) ==0:
			return 0
		classification_results = ClassificationResults()
		print "Testing on %d samples"%(len(lstSamples))
		for sample in lstSamples:
			#if sample.get_class_label() != self.null_flag: # uncommented by RVF
			if True: # RVF. Also classify the sample, if the class is previously unknown
				intBestClass = self.classify(sample,lstRules)
				classification_results.add_classification(sample.id,intBestClass,sample.get_class_label())

		return classification_results