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

RandomForest issue with apply() when using Python interface. #5061

Closed
geektoni opened this issue Jun 8, 2020 · 5 comments
Closed

RandomForest issue with apply() when using Python interface. #5061

geektoni opened this issue Jun 8, 2020 · 5 comments
Labels

Comments

@geektoni
Copy link
Contributor

geektoni commented Jun 8, 2020

If we train a RandomForest object for a regression problem, the apply() method won't work as expected and it will throw the error below. If we use apply_regression() instead everything works perfectly.

Traceback (most recent call last):
  File "serialization.py", line 26, in <module>
    labels_predict = rand_forest.apply(features_test)
SystemError: Labels (RegressionLabels) are not compatible with multiclass.

Code to replicate the issue:

#!/usr/bin/env python
# coding: utf-8

import shogun as sg
import numpy as np

# Create random features
X_train = np.random.normal(0, 1, (100, 5))
betas = np.random.normal(0,1, 5)
y_train = np.dot(X_train, betas)

X_test = np.random.normal(0, 1, (10, 5))
y_test = np.dot(X_test, betas)

features_train = sg.create_features(X_train.T)
features_test = sg.create_features(X_test.T)
labels_train = sg.create_labels(y_train)
labels_test = sg.create_labels(y_test)

# Create the random forest object
mean_rule = sg.create_combination_rule("MeanRule")
rand_forest = sg.create_machine("RandomForest", labels=labels_train, num_bags=5,
                                seed=1, combination_rule=mean_rule)

rand_forest.train(features_train)
labels_predict = rand_forest.apply(features_test)
@gf712
Copy link
Member

gf712 commented Jun 8, 2020

Hmmm, this should be fixed once someone picks up on #5054

@stale
Copy link

stale bot commented Dec 5, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 5, 2020
@stale
Copy link

stale bot commented Dec 12, 2020

This issue is now being closed due to a lack of activity. Feel free to reopen it.

@stale stale bot closed this as completed Dec 12, 2020
@karlnapf karlnapf reopened this Dec 18, 2020
@stale stale bot removed the stale label Dec 18, 2020
@stale
Copy link

stale bot commented Jun 16, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 16, 2021
@stale
Copy link

stale bot commented Jun 23, 2021

This issue is now being closed due to a lack of activity. Feel free to reopen it.

@stale stale bot closed this as completed Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants