uber / uber/causalml

Error to import causal forest regressor

Open
#1,048 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
6k
Forks
877
PR merge metrics
No merged PRs in 30d

Description

Hi! I am trying to import the causal forest regressor as below but it throws an error. Also tried the second script which seems the right path but still shows errors. Can you help? @jeongyoonlee
from causalml.inference.tree import CausalRandomForestRegressor
from causalml.inference.tree.causal.causalforest import CausalRandomForestRegressor


ImportError Traceback (most recent call last)
/tmp/ipykernel_43828/4294848391.py in <cell line: 0>()
----> 1 from causalml.inference.tree import CausalRandomForestRegressor

4 frames
/content/causalml/causalml/inference/tree/_tree/_classes.py in
43 validate_data,
44 )
---> 45 from . import _criterion, _splitter, _tree
46 from ._criterion import Criterion
47 from ._splitter import Splitter

ImportError: cannot import name '_criterion' from partially initialized module 'causalml.inference.tree._tree' (most likely due to a circular import) (/content/causalml/causalml/inference/tree/_tree/init.py)


NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failing imports from causalml.inference.tree and causalml.inference.tree.causal.causalforest in the reported notebook environment. Then inspect causalml/inference/tree/_tree/_classes.py and its imports of _criterion, _splitter, and _tree. Done means the documented CausalRandomForestRegressor import succeeds without the partial-initialization error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.