From 35d781e71b68eb6da7f49fdae40fa6c4f8e27060 Mon Sep 17 00:00:00 2001 From: MechCoder Date: Tue, 7 Jul 2015 12:35:40 -0700 Subject: [SPARK-8704] [ML] [PySpark] Add missing methods in StandardScaler Add std, mean to StandardScalerModel getVectors, findSynonyms to Word2Vec Model setFeatures and getFeatures to hashingTF Author: MechCoder Closes #7086 from MechCoder/missing_model_methods and squashes the following commits: 9fbae90 [MechCoder] Add type 6e3d6b2 [MechCoder] [SPARK-8704] Add missing methods in StandardScaler (ML and PySpark) --- python/pyspark/ml/feature.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'python/pyspark/ml/feature.py') 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): -- cgit v1.2.3