[英]difference between DictionaryLearning and MiniBatchDictionaryLearning in scikit-learn
[英]Difference between scikit-learn and caret GBM results?
在scikit-learn和caret的相同輸入數據下,我得到的F1分數大為不同。 這是我為每個模型運行GBM模型的方式。
scikit-learn(默認輸出為F1)
est = GradientBoostingClassifier(n_estimators = 4000, learning_rate = 0.1, max_depth = 5, max_features = 'log2', random_state = 0)
cv = StratifiedKFold(y = labels, n_folds = 10, shuffle = True, random_state = 0)
scores = cross_val_score(est, data, labels, scoring = 'f1', cv, n_jobs = -1)
脫字號(必須定義並調用F1):
f1 <- function(data, lev = NULL, model = NULL) {
f1_val <- F1_Score(y_pred = data$pred, y_true = data$obs, positive = lev[1])
c("F1" = f1_val)
}
set.seed(0)
gbm <- train(label ~ .,
data = data,
method = "gbm",
trControl = trainControl(method = "repeatedcv", number = 10, repeats = 3,
summaryFunction = f1, classProbs = TRUE),
metric = "F1",
verbose = FALSE)
從上面的代碼中,我使用scikit-learn得到的F1得分約為0.8,而使用插入符號得到的F1得分約為0.25。 小差異可能歸因於算法差異,但是我必須對插入符號建模做一些錯誤處理才能獲得我在這里看到的巨大差異。 我不希望發布數據集,因此希望可以從代碼中診斷出該問題。 任何幫助將非常感激。
GBT是決策樹的集合。 區別來自:
n_estimators = 4000
與n.trees = 100
)。 max_depth = 5
與interaction.depth = 1
)。 當前,您正在將100 MB的 GradientBoostingClassifier
對象的F1得分與100 kB的 gbm
對象進行比較-一種GBT模型包含的信息實際上比另一種模型多出數千倍。
您可能希望使用sklearn2pmml和r2pmml軟件包將兩個模型導出為標准化PMML表示,並查看生成的PMML文件(純文本,因此可以在任何文本編輯器中打開)以更好地掌握其內部結構。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.