コード例 #1
0
ファイル: crossvalidate.py プロジェクト: FloFlo93/PICA
		trainer = TrainerClass.__dict__[classname](options.parameters, C=options.C)
	else:
		trainer = TrainerClass.__dict__[classname](options.parameters)
	trainer.set_null_flag("NULL")
	
	modulepath = "pica.classifiers.%s"%(options.classification_algorithm)
	classname = options.classification_algorithm.split(".")[-1]
	ClassifierClass = __import__(modulepath, fromlist=(classname,))
	classifier = ClassifierClass.__dict__[classname](options.parameters)
	classifier.set_null_flag("NULL")
	
	test_configurations = [TestConfiguration("A",None,trainer,classifier)]
	
	#RVF changed (added the last 3 parameters)
	if ( options.crossval_files ):
		crossvalidator = CrossValidation(samples,options.parameters,options.folds,options.replicates,test_configurations,False,None,options.target_class,options.output_filename)
	else:
		crossvalidator = CrossValidation(samples,options.parameters,options.folds,options.replicates,test_configurations)		
	crossvalidator.crossvalidate()
	classifications,misclassifications = crossvalidator.get_classification_vector()
	metadata = None
	if options.metadata:
		metadata = fileio.load_metadata(options.metadata)
	
	fout = open(options.output_filename,"w")
	fout.write("who\t%s\tFalse Classifications\tTrue Classifications\tTotal"%(options.target_class))
	if metadata:
		for key in metadata.get_key_list():
			fout.write("\t%s"%(key))
	fout.write("\n")
	for who in misclassifications.keys():
コード例 #2
0
ファイル: batch_validate.py プロジェクト: pythseq/PICA
	
	samples.set_current_class(options.target_class)
	print "Parameters from %s"%(options.parameters)
	print "Compressing features...",
	samples = samples.compress_features()
	print "compressed to %d distinct features."%(samples.get_number_of_features())
	
	samples.set_current_class(options.target_class)
	samples.hide_nulls(options.target_class)
	
	test_configurations = []
	confounders = ("genus","family","order","class","phylum","superkingdom")
	scores_list = (("cmi",),("cwmi",),("mi","cwmi"))
	
	feature_selector = CWMIRankFeatureSelector(confounders_filename=options.parameters,scores=("mi",),features_per_class=options.features_per_class,confounder=options.confounder)
	trainer = libSVMTrainer(kernel_type="LINEAR",C=5)
	classifier = libSVMClassifier()
	tc = TestConfiguration("mi",feature_selector,trainer,classifier)
	test_configurations.append(tc)
	

	for scores in scores_list:
		feature_selector = CWMIRankFeatureSelector(features_per_class=options.features_per_class,confounder=options.confounder,scores=scores,confounders_filename=options.parameters)
		tc = TestConfiguration("%s_%s"%("_".join(scores),options.confounder),feature_selector,trainer,classifier)
		test_configurations.append(tc)

	root = "%s_%s_p%dn%d"%(options.target_class,options.confounder,options.features_per_class,options.features_per_class)
	
	crossvalidator = CrossValidation(samples,options.parameters,options.folds,options.replicates,test_configurations,root_output=options.output_filename)
	crossvalidator.crossvalidate()