h2o.relevel_by_frequency | R Documentation |
The levels of a factor are reordered so that the most frequency level is at level 0, remaining levels are ordered from the second most frequent to the least frequent.
h2o.relevel_by_frequency(x, weights_column = NULL, top_n = -1)
x |
H2O frame with some factor columns |
weights_column |
optional name of weights column |
top_n |
optional number of most frequent levels to move to the top (eg.: for top_n=1 move only the most frequent level) |
new reordered frame
## Not run:
library(h2o)
h2o.init()
# Convert iris dataset to an H2OFrame
iris_hf <- as.h2o(iris)
# Look at current ordering of the Species column levels
h2o.levels(iris_hf["Species"])
# "setosa" "versicolor" "virginica"
# Change the reference level to "virginica"
iris_hf["Species"] <- h2o.relevel_by_frequency(x = iris_hf["Species"])
# Observe new ordering
h2o.levels(iris_hf["Species"])
# "virginica" "versicolor" "setosa"
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.