2017-10-12 102 views
0

是否有執行在MLR使用包裝預處理步驟後訪問數據的方式是什麼?這裏提供一個剝離版本的代碼:MLR - 之間或預處理後接入數據的步驟

library(mlr) 
library(mlbench) 

data <- BreastCancer[, 2:11] 
lrn <- makeLearner(cl = "classif.ranger", 
         predict.type = "prob", 
         fix.factors.prediction = TRUE, 
         importance = "permutation") 

lrn <- makeImputeWrapper(lrn, classes = list(integer = imputeMedian(), 
                numeric = imputeHist(), 
                factor = imputeMode())) 

lrn <- makeRemoveConstantFeaturesWrapper(lrn, na.ignore = TRUE) 

classif.task <- makeClassifTask(data = rawdata, target = "Target", positive = "1") 

model <- train(lrn, classif.task) 

該代碼定義了一個學習者,刪除了常量特徵並執行插補。有沒有辦法看到刪除常量要素後數據的外觀如何,或者更有趣的是,在插補之後呢?

回答

1

這不是在此刻實現 - 在包裝點是封裝的一切,讓你不必擔心中間步驟。

但是,您可以使用impute()功能(用於去除的恆定功能和下同)分別做同樣的歸集。有關更多信息,請參閱the tutorial

+0

感謝您的快速反應。我使用包裝的原因,例如上面沒有提到的定製的方法是將訓練和評分代碼合併到一個函數中,同時在兩者之間傳遞參數(如果需要,還可以執行超參數調整)。但是,在「真實」工作流程中測試/調試代碼通常與使用單元測試一樣有用。 **而且**有些情況下,第三個包裹,例如在我的情況下xgboostExplainer(https://medium.com/applied-data-science/new-r-package-the-xgboost-explainer-51dd7d1aa211),需要經過預處理的訓練數據。 – notiv

+1

如果你寫定製PreprocessingWrappers(http://mlr-org.github.io/mlr-tutorial/devel/html/preproc/index.html#preprocessing-wrapper-functions),你可以簡單地存儲東西,在全球環境(< < - )或者在火車上寫東西到磁盤並預測功能。 –

+0

謝謝@jakobr,這實際上是一個很好的提示! – notiv

相關問題