# 将预测结果四舍五入取整 y_pred = y_pred.round() # 去除重复的行 y_pred_filtered = y_pred.drop_duplicates()raceback (most recent call last): File "D:\anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3460, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-10-b08427c8ccad>", line 58, in <module> y_pred_filtered = y_pred.drop_duplicates() AttributeError: 'numpy.ndarray' object has no attribute 'drop_duplicates'
时间: 2024-02-23 22:59:42 浏览: 82
ext4备份工具-ParagonPREDWinInstallDemox
根据报错信息,你正在尝试对一个numpy数组执行drop_duplicates()函数,但是该函数不适用于numpy数组,只适用于pandas数据框。你需要将y_pred转换为pandas数据框,然后再执行drop_duplicates()函数。可以使用以下代码将numpy数组转换为pandas数据框:
```
import pandas as pd
y_pred_df = pd.DataFrame(y_pred)
y_pred_filtered = y_pred_df.drop_duplicates()
```
阅读全文