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'])
params={ 'cpType':1, 'numClasses':2, 'confList':[.5,.4,.3,.2,.1,.05,.01], 'trainPortion':.75, 'calibPortion':.25, 'classifier':3, 'flavor':None, 'k':None, } scidict = prepareData(scidict, params) 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'])) )