Example #1
0
def verboseOutput(params, scidict):
	"""
		Perform Calculations and then output
		Driver File for CP execution
	"""

	#copied from verboseError.py
	scidict = prepareData(params, scidict)

	#compute p values
	pValMat = p2mat.computePVal(scidict['trainData'],scidict['testData'],scidict['trainLabels'],scidict['testLabels'], params)

	print "printing: point | p-value by class | true label"
	size = pValMat.shape
	for point in xrange(size[0]):
		print point,pValMat[point,:],scidict['testTarget'][point]


	# verbose results
	errorMat = np.zeros( (len(params['confList']),len(['emptyError','predError','multiError'])) )
	errorSourceMat = [ [ [],[],[] ] for i in xrange(len(params['confList'])) ]

	errorArray = np.zeros( (len(['emptyError','predError','multiError']),len(pValMat),len(params['confList'])) )
	errorArraySource = [ [ [],[],[] ] for i in xrange(len(params['confList'])) ]

	####################################################################
	#	Write code here for computing errorArraySource



	####################################################################

	#print source results
	print "printing: confidence level | errors by type | points causing error"
	for i in xrange(len(params['confList'])):
		errorSum = np.sum(errorArray[:,:,i],axis=1)
		print 1-params['confList'][i],errorSum,errorArraySource[i][1]

	# which points at 95% confidence have prediction error
	logical = errorArray[1,:,5] == 1
	size = pValMat.shape
	for point in xrange(len(pValMat)):
		if logical[point] == 1:
			print point,pValMat[point,:],scidict['testLabels'][point]

	ep.errorPlot(errorArray,params['confList'])
Example #2
0
if params['cpType'] != 2:
	#not inductive
	pValMat = p2mat.computePVal(scidict.data,scidict.testData,scidict.target,scidict.testTarget,params)

else:
	#inductive
	pValMat = p2mat.computePVal(scidict.data,scidict.testData,scidict.target,scidict.testTarget,params,scidict.calibIndices)

for i in xrange(len(pValMat)):
	print pValMat[i,:], scidict.testTarget[i]

#for manual check of results
#for i in xrange(len(pValMat)):
#	print pValMat[i,:],scidict.testTarget[i]

#four dimensional array object; tuple is mneumonic
#runs an error test
errorArray = np.zeros( (len(['emptyError','predError','multiError']),len(pValMat),len(params['confList'])) )
#for confIndex in xrange(len(params['confList'])):
for confIndex in xrange(2,3):
	confLevel = params['confList'][confIndex]
	for p in xrange(len(pValMat)):
		errorArray[:,p,confIndex] = er.errors(pValMat[p,:],confLevel,scidict.testTarget[p],params,outType=1)
		print errorArray[:,p,confIndex]

print "sum"
print sum(errorArray[:,:,2],axis=1)

ep.errorPlot(pValMat,errorArray,params)