pyspark 代码练习9 —— StandardScaler

from pyspark.ml.feature import StandardScaler
from pyspark.ml.linalg import Vectors
df3 = spark.createDataFrame([
    (Vectors.dense(10.2,), "a"),
    (Vectors.dense(1.6,), "b"),
    (Vectors.dense(23.6,), "c"),
    (Vectors.dense(35.7,), "e"),
    (Vectors.dense(4.8,), "e"),
    (Vectors.dense(50.8,), "e")
], ["amt", "value"])
scaler = StandardScaler(inputCol="amt", outputCol="scaledAmt", withStd=True, withMean=False)

scalerModel = scaler.fit(df3)

scaledData = scalerModel.transform(df3)
scaledData.show()
相关推荐
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页