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

ImportError: Module 'outputs/rules/rules' not found #55

Open
TrulsKarlsson opened this issue May 5, 2024 · 1 comment
Open

ImportError: Module 'outputs/rules/rules' not found #55

TrulsKarlsson opened this issue May 5, 2024 · 1 comment

Comments

@TrulsKarlsson
Copy link

I have chefboost==0.0.18 and perform the following code:

from chefboost import Chefboost as chef
config = {'algorithm': 'C4.5'}#, 'enableParallelism': False}
tmp_df = df[["distance", "Decision"]]
model = chef.fit(tmp_df, config)

and I get the following error message:

24-05-05 17:46:31 - [INFO]: 4 CPU cores will be allocated in parallel running
24-05-05 17:46:31 - C4.5 tree is going to be built...
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[23], line 1
----> 1 model = chef.fit(tmp_df, config)

File ~/Exjobb/BachelorThesis/env/lib/python3.11/site-packages/chefboost/Chefboost.py:275, in fit(df, config, target_label, validation_df, silent)
    272         json_file = "outputs/rules/rules.json"
    273         functions.createFile(json_file, "[\n")
--> 275     trees = Training.buildDecisionTree(
    276         df,
    277         root=root,
    278         file=file,
    279         config=config,
    280         dataset_features=dataset_features,
    281         parent_level=0,
    282         leaf_id=0,
    283         parents="root",
    284         validation_df=validation_df,
    285         main_process_id=process_id,
    286     )
    288 if silent is False:
    289     logger.info("-------------------------")

File ~/Exjobb/BachelorThesis/env/lib/python3.11/site-packages/chefboost/training/Training.py:711, in buildDecisionTree(df, root, file, config, dataset_features, parent_level, leaf_id, parents, tree_id, validation_df, main_process_id)
    703     if (
    704         config["enableRandomForest"] != True
    705         and config["enableGBM"] != True
    706         and config["enableAdaboost"] != True
    707     ):
    708         # this is reguler decision tree. find accuracy here.
    710         module_name = "outputs/rules/rules"
--> 711         myrules = load_module(module_name)  # rules0
    712         models.append(myrules)
    714 return models

File ~/Exjobb/BachelorThesis/env/lib/python3.11/site-packages/chefboost/commons/module.py:20, in load_module(module_name)
     18 spec = importlib.util.find_spec(module_name)
     19 if spec is None:
---> 20     raise ImportError(f"Module '{module_name}' not found")
     22 module = importlib.util.module_from_spec(spec)
     23 spec.loader.exec_module(module)

ImportError: Module 'outputs/rules/rules' not found

Anyone know how to fix!? Thanks in advance!

@sachinlodhi
Copy link

I found the temporary fix.
Go to chefboost/chefboost/commons/module.py
Change the following statement:
python if sys.version_info >= (3, 11):
to
python if sys.version_info >= (3, 12):

And it will work okay.
The key here is the importlib module does not work well.
So as a fallback, we should rely on the else block here.
So whatever your Python version is, you set the second parameter +1 to that of.
For instance, if your Python version is 3.11 then you set :
python if sys.version_info >= (3, 12):
and if your Python version is 3.10, then you set it as:
python if sys.version_info >= (3, 11):
And so on.
It is a temporary fix.
I will try to provide a permanent fix after my exams.

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