google / yggdrasil-decision-forests

A library to train, evaluate, interpret, and productionize decision forest models such as Random Forest and Gradient Boosted Decision Trees.
https://ydf.readthedocs.io/
Apache License 2.0
498 stars 53 forks source link

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

Open alefbetac opened 14 hours ago

alefbetac commented 14 hours ago

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 commented 14 hours ago

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 commented 14 hours ago

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 commented 14 hours ago

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

alefbetac commented 14 hours ago

MacOs M2 (Arm)

rstz commented 14 hours ago

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

alefbetac commented 13 hours ago

0.8.0

rstz commented 12 hours ago

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.