Skip to content
Snippets Groups Projects
Commit 35d781e7 authored by MechCoder's avatar MechCoder Committed by Xiangrui Meng
Browse files

[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 <manojkumarsivaraj334@gmail.com>

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)
parent 3336c7b1
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment