当前位置: 首页>>代码示例>>Python>>正文


Python Utility.haversine方法代码示例

本文整理汇总了Python中utility.Utility.haversine方法的典型用法代码示例。如果您正苦于以下问题:Python Utility.haversine方法的具体用法?Python Utility.haversine怎么用?Python Utility.haversine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utility.Utility的用法示例。


在下文中一共展示了Utility.haversine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _updateLabelersStats

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import haversine [as 别名]
 def _updateLabelersStats(self, expertise, expertId, regionName, userData):
     '''
     Generates the statistics for the labeling users 
     Calculates that what percentage of the labeling
     users lie in a certain city within in a given 
     radius.
     '''
     userLocation = userData[2], userData[3]
     region = self._regions[regionName]
     regionCenter = region['center']
     distance = Utility.haversine(regionCenter[0], regionCenter[1], userLocation[0], userLocation[1])
     
     if expertise not in self._labelerStatsDict:
         self._labelerStatsDict[expertise] = {}
         
     if expertId not in self._labelerStatsDict[expertise]:
         self._labelerStatsDict[expertise][expertId] = {}
         
         for regionName in self._regions:
             self._labelerStatsDict[expertise][expertId][regionName] = {}
             self._labelerStatsDict[expertise][expertId][regionName]['inside'] = 0
             self._labelerStatsDict[expertise][expertId][regionName]['outside'] = 0
     
     if distance < self._getEffectiveRadius(regionName):
         self._labelerStatsDict[expertise][expertId][regionName]['inside'] += 1
         
     else:
         self._labelerStatsDict[expertise][expertId][regionName]['outside'] += 1
开发者ID:hbarthwal,项目名称:infolab,代码行数:30,代码来源:simple_probabilistic_expert_model.py

示例2: _getScore

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import haversine [as 别名]
 def _getScore(self, userData, regionName):
     '''
     Calculates the score for an expert given by a user
     the score is discounted using the log10(distance)
     therefore the user far away from the expertise location
     of the expert will be ble to assign a lower score for 
     that expertise. 
     '''
     userLocation = userData[2], userData[3]
     regionCenter = self._regions[regionName]['center']
     distance = Utility.haversine(regionCenter[0], regionCenter[1], userLocation[0], userLocation[1])
     # This is the equation used for calculating the score for the
     # expert.
     score = self._getEffectiveRadius(regionName)/ (self._Dmin + distance)
     score = pow(score, self._alpha)
     return score
开发者ID:hbarthwal,项目名称:infolab,代码行数:18,代码来源:simple_probabilistic_expert_model.py

示例3: _bucketUserData

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import haversine [as 别名]
 def _bucketUserData(self):
     #print 'Bucketing ', len(self._usersData), ' users !'
     #count = 0
     expertise = self._region.getExpertise()
     
     #print 'bucketing for ', self._region.getName()
     for userData in self._usersData:
         userLocation = (userData[2], userData[3])
         # print userData
         # The root expertise region from which this child has descended
         parentRegion = None
         if self._region.isParent():
             parentRegion = self._region
         else:
             parentRegion = self._region.getParent()
         
         
         if parentRegion.boundsLocation(userData):
             #count += 1
             # if the user data is corresponding to a location 
             # belonging to the expertise region only then we include it in
             # our calculation
             userConfidence = userData[1]
             userDistance = Utility.haversine(self._center[1], self._center[0], userLocation[1], userLocation[0])
             isExpert = (expertise == userData[4])
             distanceBucketKey = self._getBucketKey(userDistance)
             requiredKey, nonRequiredKey = self._getKeys(isExpert)
             
             if not distanceBucketKey in self._bucketedUserData:
                
                 self._bucketedUserData[distanceBucketKey] = {}
                 self._bucketedUserData[distanceBucketKey][requiredKey] = {'distanceSum': userDistance,
                                                                   'confidenceSum': userConfidence,
                                                                   'usersCount': 1
                                                                  }
                 self._bucketedUserData[distanceBucketKey][nonRequiredKey] = {'distanceSum': 0.0,
                                                                           'confidenceSum': 0.0,
                                                                           'usersCount': 0
                                                                           }
             else:
                 # calculating the sum of all users' distance and confidence within a 
                 # certain radius denoted by the bucketKey
                 #print 'Incrementing------------------------------------'
                 self._bucketedUserData[distanceBucketKey][requiredKey]['distanceSum'] += userDistance
                 self._bucketedUserData[distanceBucketKey][requiredKey]['confidenceSum'] += userConfidence
                 self._bucketedUserData[distanceBucketKey][requiredKey]['usersCount'] += 1
开发者ID:hbarthwal,项目名称:infolab,代码行数:48,代码来源:bucket_users.py


注:本文中的utility.Utility.haversine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。