本文整理汇总了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)
示例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