本文整理汇总了Python中SSUtilities.iteritems方法的典型用法代码示例。如果您正苦于以下问题:Python SSUtilities.iteritems方法的具体用法?Python SSUtilities.iteritems怎么用?Python SSUtilities.iteritems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SSUtilities
的用法示例。
在下文中一共展示了SSUtilities.iteritems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getMoranStats
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import iteritems [as 别名]
def getMoranStats(self):
self.sumMoranRuns = 0
self.sumMoranPass = 0
miValues = []
miModels = []
miSorted = NUM.array([(0.0, 0.0), (0.0, 0.0), (0.0, 0.0)],
dtype = [('mi', float), ('r2', float)])
for resKey, resHandler in UTILS.iteritems(self.resultDict):
for olsKey, olsRes in UTILS.iteritems(resHandler.olsResults):
miValue = olsRes.miPVal
if miValue is not None:
numRes = len(miValues)
if numRes < 3:
miValues.append(miValue)
miModels.append(olsRes)
else:
if numRes == 3:
miSorted['mi'] = miValues
miSorted['r2'] = [ ols.r2 for ols in miModels ]
minIndex = miSorted.argsort(order = ('mi', 'r2'))[0]
minValue = miValues[minIndex]
valueSame = UTILS.compareFloat(minValue, miValue)
update = False
if valueSame:
if olsRes.r2 > miModels[minIndex].r2:
update = True
else:
if minValue < miValue:
update = True
if update:
miValues[minIndex] = miValue
miModels[minIndex] = olsRes
miSorted['mi'][minIndex] = miValue
miSorted['r2'][minIndex] = olsRes.r2
self.sumMoranRuns += 1
if miValue > self.minMI:
self.sumMoranPass += 1
miOrder = list(miSorted.argsort(order = ('mi', 'r2')))
#miOrder = list(NUM.argsort(miValues))
miOrder.reverse()
self.miReportRows = []
for miIndex in miOrder:
try:
miResult = miModels[miIndex]
self.miReportRows.append(miResult.report(orderType = 2))
except:
pass
示例2: poly2Weights
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import iteritems [as 别名]
def poly2Weights(ssdo, contiguityType = "ROOK", rowStandard = True):
"""Uses GP Polygon Neighbor Tool to construct contiguity relationships
and stores them in PySAL Sparse Spatial Weights class.
INPUTS:
ssdo (class): instance of SSDataObject [1]
contiguityType {str, ROOK}: ROOK or QUEEN contiguity
rowStandard {bool, True}: whether to row standardize the spatial weights
NOTES:
(1) Data must already be obtained using ssdo.obtainData() or ssdo.obtainDataGA ()
"""
neighbors = {}
weights = {}
polyNeighDict = WU.polygonNeighborDict(ssdo.inputFC, ssdo.masterField,
contiguityType = contiguityType)
for masterID, neighIDs in UTILS.iteritems(polyNeighDict):
orderID = ssdo.master2Order[masterID]
neighbors[orderID] = [ssdo.master2Order[i] for i in neighIDs]
w = PYSAL.W(neighbors)
if rowStandard:
w.transform = 'R'
return w
示例3: endSummary
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import iteritems [as 别名]
def endSummary(self):
"""Creates End Summary for Report File."""
#### Passing Model Global Summary ####
passHeader = ARCPY.GetIDMessage(84294)
emptyValue = ARCPY.GetIDMessage(84092)
perfectMultiStr = ARCPY.GetIDMessage(84368)
perfectInterStr = ARCPY.GetIDMessage(84369)
perfectInterStr += " (%s)" % LOCALE.format("%0.2f", 100)
passResults = [ [ARCPY.GetIDMessage(84295),
ARCPY.GetIDMessage(84296),
ARCPY.GetIDMessage(84297),
ARCPY.GetIDMessage(84298),
ARCPY.GetIDMessage(84299)] ]
cutoffList = [ "> " + UTILS.formatValue(self.minR2, "%0.2f"),
"< " + UTILS.formatValue(self.maxCoef, "%0.2f"),
"< " + UTILS.formatValue(self.maxVIF, "%0.2f"),
"> " + UTILS.formatValue(self.minJB, "%0.2f"),
"> " + UTILS.formatValue(self.minMI, "%0.2f") ]
categories = [ARCPY.GetIDMessage(84300), ARCPY.GetIDMessage(84301),
ARCPY.GetIDMessage(84302), ARCPY.GetIDMessage(84303),
ARCPY.GetIDMessage(84304)]
boolPerc = [ returnPerc(i, self.sumRuns) for i in self.boolResults ]
boolPerc.append( returnPerc(self.sumMoranPass, self.sumMoranRuns) )
boolOut = list(self.boolResults) + [self.sumMoranPass]
sumOut = [ self.sumRuns for i in self.boolResults ]
sumOut += [self.sumMoranRuns]
for ind, category in enumerate(categories):
outValue = LOCALE.format("%0.2f", boolPerc[ind])
outCutoff = cutoffList[ind]
outTrial = sumOut[ind]
outCount = boolOut[ind]
passResults.append( [category, outCutoff, outTrial,
outCount, outValue] )
self.passReport = UTILS.outputTextTable(passResults,
header = passHeader,
pad = 1, justify = "right")
##### Variable Significance and VIF Reports ####
##### Create Table Headers ####
signHeader = ARCPY.GetIDMessage(84305)
vifHeader = ARCPY.GetIDMessage(84306)
#### Create Column Labels and Result Lists ####
signColInfo = [ [ARCPY.GetIDMessage(84068), ARCPY.GetIDMessage(84307),
ARCPY.GetIDMessage(84366), ARCPY.GetIDMessage(84367)] ]
signResults = []
vifResults = [ [ARCPY.GetIDMessage(84068), ARCPY.GetIDMessage(84284),
ARCPY.GetIDMessage(84308), ARCPY.GetIDMessage(84309)] ]
##### Get Covariate Total ####
percVarRes = []
totalTogether = 0
for resultKey, result in UTILS.iteritems(self.resultDict):
totalTogether += result.eachAppears
##### Populate Result Lists ####
for ind, varName in enumerate(self.independentVars):
totalNeg = 0
totalPos = 0
totalSign = 0
totalRan = 0
totalViolations = 0
totalCovariates = COLL.defaultdict(int)
for resultKey, result in UTILS.iteritems(self.resultDict):
#### Significance Results ####
numRan, numSign = result.signDict[varName]
totalSign += numSign
totalRan += numRan
numNeg, numPos = result.varSignDict[varName]
totalNeg += numNeg
totalPos += numPos
#### VIF Results ####
numViolate, covariates = result.vifDict[varName]
totalViolations += numViolate
for covariate in covariates:
if covariate != varName:
totalCovariates[covariate] += 1
#### Add Perfect Multicollinearity Results * ####
successfulRun = totalRan > 0
#### Complete Significance Row ####
if successfulRun:
percentSign = ((totalSign * 1.0) / totalRan) * 100.0
percentNeg = ((totalNeg * 1.0) / totalRan) * 100.0
percentPos = ((totalPos * 1.0) / totalRan) * 100.0
rowRes = [varName, LOCALE.format("%0.2f", percentSign),
LOCALE.format("%0.2f", percentNeg),
LOCALE.format("%0.2f", percentPos)]
else:
percentSign = -1.0
rowRes = [varName, emptyValue, emptyValue, emptyValue]
#.........这里部分代码省略.........