Adding examples on xgb.importance, xgb.plot.importance and xgb.plot tree
This commit is contained in:
parent
a735f8cb76
commit
364abdd6d1
@ -337,6 +337,17 @@ err <- as.numeric(sum(as.integer(pred > 0.5) != label))/length(label)
|
|||||||
print(paste("test-error=", err))
|
print(paste("test-error=", err))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
View feature importance/influence from the learnt model
|
||||||
|
-------------------------------------------------------
|
||||||
|
|
||||||
|
Feature importance is similar to R gbm package's relative influence (rel.inf).
|
||||||
|
|
||||||
|
```
|
||||||
|
importance_matrix <- xgb.importance(model = bst)
|
||||||
|
print(importance_matrix)
|
||||||
|
xgb.plot.importance(importance_matrix)
|
||||||
|
```
|
||||||
|
|
||||||
View the trees from a model
|
View the trees from a model
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
@ -346,6 +357,12 @@ You can dump the tree you learned using `xgb.dump` into a text file.
|
|||||||
xgb.dump(bst, with.stats = T)
|
xgb.dump(bst, with.stats = T)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can plot the trees from your model using ```xgb.plot.tree``
|
||||||
|
|
||||||
|
```
|
||||||
|
xgb.plot.tree(model = bst)
|
||||||
|
```
|
||||||
|
|
||||||
> if you provide a path to `fname` parameter you can save the trees to your hard drive.
|
> if you provide a path to `fname` parameter you can save the trees to your hard drive.
|
||||||
|
|
||||||
Save and load models
|
Save and load models
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user