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

module 'ydf' has no attribute 'RandomForestLearner' #148

Open
alefbetac opened this issue Nov 18, 2024 · 7 comments
Open

module 'ydf' has no attribute 'RandomForestLearner' #148

alefbetac opened this issue Nov 18, 2024 · 7 comments

Comments

@alefbetac
Copy link

I'm just going through the tutorial and this is not working for me:

pip install ydf -U

# Load libraries
import ydf  # Yggdrasil Decision Forests
import pandas as pd  # We use Pandas to load small datasets

# Download a classification dataset and load it as a Pandas DataFrame.
ds_path = "https://raw.githubusercontent.com/google/yggdrasil-decision-forests/main/yggdrasil_decision_forests/test_data/dataset"
train_ds = pd.read_csv(f"{ds_path}/adult_train.csv")
test_ds = pd.read_csv(f"{ds_path}/adult_test.csv")

train_ds["income"]

model = ydf.RandomForestLearner(label="income",
                                task=ydf.Task.CLASSIFICATION).train(train_ds)
# Note: ydf.Task.CLASSIFICATION is the default value of "task"

assert model.task() == ydf.Task.CLASSIFICATION

I get error:

Traceback (most recent call last):
  File "...", line 12, in <module>
    model = ydf.RandomForestLearner(label="income",
AttributeError: module 'ydf' has no attribute 'RandomForestLearner'

Sorry if I am missing something obvious here.

@rstz
Copy link
Collaborator

rstz commented Nov 18, 2024

That is unusual. Could it be that you're running on some system we're not supporting and the ydf version you have is 0.0.0 ?

@alefbetac
Copy link
Author

Ah I see now that the supported python versions are

Python 3.8, 3.9, 3.11 and 3.12

And I am on Python 3.10.13, could it be that?

@rstz
Copy link
Collaborator

rstz commented Nov 18, 2024

No, 3.10 is supported (that's a documentation error). Are you running Windows, MacOs or Linux?

@alefbetac
Copy link
Author

MacOs M2 (Arm)

@rstz
Copy link
Collaborator

rstz commented Nov 18, 2024

Can you also tell me the ydf version (available via pip list)

@alefbetac
Copy link
Author

0.8.0

copybara-service bot pushed a commit that referenced this issue Nov 18, 2024
PiperOrigin-RevId: 697569851
@rstz
Copy link
Collaborator

rstz commented Nov 18, 2024

I couldn't find a way to reproduce this on a similar machine. Best advice I can give, right now, is probably to retry everything in a fresh virtual environment.

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

No branches or pull requests

2 participants