本文簡要介紹
pyspark.ml.feature.ElementwiseProduct
的用法。用法:
class pyspark.ml.feature.ElementwiseProduct(*, scalingVec=None, inputCol=None, outputCol=None)
使用提供的 “weight” 向量輸出每個輸入向量的 Hadamard 乘積(即元素乘積)。換句話說,它通過標量乘數縮放數據集的每一列。
1.5.0 版中的新函數。
例子:
>>> from pyspark.ml.linalg import Vectors >>> df = spark.createDataFrame([(Vectors.dense([2.0, 1.0, 3.0]),)], ["values"]) >>> ep = ElementwiseProduct() >>> ep.setScalingVec(Vectors.dense([1.0, 2.0, 3.0])) ElementwiseProduct... >>> ep.setInputCol("values") ElementwiseProduct... >>> ep.setOutputCol("eprod") ElementwiseProduct... >>> ep.transform(df).head().eprod DenseVector([2.0, 2.0, 9.0]) >>> ep.setParams(scalingVec=Vectors.dense([2.0, 3.0, 5.0])).transform(df).head().eprod DenseVector([4.0, 3.0, 15.0]) >>> elementwiseProductPath = temp_path + "/elementwise-product" >>> ep.save(elementwiseProductPath) >>> loadedEp = ElementwiseProduct.load(elementwiseProductPath) >>> loadedEp.getScalingVec() == ep.getScalingVec() True >>> loadedEp.transform(df).take(1) == ep.transform(df).take(1) True
相關用法
- Python pyspark Expanding.count用法及代碼示例
- Python pyspark Expanding.min用法及代碼示例
- Python pyspark Expanding.max用法及代碼示例
- Python pyspark Expanding.sum用法及代碼示例
- Python pyspark Expanding.mean用法及代碼示例
- Python pyspark create_map用法及代碼示例
- Python pyspark date_add用法及代碼示例
- Python pyspark DataFrame.to_latex用法及代碼示例
- Python pyspark DataStreamReader.schema用法及代碼示例
- Python pyspark MultiIndex.size用法及代碼示例
- Python pyspark arrays_overlap用法及代碼示例
- Python pyspark Series.asof用法及代碼示例
- Python pyspark DataFrame.align用法及代碼示例
- Python pyspark Index.is_monotonic_decreasing用法及代碼示例
- Python pyspark IsotonicRegression用法及代碼示例
- Python pyspark DataFrame.plot.bar用法及代碼示例
- Python pyspark DataFrame.to_delta用法及代碼示例
- Python pyspark element_at用法及代碼示例
- Python pyspark explode用法及代碼示例
- Python pyspark MultiIndex.hasnans用法及代碼示例
- Python pyspark Series.to_frame用法及代碼示例
- Python pyspark DataFrame.quantile用法及代碼示例
- Python pyspark Column.withField用法及代碼示例
- Python pyspark Index.values用法及代碼示例
- Python pyspark Index.drop_duplicates用法及代碼示例
注:本文由純淨天空篩選整理自spark.apache.org大神的英文原創作品 pyspark.ml.feature.ElementwiseProduct。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。