Skip to content

Commit c0b7f06

Browse files
committed
optimize code
1 parent e79004c commit c0b7f06

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

R/FilterUnivariateCox.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ FilterUnivariateCox = R6Class("FilterUnivariateCox",
4646

4747
private = list(
4848
.calculate = function(task, nfeat) {
49-
t = task$clone()
50-
features = t$feature_names
49+
features = task$feature_names
50+
targets = task$data(cols = task$target_names)
5151

5252
scores = map_dbl(features, function(feature) {
53-
t$col_roles$feature = feature
54-
model = invoke(survival::coxph, formula = t$formula(), data = t$data())
53+
model = invoke(
54+
survival::coxph,
55+
formula = task$formula(rhs = feature),
56+
data = cbind(task$data(cols = feature), targets)
57+
)
5558
pval = summary(model)$coefficients[, "Pr(>|z|)"]
5659
-log10(pval) # smaller p-values => larger scores
5760
})

0 commit comments

Comments
 (0)