本文簡要介紹
pyspark.mllib.feature.StandardScaler
的用法。用法:
class pyspark.mllib.feature.StandardScaler(withMean=False, withStd=True)
通過使用訓練集中樣本的列匯總統計數據去除均值並縮放到單位方差來標準化特征。
版本 1.2.0 中的新函數。
- withMean:布爾型,可選
默認為假。在縮放之前以均值居中數據。它將構建一個密集的輸出,因此在應用於稀疏輸入時要小心。
- withStd:布爾型,可選
默認為真。將數據縮放到單位標準差。
參數:
例子:
>>> vs = [Vectors.dense([-2.0, 2.3, 0]), Vectors.dense([3.8, 0.0, 1.9])] >>> dataset = sc.parallelize(vs) >>> standardizer = StandardScaler(True, True) >>> model = standardizer.fit(dataset) >>> result = model.transform(dataset) >>> for r in result.collect(): r DenseVector([-0.7071, 0.7071, -0.7071]) DenseVector([0.7071, -0.7071, 0.7071]) >>> int(model.std[0]) 4 >>> int(model.mean[0]*10) 9 >>> model.withStd True >>> model.withMean True
相關用法
- Python pyspark StandardScaler用法及代碼示例
- Python pyspark Statistics.corr用法及代碼示例
- Python pyspark Statistics.kolmogorovSmirnovTest用法及代碼示例
- Python pyspark Statistics.colStats用法及代碼示例
- Python pyspark Statistics.chiSqTest用法及代碼示例
- Python pyspark StopWordsRemover用法及代碼示例
- Python pyspark StructType用法及代碼示例
- Python pyspark StreamingQueryManager.get用法及代碼示例
- Python pyspark StructField用法及代碼示例
- Python pyspark StringIndexer用法及代碼示例
- Python pyspark StreamingQueryManager.resetTerminated用法及代碼示例
- Python pyspark StreamingKMeansModel用法及代碼示例
- Python pyspark StructType.fieldNames用法及代碼示例
- Python pyspark StreamingQueryManager.active用法及代碼示例
- Python pyspark StructType.add用法及代碼示例
- Python pyspark StreamingQuery.explain用法及代碼示例
- Python pyspark Series.asof用法及代碼示例
- Python pyspark Series.to_frame用法及代碼示例
- Python pyspark Series.rsub用法及代碼示例
- Python pyspark Series.mod用法及代碼示例
- Python pyspark Series.str.join用法及代碼示例
- Python pyspark Series.str.startswith用法及代碼示例
- Python pyspark Series.dt.is_quarter_end用法及代碼示例
- Python pyspark Series.dropna用法及代碼示例
- Python pyspark Series.sub用法及代碼示例
注:本文由純淨天空篩選整理自spark.apache.org大神的英文原創作品 pyspark.mllib.feature.StandardScaler。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。