不,这与从
model
. 它与
cross_val_score
.
交叉评分
将根据
cv
帕拉姆。为此,它将执行以下操作:
for train, test in splitter.split(X_train, y_train):
new_X_train, new_y_train = X_train[train], y_train[train]
X_train
是一个
pandas.Series
对象,在该对象中基于索引的选择不是这样工作的。见此:
https://pandas.pydata.org/pandas-docs/stable/indexing.html#selection-by-position
更改此行:
X_train = data.apply(lambda r: simple_preprocess(r['text'], min_len=2), axis=1)
致:
# Access the internal numpy array
X_train = data.apply(lambda r: simple_preprocess(r['text'], min_len=2), axis=1).values
OR
# Convert series to list
X_train = data.apply(lambda r: simple_preprocess(r['text'], min_len=2), axis=1).tolist()