9
9
# ' association with the event of interest, typically in the context of clinical
10
10
# ' or biomedical research.
11
11
# '
12
- # ' This filter fits a [CoxPH][mlr3proba::LearnerSurvCoxPH ()] learner using each
13
- # ' feature independently and extracts the \eqn{p}-value that quantifies the
12
+ # ' This filter fits a [Cox Proportional Hazards][survival::coxph ()] model using
13
+ # ' each feature independently and extracts the \eqn{p}-value that quantifies the
14
14
# ' significance of the feature's impact on survival. The filter value is
15
15
# ' `-log10(p)` where `p` is the \eqn{p}-value. This transformation is necessary
16
16
# ' to ensure numerical stability for very small \eqn{p}-values. Also higher
44
44
# ' # Use filter in a learner pipeline
45
45
# ' # Note: `filter.cutoff` is selected randomly and should be tuned.
46
46
# ' # The significance level of `0.05` serves as a conventional threshold.
47
- # ' # The filter returns the `-log `-transformed scores so we transform
47
+ # ' # The filter returns the `-log10 `-transformed scores so we transform
48
48
# ' # the cutoff as well:
49
- # ' cutoff = -log (0.05) # ~2.99
49
+ # ' cutoff = -log10 (0.05) # ~1.3
50
50
# '
51
51
# ' graph =
52
52
# ' po("filter", filter = flt("univariatecox"), filter.cutoff = cutoff) %>>%
@@ -69,7 +69,7 @@ FilterUnivariateCox = R6Class("FilterUnivariateCox",
69
69
initialize = function () {
70
70
super $ initialize(
71
71
id = " surv.univariatecox" ,
72
- packages = c(" mlr3proba " ),
72
+ packages = c(" survival " ),
73
73
param_set = ps(),
74
74
feature_types = c(" integer" , " numeric" ),
75
75
task_types = " surv" ,
@@ -83,13 +83,12 @@ FilterUnivariateCox = R6Class("FilterUnivariateCox",
83
83
.calculate = function (task , nfeat ) {
84
84
t = task $ clone()
85
85
features = t $ feature_names
86
- learner = lrn(" surv.coxph" )
87
86
88
87
scores = map_dbl(features , function (feature ) {
89
88
t $ col_roles $ feature = feature
90
- learner $ train( t )
91
- pval = summary(learner $ model )$ coefficients [, " Pr(>|z|)" ]
92
- - log (pval ) # smaller p-values => larger scores
89
+ model = invoke( survival :: coxph , formula = t $ formula(), data = t $ data() )
90
+ pval = summary(model )$ coefficients [, " Pr(>|z|)" ]
91
+ - log10 (pval ) # smaller p-values => larger scores
93
92
})
94
93
95
94
set_names(scores , features )
0 commit comments