Я пытаюсь создать конвейер, но получаю сообщение об ошибке
Есть предложения? Оба моих входных столбца являются категориальными, а выходные данные также являются категориями.
Код
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.linear_model import LogisticRegression
from sklearn.impute import SimpleImputer
target = dataframe.final
features = dataframe[['A', 'B']].copy()
X_train1, X_test1, y_train1, y_test1 = train_test_split(features, target,test_size=0.2,
random_state=42)
numerical_features = features.dtypes == 'float'
categorical_features = ~numerical_features
preprocess = make_column_transformer(
(numerical_features, make_pipeline(SimpleImputer(), StandardScaler())),
(categorical_features, OneHotEncoder()))
model = make_pipeline(
preprocess,
LogisticRegression())
model.fit(X_train1, y_train1)
Ошибка:
ValueError Traceback (most recent call last)
<ipython-input-53-e1960c314217> in <module>
14 preprocess,
15 LogisticRegression())
---> 16 model.fit(X_train1, y_train1)
17 print("logistic regression score: %f" % model.score(X_test1, y_test1))
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().