Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RandomSurvivalForest.apply raises AttributeError #290

Closed
Vincent-Maladiere opened this issue Aug 19, 2022 · 2 comments
Closed

RandomSurvivalForest.apply raises AttributeError #290

Vincent-Maladiere opened this issue Aug 19, 2022 · 2 comments

Comments

@Vincent-Maladiere
Copy link
Contributor

Describe the bug

The apply method inherited from scikit-learn is broken. After fitting, apply raises AttributeError since it is not implemented in the SurvivalTree class.

Code Sample to Reproduce the Bug

from sksurv.datasets import load_whas500
from sksurv.ensemble.forest import RandomSurvivalForest

X_sk, y_sk = load_whas500()
rf = RandomSurvivalForest()
rf.fit(X_sk, y_sk)
rf.apply(X_sk)

Expected Results
Same data-structure as returned by scikit-learn RF.

Actual Results

Traceback (most recent call last)
[/usr/local/lib/python3.7/dist-packages/sklearn/ensemble/_forest.py](https://localhost:8080/#) in <genexpr>(.0)
    251             verbose=self.verbose,
    252             **_joblib_parallel_args(prefer="threads"),
--> 253         )(delayed(tree.apply)(X, check_input=False) for tree in self.estimators_)
    254 
    255         return np.array(results).T
AttributeError: 'SurvivalTree' object has no attribute 'apply'

Versions
Please execute the following snippet and paste the output below.

System:
    python: 3.7.13 (default, Apr 24 2022, 01:04:09)  [GCC 7.5.0]
executable: /usr/bin/python3
   machine: Linux-5.4.188+-x86_64-with-Ubuntu-18.04-bionic

Python dependencies:
          pip: 21.1.3
   setuptools: 57.4.0
      sklearn: 1.0.2
        numpy: 1.21.6
        scipy: 1.7.3
       Cython: 0.29.32
       pandas: 1.3.5
   matplotlib: 3.2.2
       joblib: 1.1.0
threadpoolctl: 3.1.0

Built with OpenMP: True
sksurv: 0.17.2
cvxopt: 1.3.0
cvxpy: 1.2.1
numexpr: 2.8.3
osqp: 0.6.2
@Vincent-Maladiere
Copy link
Contributor Author

Would you prefer me to submit a PR to fix this or do it yourself?

@sebp
Copy link
Owner

sebp commented Aug 19, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants