Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPO: Composable Preprocessing Operators #1827

Merged
merged 246 commits into from
Dec 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
246 commits
Select commit Hold shift + click to select a range
ac03d22
Introducing Composable Preprocessing Objects.
Jun 3, 2017
aa2d283
ParamSet syntactic sugar
Jun 3, 2017
d569590
Make git ignore emacs temp files
Jun 3, 2017
a005016
Bugfixes in ParamSetSugar
Jun 3, 2017
7443300
Automatically generate function from braced expressions
Jun 3, 2017
ac8e620
lintr fixes
Jun 3, 2017
1a704ee
Creation of CPOObject
Jun 4, 2017
7349cfb
Nice printing
Jun 4, 2017
fc07a79
CPOObject concatenation
Jun 4, 2017
a5beba8
CPO composition
Jun 4, 2017
307a54d
Composition operator also for attachment
Jun 4, 2017
c91090f
wrapping seems to work now
Jun 4, 2017
3fdbba9
some experiments
Jun 4, 2017
6d27fe3
Some reorganizing
Jun 4, 2017
ce63c0e
Implemented CPOFunctional, against all odds. Probably full of bugs st…
Jun 4, 2017
c767f7a
Reorg: Organize CPOObjectBased, CPOFunctional the same
Jun 4, 2017
fe26b4f
Bugfixes
Jun 4, 2017
9132f86
CPOObject now doesn't need to return 'control', just create it.
Jun 4, 2017
222b08a
lintr
Jun 4, 2017
e87c580
ParamSetSugar test
Jun 5, 2017
5963c0f
Indentation
Jun 5, 2017
52d6988
Testing most of CPO, excluding ParamSet feasibility checks
Jun 5, 2017
d41e287
Bugfixes, found through tests
Jun 5, 2017
dc8c342
setHyperPars: assert uniquely named parameters
Jun 5, 2017
9ba3d4b
Testing hyperparameter feasibility
Jun 5, 2017
3ab44f1
Test parameter feasibility
Jun 5, 2017
0375e41
Testing actual data transformation
Jun 5, 2017
d461e77
Testing CPO trafo functions
Jun 5, 2017
f35f3ee
Testing requirement handling
Jun 5, 2017
21303b7
Forgive absence of parameters with unfulfilled requirements
Jun 5, 2017
ce96cf3
Requirement handling when changing ID
Jun 5, 2017
19af045
Repair global var problems in S3 methods in cpo tests
Jun 5, 2017
5638bc8
lintr
Jun 5, 2017
9cadea3
Application operator
Jun 5, 2017
6a97975
Corrected copy-paste caused typo
Jun 5, 2017
5bed71d
Inform user when he forgets to construct CPO
Jun 5, 2017
3e52a49
Documentation
Jun 5, 2017
a5cdddf
Make R CMD check --no-test happy
Jun 5, 2017
5a84fe3
lintr doesnt recognize CPO function definitions as functions
Jun 5, 2017
709480d
Retrafo set / access functions
Jun 6, 2017
bdaa635
paramSetSugar parameter pss.* now have dot prefix
Jun 6, 2017
27a3068
retrafo() machinery
Jun 6, 2017
04d47ca
Functional CPO now uses retrafo()
Jun 6, 2017
71124b4
Roxygenise
Jun 6, 2017
c2dfdc1
Tests work again
Jun 6, 2017
4d1b693
Bugfixes
Jun 6, 2017
ce390fd
More informative error messages
Jun 6, 2017
b36e3c1
More informative error messages
Jun 6, 2017
c708318
Testing for error handling
Jun 6, 2017
902bf3c
Embarrassing!
Jun 6, 2017
32d3cb0
static analyzer safe paramSetSugar
Jun 6, 2017
106f4e0
Using NA instead of dot to indicate missing parameter
Jun 6, 2017
142239f
Cleaning up documentation
Jun 6, 2017
deb02d3
Documentation fixes
Jun 6, 2017
a09841f
lintr
Jun 6, 2017
ebfd032
Turn chain of preprocs into list, and assemble list into chain
Jun 7, 2017
07dee57
roxygenize
Jun 7, 2017
8f3557e
Put common CPO test objects into helper_cpo.R
Jun 7, 2017
e2c42cc
Refactor chainung and un-chaining
Jun 7, 2017
018168f
Chaining, unchaining of object based retrafos
Jun 7, 2017
cdae51f
use 'predict' to apply retrafos
Jun 7, 2017
ef32bf9
lint
Jun 7, 2017
eafb7d0
Adding get / set retrafo state functionality
Jun 7, 2017
e8e6eb5
Adding get state and makefromstate for object based
Jun 7, 2017
3ef0230
Cleaning up CPO object based
Jun 7, 2017
bacf681
Testing for retrafo state
Jun 7, 2017
d14102d
Cleaning up CPOFunctional
Jun 7, 2017
5377138
Adding get state and makefromstate for functional based
Jun 7, 2017
9dd358d
lintr
Jun 7, 2017
f973beb
R CMD check
Jun 7, 2017
747ed41
Small test correction
Jun 7, 2017
837f87f
small comment change
Jun 8, 2017
38d2522
retrafo assignment now checks for type, not function
Jun 8, 2017
463df85
Adding properties parameters
Jun 8, 2017
35899e7
Added docu, todo
Jun 8, 2017
fc98b7b
Starting task shape verification things
Jun 8, 2017
4eccc4a
Get format check its own file
Jun 8, 2017
a55e427
Auxiliary files reorg
Jun 8, 2017
68aac1d
changed object based callCPO[Re]Trafo, need to propagate the changes now
Jun 8, 2017
4e16e5f
One more step towards properties & data shape checking
Jun 9, 2017
ee7d106
Tests pass again
Jun 9, 2017
6562cb9
cleaning up
Jun 9, 2017
a0034ae
Make lint approve of TODOs temporarily
Jun 9, 2017
514163c
Tests first half of target type functionality
Jun 9, 2017
796f176
checkLearnerBeforeTrain: Wrong error message when unordered not suppo…
Jun 9, 2017
7422c96
lintr
Jun 9, 2017
a2342a8
NOOP
Jun 9, 2017
f7e5c39
Merge branch 'master' into ComposablePreprocOperators
Jun 9, 2017
392d272
Finished datasplit tests
Jun 10, 2017
fea64ab
Most property tests are done
Jun 10, 2017
f82b75a
get CPO from learner
Jun 10, 2017
dfca765
Ported properties and datasplit to functional
Jun 10, 2017
382270c
Tests pass
Jun 10, 2017
4e9df81
roxygenise
Jun 10, 2017
89dfac8
Make tests faster
Jun 10, 2017
2fc3107
travis timeout ++
Jun 10, 2017
9bf5dbd
Travis timeout +++
Jun 10, 2017
659eb0a
Rewritten CPO core. A beauty to behold!
Jun 11, 2017
9b1da71
Travis timeout ++++
Jun 11, 2017
40ccad9
Added 'factor', 'ordered', 'onlyfactor', 'numeric' datasplit
Jun 11, 2017
89f5bf2
Introducing NULLCPO, the neutral element of the CPO monad
Jun 11, 2017
40c35a9
Starting targetbound CPO
Jun 11, 2017
86e18c0
Targetbound CPO Task conversion backend
Jun 11, 2017
b0dfe11
static code analyser found bugs
Jun 11, 2017
59b1946
Making big steps towards target CPOs
Jun 12, 2017
1b0e0f9
to-do list, travis timeout ++ again
Jun 12, 2017
3b54bc9
Pretty much done with target-bound CPO
Jun 13, 2017
d34be3e
Introducing stateless CPOs
Jun 13, 2017
cb5b7a7
is.nullcpo
Jun 13, 2017
75cc19f
Completing stateless
Jun 13, 2017
1507b82
Roxygenise
Jun 13, 2017
9262992
Tests pass
Jun 13, 2017
4fd1660
lintr
Jun 13, 2017
21eaa3e
Merge remote-tracking branch 'origin/master' into ComposablePreprocOp…
Jun 13, 2017
6ef77fb
stateless trafo-less CPO
Jun 13, 2017
deafe84
ShapeInfo printing
Jun 14, 2017
fe20a6f
Nicer ShapeInfo printing
Jun 14, 2017
cceb2e1
More generics for getting CPO information
Jun 14, 2017
3e3f299
Multiplexer, Applicator
Jun 14, 2017
83517f1
Renaming test files
Jun 14, 2017
b35fad9
Split up test_cpo_datasplit into *_datasplit and *_properties
Jun 14, 2017
1740471
Checking par.vals availability at the right places
Jun 15, 2017
8284d1b
Proper datasplit numeric / factor / etc handling
Jun 15, 2017
ed24554
New tests
Jun 15, 2017
923766d
Datasplit numeric, factor, ordered, onlyfactor finally seem to work
Jun 15, 2017
d26c198
Finished datasplit tests
Jun 15, 2017
b0ef0f4
summary bug
Jun 15, 2017
a2a28bd
example CPOs handle DFs containing non-numeric columns
Jun 15, 2017
a433dd8
repair summary
Jun 15, 2017
10d7e8d
Accept NA vector length
Jun 16, 2017
4ac7a94
Accept character vectors for discrete character params
Jun 16, 2017
41c391a
cpoSelect CPO
Jun 16, 2017
6b44529
cpoSelect Params Reorg
Jun 16, 2017
ed832d1
cpoCbind
Jun 16, 2017
8ae7e43
Check more rigorously that CPOs don't get called too often.
Jun 16, 2017
8b2c215
Test cpoCbind with tasks
Jun 16, 2017
5e72da8
Merge remote-tracking branch 'origin/master' into ComposablePreprocOp…
Jun 16, 2017
31c1152
listCPO
Jun 17, 2017
258d395
Testing concrete CPOs so far
Jun 18, 2017
6922409
Fix retrafo column name test
Jun 18, 2017
b86af3a
fix.factors
Jun 18, 2017
b421441
dummy encoder
Jun 18, 2017
e5ed13a
Column selection by name
Jun 18, 2017
475c84f
invert option for cpoSelect
Jun 18, 2017
515640b
Starting to implement affect.*
Jun 18, 2017
eded721
Interpreting subset
Jun 18, 2017
176688b
Fixing some bugs, implementing some tests, for affect subset
Jun 18, 2017
1169fc7
Don't print meta-params for CPO constructors
Jun 19, 2017
092ded1
Tests for affect.* done
Jun 19, 2017
02564e0
Collect meta-CPOs in a separate file
Jun 19, 2017
edd36b4
Finishing cpoMeta and its tests
Jun 19, 2017
5c32a5e
lintr
Jun 19, 2017
a6b539a
Export cpoMeta
Jun 19, 2017
bbb339d
Fix summary bug
Jun 19, 2017
683ad38
Export some functions I forgot to export
Jun 19, 2017
8096cc9
Adding jupyter vignette
Jun 19, 2017
50e92fb
Adding html rendered version of vignette
Jun 19, 2017
7fca290
update .gitignore
Jun 19, 2017
916fae1
Compact html vignette
Jun 19, 2017
953f840
Fixing test bug for impute
Jun 20, 2017
3a70b92
Impute CPO + tests
Jun 20, 2017
11639ff
Adding specialised CPO imputers
Jun 20, 2017
1f74f5c
CPO Imputers get their own file
Jun 20, 2017
7394314
lintr
Jun 20, 2017
7bf55e7
Test that dummys are not created when the flag says so.
Jun 20, 2017
fc16b90
Updating Vignette
Jun 20, 2017
2ea448e
checkMeasures: instead of missing(), use NULL
Jun 21, 2017
5d5eedb
Feature Filters
Jun 21, 2017
bdcf9fc
Introducing applyCPO: apply a CPO to a Task / df
Jun 24, 2017
3fe43e6
Introduce composeCPO: composing two CPOs
Jun 24, 2017
15eb679
Introducing attachCPO: Attaching a CPO to a learner.
Jun 24, 2017
2ce6209
Adjust properties of imputers that can only handle certain types
Jun 24, 2017
a79317b
Forgot export
Jun 24, 2017
90311bd
filter features now only operate on the columns of the right type
Jun 24, 2017
829e1bd
Constant Feature Remover CPO
Jun 24, 2017
e5d4dbf
CPO for fixing factors
Jun 24, 2017
ad7d16b
cpoDummyEncode works much better now
Jun 24, 2017
82a72ff
MissingIndicators CPO
Jun 24, 2017
6b12f93
Repairing checkMeasures
Jun 24, 2017
dc7a187
Better travis check
Jun 24, 2017
9155416
cpoCbind bugfixes
Jun 24, 2017
91b6d8f
bugfix
Jun 24, 2017
bf610ed
Vignette updates
Jun 24, 2017
ea4b9c8
use cases ipynb
Jun 26, 2017
03c9657
Recursive application of CPO fix
Jul 12, 2017
1e2e4d1
Merge branch 'master' into ComposablePreprocOperators
Jul 12, 2017
baf67ab
roxygenise
Jul 12, 2017
ba2cf73
Avoid warnings when load_all-ing mlr
Jul 14, 2017
1770d37
Merge branch 'master' into ComposablePreprocOperators
Jul 14, 2017
b484cc5
Now possible to specify packages associated with CPOs
Jul 15, 2017
b8122c8
Bugfix
Jul 15, 2017
9e1007f
Fix blackboost bug
Jul 15, 2017
76bdfe5
Revert "Avoid warnings when load_all-ing mlr"
Jul 25, 2017
1b7d59b
Revert "Fix blackboost bug"
Jul 25, 2017
08aaca8
Fix imputation of empty df bug
Jul 18, 2017
4b39d69
cpoScale fix for 1-column data
Jul 18, 2017
90ce673
cpoApplyFun
Jul 26, 2017
98673e2
cpoRangeScale
Jul 26, 2017
0f6afec
cpoProbEncode
Jul 26, 2017
a3219b5
Impact encoding
Jul 27, 2017
f66304c
Adding new CPOs
Jul 27, 2017
bcd4aab
rename cpoRangeScale -> cpoScaleRange
Jul 28, 2017
66ad392
More natural handling of 'stateless' cpo
Jul 28, 2017
abfcbd8
.retrafo.format added, with new 'combined' option
Jul 28, 2017
5cc5f4b
optionally only export subset of parameters
Jul 31, 2017
31fdd66
fix export
Jul 31, 2017
6229492
removing 'CPOS3Primitive' class, as ordered
Jul 31, 2017
80b1cd6
removing 'CPOS3Constructor' class, as ordered
Jul 31, 2017
2ecb30c
removing 'CPOS3RetrafoPrimitive', as ordered
Jul 31, 2017
2905019
simplifying class structure, as ordered
Jul 31, 2017
bee6720
simplifying class structure further
Jul 31, 2017
4a9f1ad
done simplifying class structure
Jul 31, 2017
49dbe4a
makeCPO documentation
Jul 31, 2017
8e2fecc
Handle ID correctly for non-exported values
Aug 1, 2017
0216b9c
Pretty printing; Bugfixes
Aug 1, 2017
5bc900a
A few new CPOs
Aug 1, 2017
2b97a8f
cpoSpatialSign
Aug 2, 2017
cd7bb2c
tuning CPO test
Aug 2, 2017
ab2eb9d
tuning CPO test II
Aug 2, 2017
b79b3bb
bugfixes
Aug 2, 2017
0c26d0b
roxygenise
Aug 2, 2017
19a317e
Vignette: Examples, CPOs, Construction
Aug 4, 2017
b09b1c2
cleaning up vignette
Aug 4, 2017
2d54378
vignette html export
Aug 4, 2017
6d459ee
Bugfix
Aug 4, 2017
9d81764
Merge branch 'master' into ComposablePreprocOperators
Aug 4, 2017
e7310dd
Tuning vignette
Aug 6, 2017
7398595
vignette
Aug 7, 2017
5a1a725
exporting necessary things
Aug 8, 2017
31ae1b0
deleting superfluous files which are now in mlrCPO
Aug 8, 2017
12d4b06
forgot necessary function
Aug 8, 2017
9dc4dc6
Export makeBaseWrapper
Aug 17, 2017
a161c5d
Merge branch 'master' into ComposablePreprocOperators
Aug 17, 2017
be84fae
Removing paramSetSugar
Aug 24, 2017
be896ec
Roxygenise
Aug 24, 2017
99151fc
Exporting changeData
Sep 4, 2017
d280768
Merge branch 'master' into ComposablePreprocOperators
Nov 13, 2017
46232a2
Removing the last few bits from before the cpo-mlr-split
Nov 13, 2017
c560097
Export checkPredictLearnerOutput for mlrCPO
Dec 1, 2017
03d2c3c
add 'keywords internal' to internal use only functions
Dec 1, 2017
4ecc1dd
roxygenise
Dec 1, 2017
7044b17
Merge branch 'master' into ComposablePreprocOperators
Dec 4, 2017
173b470
overlooked while merging
Dec 4, 2017
48a75df
%%
Dec 4, 2017
28d1bda
Merge branch 'master' into ComposablePreprocOperators
Dec 7, 2017
0d4a2a6
Merge branch 'master' into ComposablePreprocOperators
Dec 13, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ ehthumbs.db
Icon?
Thumbs.db
*xgboost.model
.#*
*~
\#*#
.project
.settings
.ipynb_checkpoints
man/*.Rd
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,4 @@ LazyData: yes
ByteCompile: yes
Version: 2.12
VignetteBuilder: knitr
RoxygenNote: 6.0.1.9000
RoxygenNote: 6.0.1
12 changes: 12 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,9 @@ export(brier.scaled)
export(calculateConfusionMatrix)
export(calculateROCMeasures)
export(capLargeValues)
export(changeData)
export(checkLearner)
export(checkPredictLearnerOutput)
export(cindex)
export(cindex.uno)
export(configureMlr)
Expand Down Expand Up @@ -939,14 +942,19 @@ export(lsr)
export(mae)
export(makeAggregation)
export(makeBaggingWrapper)
export(makeBaseWrapper)
export(makeChainModel)
export(makeClassifTask)
export(makeClassifTaskDesc)
export(makeClassificationViaRegressionWrapper)
export(makeClusterTask)
export(makeClusterTaskDesc)
export(makeConstantClassWrapper)
export(makeCostMeasure)
export(makeCostSensClassifWrapper)
export(makeCostSensRegrWrapper)
export(makeCostSensTask)
export(makeCostSensTaskDesc)
export(makeCostSensWeightedPairsWrapper)
export(makeCustomResampledMeasure)
export(makeDownsampleWrapper)
Expand Down Expand Up @@ -976,6 +984,7 @@ export(makeMultilabelDBRWrapper)
export(makeMultilabelNestedStackingWrapper)
export(makeMultilabelStackingWrapper)
export(makeMultilabelTask)
export(makeMultilabelTaskDesc)
export(makeOverBaggingWrapper)
export(makeOversampleWrapper)
export(makePrediction)
Expand All @@ -989,12 +998,15 @@ export(makeRLearnerMultilabel)
export(makeRLearnerRegr)
export(makeRLearnerSurv)
export(makeRegrTask)
export(makeRegrTaskDesc)
export(makeRemoveConstantFeaturesWrapper)
export(makeResampleDesc)
export(makeResampleInstance)
export(makeSMOTEWrapper)
export(makeStackedLearner)
export(makeSurvTask)
export(makeSurvTaskDesc)
export(makeTaskDescInternal)
export(makeTuneControlCMAES)
export(makeTuneControlDesign)
export(makeTuneControlGenSA)
Expand Down
19 changes: 19 additions & 0 deletions R/BaseWrapper.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#' Exported for internal use only.
#' @param id [\code{character(1)}]\cr
#' Id string for object. Used to display object.
#' @param type [\code{character(1)}]\cr
#' Learner type.
#' @param next.learner [\code{Learner}]\cr
#' Learner to wrap.
#' @param package [\code{character}]\cr
#' Packages to load when loading learner.
#' @param par.set [\code{ParamSet}]\cr
#' Parameter set.
#' @param par.vals [\code{list}]\cr
#' Optional list of named (hyper)parameter values.
#' @param learner.subclass [\code{character}]\cr
#' Class to assign the new object.
#' @param model.subclass [\code{character}]\cr
#' Class to assign learner models.
#' @keywords internal
#' @export
makeBaseWrapper = function(id, type, next.learner, package = character(0L), par.set = makeParamSet(),
par.vals = list(), learner.subclass, model.subclass) {
if (inherits(next.learner, "OptWrapper") && is.element("TuneWrapper", learner.subclass))
Expand Down
8 changes: 8 additions & 0 deletions R/ChainModel.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#' Only exported for internal use.
#' @param next.model [\code{WrappedModel}]\cr
#' The next model.
#' @param cl [\code{character}]\cr
#' Subclass to assign to the resulting model.
#'
#' @keywords internal
#' @export
makeChainModel = function(next.model, cl) {
setClasses(list(next.model = next.model), c(cl, "ChainModel", "WrappedModel"))
}
Expand Down
2 changes: 2 additions & 0 deletions R/ClassifTask.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ makeClassifTask = function(id = deparse(substitute(data)), data, target, weights
addClasses(task, "ClassifTask")
}

#' @export
#' @rdname makeTaskDesc
makeClassifTaskDesc = function(id, data, target, weights, blocking, positive, spatial) {
levs = levels(data[[target]])
m = length(levs)
Expand Down
2 changes: 2 additions & 0 deletions R/ClusterTask.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ makeClusterTask = function(id = deparse(substitute(data)), data, weights = NULL,
addClasses(task, "ClusterTask")
}

#' @export
#' @rdname makeTaskDesc
makeClusterTaskDesc = function(id, data, weights, blocking, spatial) {
target = character(0L)
td = makeTaskDescInternal("cluster", id, data, target, weights, blocking, spatial)
Expand Down
2 changes: 2 additions & 0 deletions R/CostSensTask.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ makeCostSensTask = function(id = deparse(substitute(data)), data, costs, blockin
addClasses(task, "CostSensTask")
}

#' @export
#' @rdname makeTaskDesc
makeCostSensTaskDesc = function(id, data, target, blocking, costs, spatial) {
td = makeTaskDescInternal("costsens", id, data, target, weights = NULL, blocking = blocking, spatial)
td$class.levels = colnames(costs)
Expand Down
3 changes: 2 additions & 1 deletion R/ImputeMethods.R
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ imputeNormal = function(mu = NA_real_, sd = NA_real_) {
imputeHist = function(breaks, use.mids = TRUE) {
if (missing(breaks)) {
breaks = "Sturges"
} else {
}
if (!identical(breaks, "Sturges")) {
breaks = asCount(breaks)
}
assertFlag(use.mids)
Expand Down
2 changes: 2 additions & 0 deletions R/MultilabelTask.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ print.MultilabelTask = function(x, ...) {
print(sums)
}

#' @export
#' @rdname makeTaskDesc
makeMultilabelTaskDesc = function(id, data, target, weights, blocking, spatial) {
levs = target
td = makeTaskDescInternal("multilabel", id, data, target, weights, blocking, spatial)
Expand Down
2 changes: 2 additions & 0 deletions R/RegrTask.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ makeRegrTask = function(id = deparse(substitute(data)), data, target, weights =
addClasses(task, "RegrTask")
}

#' @export
#' @rdname makeTaskDesc
makeRegrTaskDesc = function(id, data, target, weights, blocking, spatial) {
addClasses(makeTaskDescInternal("regr", id, data, target, weights, blocking, spatial), c("RegrTaskDesc", "SupervisedTaskDesc"))
}
2 changes: 2 additions & 0 deletions R/SurvTask.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ makeSurvTask = function(id = deparse(substitute(data)), data, target, weights =
addClasses(task, "SurvTask")
}

#' @export
#' @rdname makeTaskDesc
makeSurvTaskDesc = function(id, data, target, weights, blocking, spatial) {
td = makeTaskDescInternal("surv", id, data, target, weights, blocking, spatial)
addClasses(td, c("SurvTaskDesc", "SupervisedTaskDesc"))
Expand Down
17 changes: 17 additions & 0 deletions R/Task.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@
#' }
NULL

#' Exported for internal use.
#' @param id [\code{character(1)}]\cr
#' task id
#' @param data [\code{data.frame}]\cr
#' data
#' @param target [\code{character}]\cr
#' target columns
#' @param weights [\code{numeric}]\cr
#' weights
#' @param blocking [\code{numeric}\cr
#' task data blocking
#' @param spatial [\code{logical(1)}]\cr
#' whether data is spatial
#' @keywords internal
#' @name makeTaskDesc
NULL

makeTask = function(type, data, weights = NULL, blocking = NULL, fixup.data = "warn", check.data = TRUE, spatial = FALSE) {
if (fixup.data != "no") {
if (fixup.data == "quiet") {
Expand Down
17 changes: 17 additions & 0 deletions R/TaskDesc.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@
#' @rdname TaskDesc
NULL

#' Exported for internal use.
#' @param type [\code{character(1)}]\cr
#' Task type.
#' @param id [\code{character(1)}]\cr
#' task id
#' @param data [\code{data.frame}]\cr
#' data
#' @param target [\code{character}]\cr
#' target columns
#' @param weights [\code{numeric}]\cr
#' weights
#' @param blocking [\code{numeric}\cr
#' task data blocking
#' @param spatial [\code{logical(1)}]\cr
#' whether data is spatial
#' @keywords internal
#' @export
makeTaskDescInternal = function(type, id, data, target, weights, blocking, spatial) {
# get classes of feature cols
cl = vcapply(data, function(x) class(x)[1L])
Expand Down
13 changes: 13 additions & 0 deletions R/Task_operators.R
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,19 @@ subsetTask = function(task, subset = NULL, features) {


# we create a new env, so the reference is not changed
#' Change Task Data
#'
#' Mainly for internal use. Changes the data associated with a task, without modifying other task properties.
#'
#' @template arg_task
#' @param data [\code{data.frame}]\cr
#' The new data to associate with the task. The names and types of the feature columns must match with the old data.
#' @param costs [\code{data.frame}\cr
#' Optional: cost matrix.
#' @param weights [\code{numeric}]\cr
#' Optional: weight vector.
#' @keywords internal
#' @export
changeData = function(task, data, costs, weights) {
if (missing(data))
data = getTaskData(task)
Expand Down
9 changes: 9 additions & 0 deletions R/checkLearner.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# props checks if Learner has one or more properties specified in props as a
# character vector.

#' Exported for internal use only.
#' @param learner [\code{\link{Learner}} | \code{character(1)}]\cr
#' The learner to check, or the name of the learner to create
#' @param type [\code{character(1)}]\cr
#' What type of learner to require.
#' @param props [\code{character(1)}]\cr
#' What properties to require.
#' @keywords internal
#' @export
checkLearner = function(learner, type = NULL, props = NULL) {
if (is.character(learner))
learner = makeLearner(learner)
Expand Down
2 changes: 1 addition & 1 deletion R/checkLearnerBeforeTrain.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ checkLearnerBeforeTrain = function(task, learner, weights) {
}

if (td$n.feat["ordered"] > 0L && !hasLearnerProperties(learner, "ordered")) {
wrong.cols = getColNames(task, is.factor)
wrong.cols = getColNames(task, function(x) class(x)[1] == "ordered")
stopf("Task '%s' has ordered factor inputs in '%s', but learner '%s' does not support that!", td$id, wrong.cols, learner$id)
}

Expand Down
2 changes: 1 addition & 1 deletion R/checkMeasures.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
checkMeasures = function(measures, obj, aggr = NULL) {
if (missing(measures)) {
if (missing(measures) || is.null(measures)) {
measures = list(getDefaultMeasure(obj))
} else {
measures = ensureVector(measures, n = 1L, cl = "Measure")
Expand Down
1 change: 0 additions & 1 deletion R/getHyperPars.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#' @family learner
#' @export
getHyperPars = function(learner, for.fun = c("train", "predict", "both")) {
assertClass(learner, classes = "Learner")
assertSubset(for.fun, choices = c("train", "predict", "both"))
UseMethod("getHyperPars")
}
Expand Down
17 changes: 17 additions & 0 deletions R/predictLearner.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@ insertLines = function(prediction, inserts) {
return(ret)
}

#' @title Check output returned by predictLearner.
#'
#' @description
#' Check the output coming from a Learner's internal
#' \code{predictLearner} function.
#'
#' This function is for internal use.
#'
#' @param learner [\code{\link{Learner}}]\cr
#' The learner.
#' @param model [\code{\link{WrappedModel}}]]\cr
#' Model produced by training.
#' @param p [any]\cr
#' The prediction made by \code{learner}.
#' @return [any]. A sanitized version of \code{p}.
#' @keywords internal
#' @export
checkPredictLearnerOutput = function(learner, model, p) {
cl = class(p)[1L]
if (learner$type == "classif") {
Expand Down
5 changes: 2 additions & 3 deletions R/setHyperPars.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
#' print(cl2)
setHyperPars = function(learner, ..., par.vals = list()) {
args = list(...)
assertClass(learner, classes = "Learner")
assertList(args, names = "named", .var.name = "parameter settings")
assertList(par.vals, names = "named", .var.name = "parameter settings")
assertList(args, names = "unique", .var.name = "parameter settings")
assertList(par.vals, names = "unique", .var.name = "parameter settings")
setHyperPars2(learner, insert(par.vals, args))
}

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test_base_impute.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ test_that("Impute data frame", {
x = impute(data, target = target, dummy.classes = "numeric", dummy.cols = "z")$data
expect_true(setequal(names(x), c(names(data), "x.dummy", "y.dummy", "z.dummy")))

x = impute(data, target = target, classes = list(factor = imputeMode(), numeric = imputeMedian(),
x = impute(data, target = character(0), classes = list(factor = imputeMode(), numeric = imputeMedian(),
integer = imputeMedian(), logical = imputeConstant(1)))
expect_true(all(!is.na(x)))
expect_true(all(!is.na(x$data)))

data2 = data[1:5, ]
x = impute(data2, target = target, dummy.classes = c("numeric", "logical", "factor"), force.dummies = TRUE)
Expand Down