本文簡要介紹
pyspark.ml.linalg.DenseVector.squared_distance
的用法。用法:
squared_distance(other)
兩個向量的平方距離。
例子:
>>> dense1 = DenseVector(array.array('d', [1., 2.])) >>> dense1.squared_distance(dense1) 0.0 >>> dense2 = np.array([2., 1.]) >>> dense1.squared_distance(dense2) 2.0 >>> dense3 = [2., 1.] >>> dense1.squared_distance(dense3) 2.0 >>> sparse1 = SparseVector(2, [0, 1], [2., 1.]) >>> dense1.squared_distance(sparse1) 2.0 >>> dense1.squared_distance([1.,]) Traceback (most recent call last): ... AssertionError: dimension mismatch >>> dense1.squared_distance(SparseVector(1, [0,], [1.,])) Traceback (most recent call last): ... AssertionError: dimension mismatch
相關用法
- Python pyspark DenseVector.parse用法及代碼示例
- Python pyspark DenseVector.norm用法及代碼示例
- Python pyspark DenseVector.dot用法及代碼示例
- Python pyspark DenseVector用法及代碼示例
- Python pyspark DenseMatrix.toArray用法及代碼示例
- Python pyspark DecisionTreeClassifier用法及代碼示例
- Python pyspark DecisionTree.trainClassifier用法及代碼示例
- Python pyspark DecisionTreeRegressor用法及代碼示例
- Python pyspark DecisionTree.trainRegressor用法及代碼示例
- Python pyspark DataFrame.to_latex用法及代碼示例
- Python pyspark DataStreamReader.schema用法及代碼示例
- Python pyspark DataFrame.align用法及代碼示例
- Python pyspark DataFrame.plot.bar用法及代碼示例
- Python pyspark DataFrame.to_delta用法及代碼示例
- Python pyspark DataFrame.quantile用法及代碼示例
- Python pyspark DataFrameWriter.partitionBy用法及代碼示例
- Python pyspark DataFrame.cumsum用法及代碼示例
- Python pyspark DatetimeIndex.is_month_start用法及代碼示例
- Python pyspark DataFrame.iloc用法及代碼示例
- Python pyspark DatetimeIndex.normalize用法及代碼示例
- Python pyspark DataFrame.dropDuplicates用法及代碼示例
- Python pyspark DatetimeIndex.is_month_end用法及代碼示例
- Python pyspark DataFrame.printSchema用法及代碼示例
- Python pyspark DataFrame.to_table用法及代碼示例
- Python pyspark DatetimeIndex.is_quarter_start用法及代碼示例
注:本文由純淨天空篩選整理自spark.apache.org大神的英文原創作品 pyspark.ml.linalg.DenseVector.squared_distance。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。