本文整理匯總了Python中xgboost.sklearn.XGBClassifier.score方法的典型用法代碼示例。如果您正苦於以下問題:Python XGBClassifier.score方法的具體用法?Python XGBClassifier.score怎麽用?Python XGBClassifier.score使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xgboost.sklearn.XGBClassifier
的用法示例。
在下文中一共展示了XGBClassifier.score方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: RandomForestClassifier
# 需要導入模塊: from xgboost.sklearn import XGBClassifier [as 別名]
# 或者: from xgboost.sklearn.XGBClassifier import score [as 別名]
random_forest = RandomForestClassifier(random_state=1, n_estimators=45, min_samples_split=3, min_samples_leaf=2)
random_forest.fit(X, y)
score=random_forest.score(X, y)
Y_pred = random_forest.predict(X_test)
# In[14]:
#Classifier
xgb = XGBClassifier(max_depth=6, learning_rate=0.3, n_estimators=25,
objective='multi:softprob', subsample=0.5, colsample_bytree=0.5, seed=0)
xgb.fit(X, y)
score = xgb.score(X,y)
y_pred = xgb.predict_proba(X_test)
# In[15]:
print (score)
# In[21]:
# for Random forest
#Taking the 5 classes with highest probabilities