'numpy.ndarray' object has no attribute 'get'
时间: 2023-10-04 13:10:00 浏览: 242
numpy.meshgrid()理解(小结)
5星 · 资源好评率100%
发生AttributeError: 'numpy.ndarray' object has no attribute 'get'错误是因为numpy.ndarray对象没有get方法。通常情况下,get方法是用于从字典中获取值的,而不是从数组中获取值。在你提供的引用中,这个错误是由于在调用toarray()方法时出现的。该方法是将稀疏矩阵转换为稠密矩阵的方法,并不适用于numpy数组。解决这个问题的方法是将Xgroup_smote转换为稀疏矩阵,然后再使用toarray()方法将其转换为稠密矩阵。你可以按照引用中的修改代码进行操作。修改import scipy.sparse行并使用scipy.sparse.lil_matrix(Xgroup_smote).toarray()来替换Xgroup_smote = onehotencoder.fit_transform(Xgroup_smote).toarray()这一行。这样就可以避免'numpy.ndarray' object has no attribute 'get'错误的出现。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [AttributeError: ‘numpy.ndarray‘ object has no attribute ‘toarray](https://blog.csdn.net/weixin_54857966/article/details/128322179)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [‘numpy.ndarray‘ object has no attribute ‘get_support‘解决方案](https://blog.csdn.net/cairucxk/article/details/115864021)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文