我尝试使用决策树分类器制作梯度提升 ML 模型。 训练时,出现此错误。但是我使用二进制(0 和 1)数据作为输出列。
这是我的代码部分
from sklearn import utils
# Generate a synthetic dataset
X, y = make_classification(n_samples=1000, n_features=10, n_informative=5, random_state=42)
# Split the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
print(y_train)
print(utils.multiclass.type_of_target(y_train))
# Train the Gradient Boosting algorithm
clf = GradientBoostingClassifier()
clf.fit(X_train, y_train)
# Make predictions on the testing set and evaluate the accuracy
y_pred = clf.predict(X_test)
accuracy = accuracy_score(y_test, y_pred)