python - 无法比较类型 'ndarray(dtype=object)' 和 'Interval'
问题描述
我正在为我的代码使用这个包'from xverse.ensemble import VotingSelector'。
当我尝试运行 VotingSelector() 时,我的输出屏幕上刚刚弹出一条错误消息,警告无法进行比较。
这很奇怪,因为我已经满足了使用包的所有要求,特别是处理分类特征的编码器代码和用零替换 NaN 的 '.fillna'。
这是我的代码和我所做的:
# Encoder
cat_encoder = ce.CatBoostEncoder(handle_missing='value', handle_unknown='value')
# .fit_tranform for Training dataset
X_train_selection = cat_encoder.fit_transform(X_train.drop(['id','date_reference'],axis=1).copy(),y_train.copy())
# .fit_tranform for Testing dataset
X_test_selection = cat_encoder.transform(X_test.drop(['id', 'date_reference'], axis=1).copy())
# a sample to run faster the code
sample_index = X_train_selection.sample(10000, random_state=1).index
# .fit
clf = VotingSelector()
X = X_train_selection.loc[sample_index].fillna(0)
y = y_train.loc[sample_index].fillna(0)
clf.fit(X,y)
打印时显示:
TypeError: Cannot compare types 'ndarray(dtype=object)' and 'Interval'
解决方案
推荐阅读
- unity3d - Unity 自定义:NullReferenceExpectation
- c - 是否可以检测到有人正在使用我的窗口的 hwnd 或 dc
- ios - 如何将安全区域添加到视图高度?
- kubernetes - OpenSSL SSL_read: Connection was aborted, errno 10053 (implementing mTLS using istio)
- python - 如何在 Python Pandas DataFrame 中跨父组为所有孩子查找重复项?
- c# - 2D 坡度异常 C#
- javascript - 尝试使用 JavaScript 分而治之查找数组的总和,但输出未定义
- flutter - 流式传输 Firestore 集合的实际大小限制是多少(在 Flutter 中)
- php - 我如何以编程方式确定 Github 目录页面中所有当前存在的目录?
- phpstorm - CentOS 7 vsftpd 不断拒绝 PhpStorm FTP 连接