我有这个脚本来预测梯度提升算法。
app.post("/Login", passport.authenticate("local", {
successRedirect: "/User",
failureRedirect: "/Login",
failureFlash: true,
successFlash: true,
}));
我现在将如何手动测试此模型的新数组值的预测?假设我要预测[12,44,0]数组的结果。请告知。
答案 0 :(得分:0)
predict函数接受形状数组(n_samples,n_features)。我猜你是n_features=3
,因此:
print('Your prediction for [12,44,0] is', gb_clf.predict([[12,44,0]])
示例:
from sklearn.datasets import make_hastie_10_2
from sklearn.ensemble import GradientBoostingClassifier
X, y = make_hastie_10_2(random_state=0) # has 10 features
X_train, X_test = X[:2000], X[2000:]
y_train, y_test = y[:2000], y[2000:]
clf = GradientBoostingClassifier(n_estimators=100, learning_rate=1.0, max_depth=1, random_state=0).fit(X_train, y_train)
sample = [list(range(10))] # we provide 10 features for prediction
print('Prediction:', clf.predict(sample))