本文簡要介紹
pyspark.ml.linalg.SparseVector.squared_distance
的用法。用法:
squared_distance(other)
與 SparseVector 或一維 NumPy 數組的平方距離。
例子:
>>> a = SparseVector(4, [1, 3], [3.0, 4.0]) >>> a.squared_distance(a) 0.0 >>> a.squared_distance(array.array('d', [1., 2., 3., 4.])) 11.0 >>> a.squared_distance(np.array([1., 2., 3., 4.])) 11.0 >>> b = SparseVector(4, [2], [1.0]) >>> a.squared_distance(b) 26.0 >>> b.squared_distance(a) 26.0 >>> b.squared_distance([1., 2.]) Traceback (most recent call last): ... AssertionError: dimension mismatch >>> b.squared_distance(SparseVector(3, [1,], [1.0,])) Traceback (most recent call last): ... AssertionError: dimension mismatch
相關用法
- Python pyspark SparseVector.parse用法及代碼示例
- Python pyspark SparseVector.dot用法及代碼示例
- Python pyspark SparseVector.norm用法及代碼示例
- Python pyspark SparkConf用法及代碼示例
- Python pyspark SparkSession.createDataFrame用法及代碼示例
- Python pyspark SparkSession.table用法及代碼示例
- Python pyspark SparkContext.addFile用法及代碼示例
- Python pyspark SparkContext.union用法及代碼示例
- Python pyspark SparkContext.runJob用法及代碼示例
- Python pyspark SparkContext.parallelize用法及代碼示例
- Python pyspark SparkSession用法及代碼示例
- Python pyspark SparkSession.builder.config用法及代碼示例
- Python pyspark SparkSession.getActiveSession用法及代碼示例
- Python pyspark SparkContext用法及代碼示例
- Python pyspark SparkContext.range用法及代碼示例
- Python pyspark SparkContext.setJobGroup用法及代碼示例
- Python pyspark SparkContext.pickleFile用法及代碼示例
- Python pyspark SparkContext.applicationId用法及代碼示例
- Python pyspark SparkContext.wholeTextFiles用法及代碼示例
- Python pyspark SparkContext.textFile用法及代碼示例
- Python pyspark SparkSession.range用法及代碼示例
- Python pyspark SparkSession.sql用法及代碼示例
- Python pyspark SparkSession.builder.getOrCreate用法及代碼示例
- Python pyspark Series.asof用法及代碼示例
- Python pyspark Series.to_frame用法及代碼示例
注:本文由純淨天空篩選整理自spark.apache.org大神的英文原創作品 pyspark.ml.linalg.SparseVector.squared_distance。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。