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

Demonstration code results in an error (2) #189

Open
Checkpoint-89 opened this issue Dec 17, 2024 · 1 comment
Open

Demonstration code results in an error (2) #189

Checkpoint-89 opened this issue Dec 17, 2024 · 1 comment

Comments

@Checkpoint-89
Copy link

I have used the demo_pipeline without problem and now face this bug.

Description of the bug: the following code results in an error

from melusine.data import load_email_data
from melusine.pipeline import MelusinePipeline

# Load an email dataset
df = load_email_data()

# Load a pipeline
pipeline = MelusinePipeline.from_config("demo_pipeline")  

# Run the pipeline
df = pipeline.transform(df)

Same as in the demonstration code here.

Error :

TypeError                                 Traceback (most recent call last)
Cell In[1], [line 11](vscode-notebook-cell:?execution_count=1&line=11)
      [8](vscode-notebook-cell:?execution_count=1&line=8) pipeline = MelusinePipeline.from_config("demo_pipeline")  
     [10](vscode-notebook-cell:?execution_count=1&line=10) # Run the pipeline
---> [11](vscode-notebook-cell:?execution_count=1&line=11) df = pipeline.transform(df)

File d:\Users\cdiet\Program\miniconda3\envs\test_env\lib\site-packages\melusine\pipeline.py:403, in MelusinePipeline.transform(self, X)
    [389](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/melusine/pipeline.py:389) """
    [390](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/melusine/pipeline.py:390) Transform input dataset.
    [391](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/melusine/pipeline.py:391) 
   (...)
    [400](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/melusine/pipeline.py:400)     Output Dataset.
    [401](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/melusine/pipeline.py:401) """
    [402](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/melusine/pipeline.py:402) self.validate_input_fields(X)
--> [403](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/melusine/pipeline.py:403) return super().transform(X)

File d:\Users\cdiet\Program\miniconda3\envs\test_env\lib\site-packages\sklearn\pipeline.py:1082, in Pipeline.transform(self, X, **params)
   [1050](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1050) """Transform the data, and apply `transform` with the final estimator.
   [1051](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1051) 
   [1052](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1052) Call `transform` of each transformer in the pipeline. The transformed
   (...)
   [1079](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1079)     Transformed data.
   [1080](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1080) """
   [1081](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1081) # TODO(1.8): Remove the context manager and use check_is_fitted(self)
-> [1082](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1082) with _raise_or_warn_if_not_fitted(self):
   [1083](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1083)     _raise_for_params(params, self, "transform")
   [1085](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1085)     # not branching here since params is only available if
   [1086](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1086)     # enable_metadata_routing=True

File d:\Users\cdiet\Program\miniconda3\envs\test_env\lib\contextlib.py:142, in _GeneratorContextManager.__exit__(self, typ, value, traceback)
    [140](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/contextlib.py:140) if typ is None:
    [141](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/contextlib.py:141)     try:
--> [142](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/contextlib.py:142)         next(self.gen)
    [143](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/contextlib.py:143)     except StopIteration:
    [144](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/contextlib.py:144)         return False

File d:\Users\cdiet\Program\miniconda3\envs\test_env\lib\site-packages\sklearn\pipeline.py:60, in _raise_or_warn_if_not_fitted(estimator)
     [58](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:58) # we only get here if the above didn't raise
     [59](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:59) try:
---> [60](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:60)     check_is_fitted(estimator)
     [61](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:61) except NotFittedError:
     [62](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:62)     warnings.warn(
     [63](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:63)         "This Pipeline instance is not fitted yet. Call 'fit' with "
     [64](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:64)         "appropriate arguments before using other methods such as transform, "
   (...)
     [67](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:67)         FutureWarning,
     [68](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:68)     )

File d:\Users\cdiet\Program\miniconda3\envs\test_env\lib\site-packages\sklearn\utils\validation.py:1756, in check_is_fitted(estimator, attributes, msg, all_or_any)
   [1753](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1753) if not tags.requires_fit and attributes is None:
   [1754](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1754)     return
-> [1756](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1756) if not _is_fitted(estimator, attributes, all_or_any):
   [1757](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1757)     raise NotFittedError(msg % {"name": type(estimator).__name__})

File d:\Users\cdiet\Program\miniconda3\envs\test_env\lib\site-packages\sklearn\utils\validation.py:1665, in _is_fitted(estimator, attributes, all_or_any)
   [1662](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1662)     return all_or_any([hasattr(estimator, attr) for attr in attributes])
   [1664](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1664) if hasattr(estimator, "__sklearn_is_fitted__"):
-> [1665](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1665)     return estimator.__sklearn_is_fitted__()
   [1667](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1667) fitted_attrs = [
   [1668](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1668)     v for v in vars(estimator) if v.endswith("_") and not v.startswith("__")
   [1669](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1669) ]
   [1670](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1670) return len(fitted_attrs) > 0

