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


Python SparseVector.values方法代码示例

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


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

示例1: parseHashPoint

# 需要导入模块: from pyspark.mllib.linalg import SparseVector [as 别名]
# 或者: from pyspark.mllib.linalg.SparseVector import values [as 别名]
def parseHashPoint(point, numBuckets):
    """Create a LabeledPoint for this observation using hashing.

    Args:
        point (str): A comma separated string where the first value is the label and the rest are
            features.
        numBuckets: The number of buckets to hash to.

    Returns:
        LabeledPoint: A LabeledPoint with a label (0.0 or 1.0) and a SparseVector of hashed
            features.
    """
    label = point.split(",")[0]

    unkeyed_features = point.split(",")[1:]
    
    index = 0
    keyed_features = []
    for feature in unkeyed_features:
      keyed_features.append((index, feature))
      index += 1
    
    features = hashFunction(numBuckets, keyed_features, True)
    features = SparseVector(numBuckets, sorted(features.keys()), features.values())
    
    return LabeledPoint(label, features)
开发者ID:tcoatale,项目名称:Click_through_rate_prediction,代码行数:28,代码来源:click_through_rate_prediction.py

示例2: f

# 需要导入模块: from pyspark.mllib.linalg import SparseVector [as 别名]
# 或者: from pyspark.mllib.linalg.SparseVector import values [as 别名]
	def f(champ):
		i = 0
		newVects = []

		while champ + i * (max(champions) + 1) < len(partialVect):
			newVect = SparseVector(len(partialVect), partialVect.indices, partialVect.values)
			newVect.indices = numpy.append(newVect.indices, [champ + i * (max(champions) + 1)])
			newVect.values = numpy.append(newVect.values, [sign])
			newVects.append(newVect)
			i += 1

		return newVects
开发者ID:Sapphirine,项目名称:LeaguePredictor,代码行数:14,代码来源:learn.py


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