remove intersect column in sparse Matrix

This commit is contained in:
Michaël Benesty 2015-12-05 19:02:05 +01:00
parent 4f4a5409d7
commit 3b67028ad6

View File

@ -29,10 +29,10 @@ create.new.tree.features <- function(model, original.features){
cols <- list()
for(i in 1:length(trees)){
# max is not the real max but it s not important for the purpose of adding features
max <- max(pred_with_leaf[,i])
cols[[i]] <- factor(x = pred_with_leaf[,i], level = seq(to = max))
leaf.id <- sort(unique(pred_with_leaf[,i]))
cols[[i]] <- factor(x = pred_with_leaf[,i], level = leaf.id)
}
cBind(original.features, sparse.model.matrix( ~ ., as.data.frame(cols)))
cBind(original.features, sparse.model.matrix( ~ . -1, as.data.frame(cols)))
}
# Convert previous features to one hot encoding