diff options
-rw-r--r-- | mllib/src/main/scala/org/apache/spark/ml/feature/StandardScaler.scala | 6 | ||||
-rw-r--r-- | python/pyspark/ml/feature.py | 18 |
2 files changed, 24 insertions, 0 deletions
diff --git a/mllib/src/main/scala/org/apache/spark/ml/feature/StandardScaler.scala b/mllib/src/main/scala/org/apache/spark/ml/feature/StandardScaler.scala index ca3c1cfb56..72b545e5db 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/feature/StandardScaler.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/feature/StandardScaler.scala @@ -106,6 +106,12 @@ class StandardScalerModel private[ml] ( scaler: feature.StandardScalerModel) extends Model[StandardScalerModel] with StandardScalerParams { + /** Standard deviation of the StandardScalerModel */ + val std: Vector = scaler.std + + /** Mean of the StandardScalerModel */ + val mean: Vector = scaler.mean + /** @group setParam */ def setInputCol(value: String): this.type = set(inputCol, value) diff --git a/python/pyspark/ml/feature.py b/python/pyspark/ml/feature.py index 8804dace84..9bca7cc000 100644 --- a/python/pyspark/ml/feature.py +++ b/python/pyspark/ml/feature.py @@ -627,6 +627,10 @@ class StandardScaler(JavaEstimator, HasInputCol, HasOutputCol): >>> df = sqlContext.createDataFrame([(Vectors.dense([0.0]),), (Vectors.dense([2.0]),)], ["a"]) >>> standardScaler = StandardScaler(inputCol="a", outputCol="scaled") >>> model = standardScaler.fit(df) + >>> model.mean + DenseVector([1.0]) + >>> model.std + DenseVector([1.4142]) >>> model.transform(df).collect()[1].scaled DenseVector([1.4142]) """ @@ -692,6 +696,20 @@ class StandardScalerModel(JavaModel): Model fitted by StandardScaler. """ + @property + def std(self): + """ + Standard deviation of the StandardScalerModel. + """ + return self._call_java("std") + + @property + def mean(self): + """ + Mean of the StandardScalerModel. + """ + return self._call_java("mean") + @inherit_doc class StringIndexer(JavaEstimator, HasInputCol, HasOutputCol): |