English 中文(简体)
Kmaeans 属性错误: NoneType 对象没有属性分割
原标题:KMeans Attribute Error: NoneType object has no attribute split
The KMeans code was working before but now it s not. The change I made was "pip install scikit-image" which I think changed numpy 1.18.5 to numpy 1.22.3 . But then I changed numpy back to 1.18.5 by doing -m pip install numpy==1.18.5 --user . And this didn t fix the issue. Any ideas what else it could be? Also, I don t remember why I had to install scikit-image (again?). Is there anyway to tell which module is incompatible with the KMeans code I m using? KMeans is from sklearn.cluster AttributeError Traceback (most recent call last) in ~DocumentsUCSDprojectInteractive FrameworkFramework_functions_modified.py in cluster_imgs(num_clusters) 110 kmodel = KMeans(n_clusters = k, random_state=728) 111 kmodel.fit(pred_images) #removed n_jobs=-1 b/c no longer kmeans feature (1/14/22) --> 112 kpredictions = kmodel.predict(pred_images) 113 shutil.rmtree(r"C:UsersUserDocumentsUCSDprojectInteractive FrameworkFramework_clustered_imgs") 114 ~anaconda3libsite-packagessklearncluster\_kmeans.py in predict(self, X, sample_weight) 1332 sample_weight = _check_sample_weight(sample_weight, X, dtype=X.dtype) 1333 -> 1334 return _labels_inertia_threadpool_limit( 1335 X, sample_weight, x_squared_norms, self.cluster_centers_, self._n_threads 1336 )[0] ~anaconda3libsite-packagessklearncluster\_kmeans.py in _labels_inertia_threadpool_limit(X, sample_weight, x_squared_norms, centers, n_threads) 753 ): 754 """Same as _labels_inertia but in a threadpool_limits context.""" --> 755 with threadpool_limits(limits=1, user_api="blas"): 756 labels, inertia = _labels_inertia( 757 X, sample_weight, x_squared_norms, centers, n_threads ~anaconda3libsite-packagessklearnutilsfixes.py in threadpool_limits(limits, user_api) 312 return controller.limit(limits=limits, user_api=user_api) 313 else: --> 314 return threadpoolctl.threadpool_limits(limits=limits, user_api=user_api) 315 316 ~anaconda3libsite-packages hreadpoolctl.py in __init__(self, limits, user_api) 169 self._check_params(limits, user_api) 170 --> 171 self._original_info = self._set_threadpool_limits() 172 173 def __enter__(self): ~anaconda3libsite-packages hreadpoolctl.py in _set_threadpool_limits(self) 266 return None 267 --> 268 modules = _ThreadpoolInfo(prefixes=self._prefixes, 269 user_api=self._user_api) 270 for module in modules: ~anaconda3libsite-packages hreadpoolctl.py in __init__(self, user_api, prefixes, modules) 338 339 self.modules = [] --> 340 self._load_modules() 341 self._warn_if_incompatible_openmp() 342 else: ~anaconda3libsite-packages hreadpoolctl.py in _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() ~anaconda3libsite-packages hreadpoolctl.py in _find_modules_with_enum_process_module_ex(self) 483 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) ~anaconda3libsite-packages hreadpoolctl.py in _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) 517 ~anaconda3libsite-packages hreadpoolctl.py in __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() ~anaconda3libsite-packages hreadpoolctl.py in get_version(self) 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
问题回答
upgrading this: pip install -U threadpoolctl solved the prb for me.
seems like fixed an issue by importing a specific version of numpy import numpy numpy.__version__ 1.21.4 make sure, you not importing import numpy as np afterwards




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签