mlr関数configureMlr()を使用すると、ユーザーは次のパラメーターを設定できます。
on.learner.error: What should happen if an error in an underlying learning algorithm is caught “warn”: A FailureModel will be created, which predicts only NAs and a warning will be generated.
FailureModelが返されたかどうかを確認する最良の方法は何ですか?現時点では、モデルのクラスをチェックしているだけですが、そうでない場合は、FailureModelであると想定しています。
library(survival)
library(mlr)
library(mlrCPO)
data(veteran)
set.seed(24601)
task_id = "MAS"
mas.task <- makeSurvTask(id = task_id, data = veteran, target = c("time", "status"))
mas.task <- createDummyFeatures(mas.task)
preproc_pipeline <- cpoScale() # Standardise the numerical data - center and scale
outer = makeResampleDesc("CV", iters=5, stratify=TRUE) # Benchmarking
cox.lrn <- preproc_pipeline %>>% makeLearner(cl="surv.coxph", id = "coxph", predict.type="response")
learners = list( cox.lrn )
bmr = benchmark(learners=learners, tasks=mas.task, resamplings=outer, measures=list(cindex), show.info = TRUE, models=TRUE)
model_id = 'coxph.scale'
mods = getBMRModels(bmr, learner.ids = c(model_id))
num_models = length(mods[[task_id]][[model_id]])
for (i in 1:num_models) {
mod = getLearnerModel(mods[[task_id]][[model_id]][[i]], more.unwrap=TRUE)
if (class(mod) == "coxph") {
print(mod$coefficients)
} else {
print("Failure model")
}
}
私は以下を試しました、
if (isFailureModel(mod)) {
print("FailureModel")
}
しかし、エラーメッセージが表示されました:
Error in UseMethod("isFailureModel") :
no applicable method for 'isFailureModel' applied to an object of class "coxph"
これに対する簡単な解決策はないと思います(少なくとも私はそれを認識していません)。
あなたのアプローチは成功からそう遠くないようです。ただし、で述べたように?mlr::isFailureModel()
、WrapperModel
特定のモデルクラスのオブジェクト(たとえば、あなたの場合はcoxph)ではなく、クラスのオブジェクトに適用する必要があります。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加