DummyTransformer
In [1]:
Copied!
# Example for dummy classifier
# Example for dummy classifier
In [2]:
Copied!
# IMPORTANT: import your project once
import project_name
# IMPORTANT: import your project once
import project_name
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) Cell In[2], line 2 1 # IMPORTANT: import your project once ----> 2 import project_name File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/project_name/__init__.py:3 1 import os 2 from datetime import datetime ----> 3 from photonai.base import PhotonRegistry 4 from photonai.photonlogger import logger 6 from .version import __version__ File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/photonai/__init__.py:17 1 """ 2 PHOTONAI 3 is a rapid prototyping framework enabling (not so experienced) users to build, train, optimize, evaluate, (...) 13 14 """ 15 from .version import __version__ ---> 17 from .base import Hyperpipe, OutputSettings, Stack, Switch, Branch, PipelineElement, ParallelBranch, \ 18 PhotonRegistry, DataFilter, CallbackElement, Preprocessing, ClassificationPipe, ClassifierSwitch, \ 19 RegressionPipe, RegressorSwitch 20 from .optimization import FloatRange, IntegerRange, Categorical, MinimumPerformanceConstraint, \ 21 BestPerformanceConstraint, DummyPerformanceConstraint, BooleanSwitch 22 from .base.json_transformer import JsonTransformer File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/photonai/base/__init__.py:3 1 """ PHOTON Base Classes enabling the nested-cross-validated hyperparameter search.""" ----> 3 from .hyperpipe import Hyperpipe, OutputSettings 4 from .photon_elements import Stack, Switch, Branch, DataFilter, CallbackElement, PhotonNative, Preprocessing, \ 5 PipelineElement, ParallelBranch 6 from .model_zoo import ClassificationPipe, ClassifierSwitch, RegressionPipe, RegressorSwitch File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/photonai/base/hyperpipe.py:21 19 from bson.objectid import ObjectId 20 from dask.distributed import Client ---> 21 from sklearn.base import BaseEstimator 22 from sklearn.dummy import DummyClassifier, DummyRegressor 23 import joblib File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/sklearn/__init__.py:83 69 # We are not importing the rest of scikit-learn during the build 70 # process, as it may not be compiled yet 71 else: (...) 77 # later is linked to the OpenMP runtime to make it possible to introspect 78 # it and importing it first would fail if the OpenMP dll cannot be found. 79 from . import ( 80 __check_build, # noqa: F401 81 _distributor_init, # noqa: F401 82 ) ---> 83 from .base import clone 84 from .utils._show_versions import show_versions 86 __all__ = [ 87 "calibration", 88 "cluster", (...) 129 "show_versions", 130 ] File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/sklearn/base.py:19 17 from ._config import config_context, get_config 18 from .exceptions import InconsistentVersionWarning ---> 19 from .utils import _IS_32BIT 20 from .utils._estimator_html_repr import estimator_html_repr 21 from .utils._metadata_requests import _MetadataRequester File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/sklearn/utils/__init__.py:22 20 from ._bunch import Bunch 21 from ._estimator_html_repr import estimator_html_repr ---> 22 from ._param_validation import Interval, validate_params 23 from .class_weight import compute_class_weight, compute_sample_weight 24 from .deprecation import deprecated File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/sklearn/utils/_param_validation.py:15 12 from scipy.sparse import csr_matrix, issparse 14 from .._config import config_context, get_config ---> 15 from .validation import _is_arraylike_not_scalar 18 class InvalidParameterError(ValueError, TypeError): 19 """Custom exception to be raised when the parameter of a class/method/function 20 does not have a valid type or value. 21 """ File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/sklearn/utils/validation.py:24 21 import scipy.sparse as sp 23 # mypy error: Module 'numpy.core.numeric' has no attribute 'ComplexWarning' ---> 24 from numpy.core.numeric import ComplexWarning # type: ignore 26 from .. import get_config as _get_config 27 from ..exceptions import DataConversionWarning, NotFittedError, PositiveSpectrumWarning ImportError: cannot import name 'ComplexWarning' from 'numpy.core.numeric' (/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/numpy/core/numeric.py)
In [3]:
Copied!
from photonai.base import Hyperpipe, PipelineElement
from sklearn.model_selection import KFold
from photonai.base import Hyperpipe, PipelineElement
from sklearn.model_selection import KFold
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) Cell In[3], line 1 ----> 1 from photonai.base import Hyperpipe, PipelineElement 2 from sklearn.model_selection import KFold File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/photonai/__init__.py:17 1 """ 2 PHOTONAI 3 is a rapid prototyping framework enabling (not so experienced) users to build, train, optimize, evaluate, (...) 13 14 """ 15 from .version import __version__ ---> 17 from .base import Hyperpipe, OutputSettings, Stack, Switch, Branch, PipelineElement, ParallelBranch, \ 18 PhotonRegistry, DataFilter, CallbackElement, Preprocessing, ClassificationPipe, ClassifierSwitch, \ 19 RegressionPipe, RegressorSwitch 20 from .optimization import FloatRange, IntegerRange, Categorical, MinimumPerformanceConstraint, \ 21 BestPerformanceConstraint, DummyPerformanceConstraint, BooleanSwitch 22 from .base.json_transformer import JsonTransformer File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/photonai/base/__init__.py:3 1 """ PHOTON Base Classes enabling the nested-cross-validated hyperparameter search.""" ----> 3 from .hyperpipe import Hyperpipe, OutputSettings 4 from .photon_elements import Stack, Switch, Branch, DataFilter, CallbackElement, PhotonNative, Preprocessing, \ 5 PipelineElement, ParallelBranch 6 from .model_zoo import ClassificationPipe, ClassifierSwitch, RegressionPipe, RegressorSwitch File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/photonai/base/hyperpipe.py:21 19 from bson.objectid import ObjectId 20 from dask.distributed import Client ---> 21 from sklearn.base import BaseEstimator 22 from sklearn.dummy import DummyClassifier, DummyRegressor 23 import joblib File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/sklearn/__init__.py:83 69 # We are not importing the rest of scikit-learn during the build 70 # process, as it may not be compiled yet 71 else: (...) 77 # later is linked to the OpenMP runtime to make it possible to introspect 78 # it and importing it first would fail if the OpenMP dll cannot be found. 79 from . import ( 80 __check_build, # noqa: F401 81 _distributor_init, # noqa: F401 82 ) ---> 83 from .base import clone 84 from .utils._show_versions import show_versions 86 __all__ = [ 87 "calibration", 88 "cluster", (...) 129 "show_versions", 130 ] File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/sklearn/base.py:19 17 from ._config import config_context, get_config 18 from .exceptions import InconsistentVersionWarning ---> 19 from .utils import _IS_32BIT 20 from .utils._estimator_html_repr import estimator_html_repr 21 from .utils._metadata_requests import _MetadataRequester File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/sklearn/utils/__init__.py:22 20 from ._bunch import Bunch 21 from ._estimator_html_repr import estimator_html_repr ---> 22 from ._param_validation import Interval, validate_params 23 from .class_weight import compute_class_weight, compute_sample_weight 24 from .deprecation import deprecated File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/sklearn/utils/_param_validation.py:15 12 from scipy.sparse import csr_matrix, issparse 14 from .._config import config_context, get_config ---> 15 from .validation import _is_arraylike_not_scalar 18 class InvalidParameterError(ValueError, TypeError): 19 """Custom exception to be raised when the parameter of a class/method/function 20 does not have a valid type or value. 21 """ File /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/sklearn/utils/validation.py:24 21 import scipy.sparse as sp 23 # mypy error: Module 'numpy.core.numeric' has no attribute 'ComplexWarning' ---> 24 from numpy.core.numeric import ComplexWarning # type: ignore 26 from .. import get_config as _get_config 27 from ..exceptions import DataConversionWarning, NotFittedError, PositiveSpectrumWarning ImportError: cannot import name 'ComplexWarning' from 'numpy.core.numeric' (/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/numpy/core/numeric.py)
Create dataset
In [4]:
Copied!
import numpy as np
X = np.random.rand(10, 10)
y = np.random.rand(10)
import numpy as np
X = np.random.rand(10, 10)
y = np.random.rand(10)
Setup pipeline
In [5]:
Copied!
my_pipe += PipelineElement("DummyTransformer", dummy_hp=3)
my_pipe += PipelineElement("DummyTransformer", dummy_hp=3)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[5], line 1 ----> 1 my_pipe += PipelineElement("DummyTransformer", dummy_hp=3) NameError: name 'my_pipe' is not defined
In [6]:
Copied!
my_pipe += PipelineElement("SVR")
my_pipe += PipelineElement("SVR")
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[6], line 1 ----> 1 my_pipe += PipelineElement("SVR") NameError: name 'my_pipe' is not defined
In [7]:
Copied!
my_pipe.fit(X, y)
my_pipe.fit(X, y)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[7], line 1 ----> 1 my_pipe.fit(X, y) NameError: name 'my_pipe' is not defined
Done