我正在尝试为我的ML项目导入名为lazypredict
的python包。LazyPredict是一个AutoML包
所以,我做了以下
import lazypredict
from lazypredict.Supervised import REGRESSORS
但是,当我执行第2行时出现了一个错误,完整的错误消息如下所示
如何避免这种情况并成功导入REGRASSORS模块?
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Input In [5], in <cell line: 22>()
20 from sklearn.ensemble import *
21 import lazypredict
---> 22 from lazypredict.Supervised import REGRESSORS
File ~\Anaconda3\lib\site-packages\lazypredict\Supervised.py:73, in <module>
36 removed_classifiers = [
37 "ClassifierChain",
38 "ComplementNB", (...)
50 "VotingClassifier",
51 ]
53 removed_regressors = [
54 "TheilSenRegressor",
55 "ARDRegression", (...)
68 "VotingRegressor",
69 ]
71 CLASSIFIERS = [
72 est
---> 73 for est in all_estimators()
74 if (issubclass(est[1], ClassifierMixin) and (est[0] not in removed_classifiers))
75 ]
77 REGRESSORS = [
78 est
79 for est in all_estimators()
80 if (issubclass(est[1], RegressorMixin) and (est[0] not in removed_regressors))
81 ]
83 REGRESSORS.append(("XGBRegressor", xgboost.XGBRegressor))
File ~\Anaconda3\lib\site-packages\sklearn\utils\__init__.py:1174, in all_estimators(type_filter) 1151 """Get a list of all estimators from sklearn. 1152 1153 This function crawls the module and gets all classes that inherit (...) 1171 and ``class`` is the actual type of the class. 1172 """ 1173 # lazy import to avoid circular imports from sklearn.base
-> 1174 from ._testing import ignore_warnings 1175 from ..base import ( 1176 BaseEstimator, 1177 ClassifierMixin, (...) 1180 ClusterMixin, 1181 ) 1183 def is_abstract(c):
File ~\Anaconda3\lib\site-packages\sklearn\utils\_testing.py:532, in <module>
527 skip_travis = pytest.mark.skipif(
528 os.environ.get("TRAVIS") == "true", reason="skip on travis"
529 )
530 fails_if_pypy = pytest.mark.xfail(IS_PYPY, reason="not compatible with PyPy")
531 fails_if_unstable_openblas = pytest.mark.xfail(
--> 532 _in_unstable_openblas_configuration(),
533 reason="OpenBLAS is unstable for this configuration",
534 )
535 skip_if_no_parallel = pytest.mark.skipif(
536 not joblib.parallel.mp, reason="joblib is in serial mode"
537 )
539 # Decorator for tests involving both BLAS calls and multiprocessing.
540 #
541 # Under POSIX (e.g. Linux or OSX), using multiprocessing in conjunction (...)
555 # errors on interactively defined functions. It therefore not enabled by
556 # default.
File ~\Anaconda3\lib\site-packages\sklearn\utils\__init__.py:93, in
_in_unstable_openblas_configuration()
90 import numpy # noqa
91 import scipy # noqa
---> 93 modules_info = threadpool_info()
95 open_blas_used = any(info["internal_api"] == "openblas" for info in modules_info)
96 if not open_blas_used:
File ~\Anaconda3\lib\site-packages\sklearn\utils\fixes.py:162, in threadpool_info()
160 return controller.info()
161 else:
--> 162 return threadpoolctl.threadpool_info()
File ~\Anaconda3\lib\site-packages\threadpoolctl.py:124, in threadpool_info()
107 @_format_docstring(USER_APIS=list(_ALL_USER_APIS),
108 INTERNAL_APIS=_ALL_INTERNAL_APIS)
109 def threadpool_info():
110 """Return the maximal number of threads for each detected library.
111
112 Return a list with all the supported modules that have been found. Each (...)
122 In addition, each module may contain internal_api specific entries.
123 """
--> 124 return _ThreadpoolInfo(user_api=_ALL_USER_APIS).todicts()
File ~\Anaconda3\lib\site-packages\threadpoolctl.py:340, in
_ThreadpoolInfo.__init__(self, user_api, prefixes, modules)
337 self.user_api = [] if user_api is None else user_api
339 self.modules = []
--> 340 self._load_modules()
341 self._warn_if_incompatible_openmp()
342 else:
File ~\Anaconda3\lib\site-packages\threadpoolctl.py:373, in
_ThreadpoolInfo._load_modules(self)
371 self._find_modules_with_dyld()
372 elif sys.platform == "win32":
--> 373 self._find_modules_with_enum_process_module_ex()
374 else:
375 self._find_modules_with_dl_iterate_phdr()
File ~\Anaconda3\lib\site-packages\threadpoolctl.py:485, in
_ThreadpoolInfo._find_modules_with_enum_process_module_ex(self)
482 filepath = buf.value
484 # Store the module if it is supported and selected
--> 485 self._make_module_from_path(filepath)
486 finally:
487 kernel_32.CloseHandle(h_process)
File ~\Anaconda3\lib\site-packages\threadpoolctl.py:515, in
_ThreadpoolInfo._make_module_from_path(self, filepath)
513 if prefix in self.prefixes or user_api in self.user_api:
514 module_class = globals()[module_class]
--> 515 module = module_class(filepath, prefix, user_api, internal_api)
516 self.modules.append(module)
File ~\Anaconda3\lib\site-packages\threadpoolctl.py:606, in
_Module.__init__(self, filepath, prefix, user_api, internal_api)
604 self.internal_api = internal_api
605 self._dynlib = ctypes.CDLL(filepath, mode=_RTLD_NOLOAD)
--> 606 self.version = self.get_version()
607 self.num_threads = self.get_num_threads()
608 self._get_extra_info()
File ~\Anaconda3\lib\site-packages\threadpoolctl.py:646, in
_OpenBLASModule.get_version(self)
643 get_config = getattr(self._dynlib, "openblas_get_config",
644 lambda: None)
645 get_config.restype = ctypes.c_char_p
--> 646 config = get_config().split()
647 if config[0] == b"OpenBLAS":
648 return config[1].decode("utf-8")
AttributeError: 'NoneType' object has no attribute 'split'
1条答案
按热度按时间68bkxrlz1#
有两个问题:(1)Windows 32位Python,(2)缺少
OpenBLAS
。以下是追溯的关键部分:
最简单的修复方法可能是安装Anaconda or Miniconda on Windows,安装
scipy
和numpy
,然后运行pip install lazypredict
: