Skip to content

Commit

Permalink
Merge pull request #145 from pommedeterresautee/master
Browse files Browse the repository at this point in the history
refactoring
  • Loading branch information
tqchen committed Jan 18, 2015
2 parents bbbc6be + d84d27a commit d50079f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R-package/R/xgb.importance.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ xgb.importance <- function(feature_names = NULL, filename_dump = NULL, model = N
}

treeDump <- function(feature_names, text){
result <- xgb.model.dt.tree(feature_names = feature_names, text = text)[Feature!="Leaf",][,.(sum(Quality), sum(Cover), .N),by = Feature][,V1:=V1/sum(V1)][,V2:=V2/sum(V2)][,N:=N/sum(N)][order(-rank(V1))]
setnames(result, c("Feature", "Gain", "Cover", "Frequence"))
result <- xgb.model.dt.tree(feature_names = feature_names, text = text)[Feature!="Leaf",.(Gain = sum(Quality), Cover = sum(Cover), Frequence = .N), by = Feature][,`:=`(Gain=Gain/sum(Gain),Cover=Cover/sum(Cover),Frequence=Frequence/sum(Frequence))][order(-Gain)]

result
}

Expand Down

0 comments on commit d50079f

Please sign in to comment.