kahramankostas / IoTDevIDv2

A Behavior-Based Device Identification Method for the IoT
MIT License
47 stars 14 forks source link

03. 2 Classification of Individual packets for Aalto Dataset.ipynb -AttributeError: 'NoneType' object has no attribute 'split' (KNN) #10

Open AhmedmostafaElabdli1 opened 6 months ago

AhmedmostafaElabdli1 commented 6 months ago

AttributeError Traceback (most recent call last) Cell In[31], line 13 11 outputcsv=dataset+str(sayac)+""+str(step)+"_"+str(mixed)+".csv" 12 target_names=target_name(test) ---> 13 ML(train,test,outputcsv,feature,step,mixed,dataset[2:-1]+""+str(step))

Cell In[29], line 67, in ML(loop1, loop2, output_csv, cols, step, mixed, dname) 65 train_time=(float((time.time()-second)) ) 66 second=time.time() ---> 67 predict =clf.predict(X_test) 68 test_time=(float((time.time()-second)) ) 69 if step==1: File ~.conda\envs\IoTDevIDv2_0\lib\site-packages\sklearn\neighbors_classification.py:237, in KNeighborsClassifier.predict(self, X) 235 neigh_dist = None 236 else: --> 237 neigh_dist, neighind = self.kneighbors(X) 239 classes = self.classes_ 240 _y = self._y

File ~.conda\envs\IoTDevIDv2_0\lib\site-packages\sklearn\neighbors_base.py:824, in KNeighborsMixin.kneighbors(self, X, n_neighbors, return_distance) 817 use_pairwise_distances_reductions = ( 818 self._fit_method == "brute" 819 and ArgKmin.is_usable_for( 820 X if X is not None else self._fit_X, self._fit_X, self.effectivemetric 821 ) 822 ) 823 if use_pairwise_distances_reductions: --> 824 results = ArgKmin.compute( 825 X=X, 826 Y=self._fit_X, 827 k=n_neighbors, 828 metric=self.effectivemetric, 829 metric_kwargs=self.effective_metricparams, 830 strategy="auto", 831 return_distance=return_distance, 832 ) 834 elif ( 835 self._fit_method == "brute" and self.metric == "precomputed" and issparse(X) 836 ): 837 results = _kneighbors_from_graph( 838 X, n_neighbors=n_neighbors, return_distance=return_distance 839 )

File ~.conda\envs\IoTDevIDv2_0\lib\site-packages\sklearn\metrics_pairwise_distances_reduction_dispatcher.py:277, in ArgKmin.compute(cls, X, Y, k, metric, chunk_size, metric_kwargs, strategy, return_distance) 196 """Compute the argkmin reduction. 197 198 Parameters (...) 274 returns. 275 """ 276 if X.dtype == Y.dtype == np.float64: --> 277 return ArgKmin64.compute( 278 X=X, 279 Y=Y, 280 k=k, 281 metric=metric, 282 chunk_size=chunk_size, 283 metric_kwargs=metric_kwargs, 284 strategy=strategy, 285 return_distance=return_distance, 286 ) 288 if X.dtype == Y.dtype == np.float32: 289 return ArgKmin32.compute( 290 X=X, 291 Y=Y, (...) 297 return_distance=return_distance, 298 )

File sklearn\metrics_pairwise_distances_reduction_argkmin.pyx:95, in sklearn.metrics._pairwise_distances_reduction._argkmin.ArgKmin64.compute()

File ~.conda\envs\IoTDevIDv2_0\lib\site-packages\sklearn\utils\fixes.py:139, in threadpool_limits(limits, user_api) 137 return controller.limit(limits=limits, user_api=user_api) 138 else: --> 139 return threadpoolctl.threadpool_limits(limits=limits, user_api=user_api) File ~.conda\envs\IoTDevIDv2_0\lib\site-packages\threadpoolctl.py:171, in threadpool_limits.init(self, limits, user_api) 167 def init(self, limits=None, user_api=None): 168 self._limits, self._user_api, self._prefixes = \ 169 self._check_params(limits, user_api) --> 171 self._original_info = self._set_threadpool_limits()

File ~.conda\envs\IoTDevIDv2_0\lib\site-packages\threadpoolctl.py:268, in threadpool_limits._set_threadpool_limits(self) 265 if self._limits is None: 266 return None --> 268 modules = _ThreadpoolInfo(prefixes=self._prefixes, 269 user_api=self._user_api) 270 for module in modules: 271 # self._limits is a dict {key: num_threads} where key is either 272 # a prefix or a user_api. If a module matches both, the limit 273 # corresponding to the prefix is chosed. 274 if module.prefix in self._limits:

File ~.conda\envs\IoTDevIDv2_0\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 ~.conda\envs\IoTDevIDv2_0\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 ~.conda\envs\IoTDevIDv2_0\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 ~.conda\envs\IoTDevIDv2_0\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 ~.conda\envs\IoTDevIDv2_0\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'

kahramankostas commented 5 months ago

please see sklearn dependencies:

import sklearn
print(sklearn.show_versions())

Maybe try to update the version of threadpoolctl to see whether the issue persists? I got it working without any problems. my output is below:

System:
    python: 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
executable: C:\Users\***\AppData\Local\Programs\Python\Python310\python.exe
   machine: Windows-10-10.0.22631-SP0

Python dependencies:
      sklearn: 1.4.1.post1
          pip: 24.0
   setuptools: 65.5.0
        numpy: 1.26.4
        scipy: 1.12.0
       Cython: 3.0.10
       pandas: 2.2.1
   matplotlib: 3.8.3
       joblib: 1.3.2
threadpoolctl: 3.4.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 20
         prefix: libopenblas
       filepath: C:\Users\***\AppData\Local\Programs\Python\Python310\Lib\site-packages\numpy.libs\libopenblas64__v0.3.23-293-gc2f4bdbb-gcc_10_3_0-2bde3a66a51006b2b53eb373ff767a3f.dll
        version: 0.3.23.dev
threading_layer: pthreads
   architecture: Haswell

       user_api: openmp
   internal_api: openmp
    num_threads: 20
         prefix: vcomp
       filepath: C:\Users\***\AppData\Local\Programs\Python\Python310\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None

       user_api: blas
   internal_api: openblas
    num_threads: 20
         prefix: libopenblas
       filepath: C:\Users\***\AppData\Local\Programs\Python\Python310\Lib\site-packages\scipy.libs\libopenblas_v0.3.20-571-g3dec11c6-gcc_10_3_0-c2315440d6b6cef5037bad648efc8c59.dll
        version: 0.3.21.dev
threading_layer: pthreads
   architecture: Haswell
None