首页 > 解决方案 > 无法比较类型 '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'

标签: python

解决方案


推荐阅读