Github user BryanCutler commented on the issue:

    https://github.com/apache/spark/pull/18120
  
    Thanks @facaiy for the PR.  This might be enough to simply retrieve the 
value from the Java model, but I think the Python model also needs to "own" the 
param.  For example, if we have a `DecisionTreeRegressor` called `dt` and a 
`DecisionTreeRegressionModel` called `model` then
    ```
    In [8]: dt.hasParam("maxDepth")
    Out[8]: True
    
    In [9]: model.hasParam("maxDepth")
    Out[9]: False
    ```
    This is because the Python object does not have an instance of the param, 
its only getting a value from the Java model.  Additionally, many of the 
methods you would expect to work from class `Params` would raise an error like
    ```
    In [4]: dt.explainParam("maxDepth")
    Out[4]: 'maxDepth: Maximum depth of the tree. (>= 0) E.g., depth 0 means 1 
leaf node; depth 1 means 1 internal node + 2 leaf nodes. (default: 5, current: 
2)
    
    In [5]: model.explainParam("maxDepth")
    ...
    AttributeError: 'DecisionTreeRegressionModel' object has no attribute 
'maxDepth'
    ```
    
    As @sethah pointed out #17849 has the fix so that the Python models would 
have an instance of each param, so that should go in first.  Then, the accessor 
could be written like this:
    ```
    def getMaxDepth(self):
        return self.getOrDefault(self.maxDepth)
    ```
    I'm not sure what the best approach for adding these accessors, all at once 
or one by one as needed, like with `maxDepth`?  
    
    cc @holdenk @jkbradley for your input


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to