File d:\Users\cdiet\Program\miniconda3\envs\test_env\lib\site-packages\sklearn\pipeline.py:1310, in Pipeline.__sklearn_is_fitted__(self)
   [1303](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1303)     return True
   [1305](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1305) try:
   [1306](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1306)     # check if the last step of the pipeline is fitted
   [1307](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1307)     # we only check the last step since if the last step is fit, it
   [1308](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1308)     # means the previous steps should also be fit. This is faster than
   [1309](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1309)     # checking if every step of the pipeline is fit.
-> [1310](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1310)     check_is_fitted(last_step)
   [1311](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1311)     return True
   [1312](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/pipeline.py:1312) except NotFittedError:

File d:\Users\cdiet\Program\miniconda3\envs\test_env\lib\site-packages\sklearn\utils\validation.py:1749, in check_is_fitted(estimator, attributes, msg, all_or_any)
   [1743](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1743)     msg = (
   [1744](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1744)         "This %(name)s instance is not fitted yet. Call 'fit' with "
   [1745](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1745)         "appropriate arguments before using this estimator."
   [1746](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1746)     )
   [1748](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1748) if not hasattr(estimator, "fit"):
-> [1749](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1749)     raise TypeError("%s is not an estimator instance." % (estimator))
   [1751](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1751) tags = get_tags(estimator)
   [1753](file:///D:/Users/cdiet/Program/miniconda3/envs/test_env/lib/site-packages/sklearn/utils/validation.py:1753) if not tags.requires_fit and attributes is None:

TypeError: EmergencyDetector(name='emergency') is not an estimator instance.

Debug Information

Please write the debug information inside ``` quotes in order to prevent text interpretation by the text editor.

Operating System: (run cat /etc/os-release in a terminal if running on a GNU/Linux distribution)

Microsoft Windows [Version 10.0.22631.4460]

Python version: (run python --version in the environment running Melusine)

Python 3.10.16

Melusine version: (run pip freeze |grep melusine in your Python environment)

melusine                  3.1.0                    pypi_0    pypi

Python packages: (run pip freeze in your Python environment)
Simple environment set-up built with conda create -n test_env python=3.10 and pip install melusine, nothing else.

antlr4-python3-runtime==4.9.3
arrow==1.3.0
asttokens @ file:///home/conda/feedstock_root/build_artifacts/asttokens_1733250440834/work
colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1733218098505/work
comm @ file:///home/conda/feedstock_root/build_artifacts/comm_1733502965406/work
debugpy @ file:///D:/bld/debugpy_1734158974603/work
decorator @ file:///home/conda/feedstock_root/build_artifacts/decorator_1733236420667/work 
exceptiongroup @ file:///home/conda/feedstock_root/build_artifacts/exceptiongroup_1733208806608/work
executing @ file:///home/conda/feedstock_root/build_artifacts/executing_1733569351617/work 
importlib_metadata @ file:///home/conda/feedstock_root/build_artifacts/importlib-metadata_1733223117029/work
ipykernel @ file:///D:/bld/ipykernel_1719845595208/work
ipython @ file:///D:/bld/ipython_1732896960890/work
jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1733300866624/work
joblib==1.4.2
jupyter_client @ file:///home/conda/feedstock_root/build_artifacts/jupyter_client_1733440914442/work
jupyter_core @ file:///D:/bld/jupyter_core_1727163532151/work
matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1733416936468/work
melusine==3.1.0
nest_asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1733325553580/work
numpy==2.2.0
omegaconf==2.3.0
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1733203243479/work 
pandas==2.2.3
parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1733271261340/work
pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1733327343728/work
platformdirs @ file:///home/conda/feedstock_root/build_artifacts/platformdirs_1733232627818/work
prompt_toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1733302527033/work
psutil @ file:///D:/bld/psutil_1729847160832/work
pure_eval @ file:///home/conda/feedstock_root/build_artifacts/pure_eval_1733569405015/work 
Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1733221634316/work   
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1733215673016/work
pytz==2024.2
pywin32==307
PyYAML==6.0.2
pyzmq @ file:///D:/bld/pyzmq_1728642398422/work
scikit-learn==1.6.0
scipy==1.14.1
six @ file:///home/conda/feedstock_root/build_artifacts/six_1733380938961/work
stack_data @ file:///home/conda/feedstock_root/build_artifacts/stack_data_1733569443808/work
threadpoolctl==3.5.0
tornado @ file:///D:/bld/tornado_1732615925919/work
tqdm==4.67.1
traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1733367359838/work 
types-python-dateutil==2.9.0.20241206
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1733188668063/work
tzdata==2024.2
wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1733231326287/work     
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1732827521216/work
@Checkpoint-89
Copy link
Author

Observation: Rolling back to Scikit-learn version 1.5.2 resolves the issue, and the code runs as expected.
Root Cause: It appears that Melusine has a compatibility issue with Scikit-learn 1.6.0.
Behavior: When running pip install melusine, the latest version of Scikit-learn (1.6.0) is installed automatically, causing the issue.

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

1 participant