How to get best params after tuning by pyspark.ml.tuning.TrainValidationSplit?

前端 未结 1 709
不思量自难忘°
不思量自难忘° 2021-01-14 09:22

I\'m trying to tune the hyper-parameters of a Spark (PySpark) ALS model by TrainValidationSplit.

It works well, but I want to know which co

相关标签:
1条回答
  • 2021-01-14 09:48

    You can access best model using bestModel property of the TrainValidationSplitModel:

    best_model = model.bestModel
    

    Rank can be accessed directly using rank property of the ALSModel:

    best_model.rank
    
    10
    

    Getting maximum number of iterations requires a bit more trickery:

    (best_model
        ._java_obj     # Get Java object
        .parent()      # Get parent (ALS estimator)
        .getMaxIter()) # Get maxIter
    
    10
    
    0 讨论(0)
提交回复
热议问题