title: How to get all parameters of estimator in PySpark
body: <p>I have a <code>RandomForestRegressor</code>, <code>GBTRegressor</code> and I'd like to get all parameters of them. The only way I found it could be done with several get methods like:</p>
  
  <pre><code>from pyspark.ml.regression import RandomForestRegressor, GBTRegressor
  est = RandomForestRegressor()
  est.getMaxDepth()
  est.getSeed()
  </code></pre>
  
  <p>But <code>RandomForestRegressor</code> and <code>GBTRegressor</code> have different parameters so it's not a good idea to hardcore all that methods.
  A workaround could be something like this:</p>
  
  <pre><code>get_methods = [method for method in dir(est) if method.startswith('get')]
  
  params_est = {}
  for method in get_methods:
      try:
          key = method[3:]
          params_est[key] = getattr(est, method)() 
      except TypeError:
          pass
  </code></pre>
  
  <p>Then output will be like this:</p>
  
  <pre><code>params_est
  
  {'CacheNodeIds': False,
   'CheckpointInterval': 10,
   'FeatureSubsetStrategy': 'auto',
   'FeaturesCol': 'features',
   'Impurity': 'variance',
   'LabelCol': 'label',
   'MaxBins': 32,
   'MaxDepth': 5,
   'MaxMemoryInMB': 256,
   'MinInfoGain': 0.0,
   'MinInstancesPerNode': 1,
   'NumTrees': 20,
   'PredictionCol': 'prediction',
   'Seed': None,
   'SubsamplingRate': 1.0}
  </code></pre>
  
  <p>But I think there should be a better way to do that.</p>