You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/10/09 01:39:37 UTC

[GitHub] [spark] zhengruifeng commented on issue #26038: [SPARK-29235][ML][Pyspark]Support avgMetrics in read/write of CrossValidatorModel

zhengruifeng commented on issue #26038: [SPARK-29235][ML][Pyspark]Support avgMetrics in read/write of CrossValidatorModel
URL: https://github.com/apache/spark/pull/26038#issuecomment-539780549
 
 
   ```
   In [1]: from pyspark.ml.classification import LogisticRegression
   
   In [2]: from pyspark.ml.evaluation import BinaryClassificationEvaluator
   
   In [3]: from pyspark.ml.linalg import Vectors
   
   In [4]: dataset = spark.createDataFrame(
      ...:     ...     [(Vectors.dense([0.0]), 0.0),
      ...:     ...      (Vectors.dense([0.4]), 1.0),
      ...:     ...      (Vectors.dense([0.5]), 0.0),
      ...:     ...      (Vectors.dense([0.6]), 1.0),
      ...:     ...      (Vectors.dense([1.0]), 1.0)] * 10,
      ...:     ...     ["features", "label"]).repartition(1)
   ---------------------------------------------------------------------------
   TypeError                                 Traceback (most recent call last)
   <ipython-input-4-47bd70df4aa7> in <module>()
         1 dataset = spark.createDataFrame(
         2     ...     [(Vectors.dense([0.0]), 0.0),
   ----> 3     ...      (Vectors.dense([0.4]), 1.0),
         4     ...      (Vectors.dense([0.5]), 0.0),
         5     ...      (Vectors.dense([0.6]), 1.0),
   
   TypeError: 'ellipsis' object is not callable
   
   In [5]: dataset = spark.createDataFrame([(Vectors.dense([0.0]), 0.0),(Vectors.dense([0.4]), 1.0),(Vectors.dense([0.5]), 0.0),(Vectors.dense([0.6]), 1.0),(Vectors.dense([1.0]), 1.0)] * 10,["features", "label
      ...: "]).repartition(1)
   
   In [6]: lr = LogisticRegression()
   
   In [7]: grid = ParamGridBuilder().addGrid(lr.maxIter, [0, 1]).build()
   ---------------------------------------------------------------------------
   NameError                                 Traceback (most recent call last)
   <ipython-input-7-045a988cd0ea> in <module>()
   ----> 1 grid = ParamGridBuilder().addGrid(lr.maxIter, [0, 1]).build()
   
   NameError: name 'ParamGridBuilder' is not defined
   
   In [8]: from pyspark.ml.tuning import *
   
   In [9]: grid = ParamGridBuilder().addGrid(lr.maxIter, [0, 1]).build()
   
   In [10]: evaluator = BinaryClassificationEvaluator()
   
   In [11]: tvs = TrainValidationSplit(estimator=lr, estimatorParamMaps=grid, evaluator=evaluator, parallelism=1, seed=42)
   
   In [12]: tvsModel = tvs.fit(dataset)
   19/10/09 09:36:51 WARN BLAS: Failed to load implementation from: com.github.fommil.netlib.NativeSystemBLAS
   19/10/09 09:36:51 WARN BLAS: Failed to load implementation from: com.github.fommil.netlib.NativeRefBLAS
   
   In [13]: tvsModel.save("/tmp/model")
   
   In [14]: tvsModel2 = TrainValidationSplitModel.load("/tmp/model")
   
   In [15]: tvsModel.validationMetrics
   Out[15]: [0.5, 0.8857142857142857]
   
   In [16]: tvsModel2.validationMetrics
   Out[16]: []
   ```
   
   @shahidki31 Same issue also exist in `TrainValidationSplitModel`, can you also fix it in this pr?
   BTW, what about adding doctests for model savle/load? (also check the loaded metrics)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org