AttributeError: 'RandomUnderSampler' object has no attribute 'fit_sample'
时间: 2023-08-18 14:09:46 浏览: 308
报错信息中显示:AttributeError: 'RandomUnderSampler' object has no attribute 'fit_sample'。这是因为在最新版本的imblearn库中,fit_sample方法已被fit_resample方法取代。所以,需要将fit_sample方法替换为fit_resample方法。
解决办法是将代码中的fit_sample替换为fit_resample,即将ros.fit_sample(features,label)替换为ros.fit_resample(features,label)。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [AttributeError: ‘RandomOverSampler‘ object has no attribute ‘fit_sample](https://blog.csdn.net/weixin_41194171/article/details/124271384)[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^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [AttributeError: ‘RandomUnderSampler‘ object has no attribute ‘fit_sample](https://blog.csdn.net/qq_42008588/article/details/116461429)[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^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文