本文整理汇总了Python中utility.Utility.getModelValue方法的典型用法代码示例。如果您正苦于以下问题:Python Utility.getModelValue方法的具体用法?Python Utility.getModelValue怎么用?Python Utility.getModelValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utility.Utility
的用法示例。
在下文中一共展示了Utility.getModelValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: partitionUsers
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import getModelValue [as 别名]
def partitionUsers(expertModels, expertise):
for userData in UsersData._usersData:
pValues = []
for expertModel in expertModels:
userLocation = (userData[2], userData[3])
isExpert = userData[4] == expertise
p = Utility.getModelValue(expertModel, userLocation, isExpert)
pValues.append((p, expertModel['regionName']))
maxPRegion = max(pValues, key = itemgetter(0))[1]
if len(userData) == 5:
userData.append(maxPRegion)
else:
userData[5] = maxPRegion
UsersData._isPartitioned = True
示例2: getRankedExperts
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import getModelValue [as 别名]
def getRankedExperts(self, expertise, userLocation):
if len(self._expertModelsDict) == 0:
self._modelGenerator.loadCachedModels()
self._expertModelsDict = self._modelGenerator.getExpertImpactModels()[expertise]
expertImpactList = []
for expert in self._expertModelsDict:
models = self._expertModelsDict[expert]
modelValue = 0
prevModelValue = 0
for model in models:
modelValue = Utility.getModelValue(model, userLocation, True)
modelValue = max(modelValue, prevModelValue)
prevModelValue = modelValue
expertImpactList.append((modelValue, expert))
rankedExpertsData = sorted(expertImpactList, key = itemgetter(0), reverse = True)
rankedExperts = []
print rankedExpertsData
for rankedExpertData in rankedExpertsData:
rankedExperts.append(rankedExpertData[1])
return rankedExperts