eps_prob
¶
- Available in: Naïve-Bayes
- Hyperparameter: yes
Description¶
This option specifies the threshold value for probability. If this threshold is not met, then the min_prob
value is used. This option can be used, for example, if one response category has very few observations compared to the total. In this case, the conditional probability may be very low. The min_sdev
and eps_prob
values serve as a cutoff by setting a floor on the calculated probability.
This option is not set by default. When specified, this value must be greater than 0.
Example¶
- r
- python
library(h2o)
h2o.init()
# import the cars dataset
cars <- h2o.importFile("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv")
# Specify model-building exercise (1:binomial, 2:multinomial)
problem <- sample(1:2,1)
# Specify response column based on predictor value and problem type
predictors <- c("displacement","power","weight","acceleration","year")
if ( problem == 1 ) { response_col <- "economy_20mpg"} else { response_col <- "cylinders" }
# Convert the response column to a factor
cars[,response_col] <- as.factor(cars[,response_col])
# Specify model parameters
laplace <- c(1)
min_prob <- c(0.1)
eps_prob <- c(0.5)
# Build the model
cars_naivebayes <- h2o.naiveBayes(x=predictors, y=response_col, training_frame=cars,
eps_prob=eps_prob, min_prob=min_prob, laplace=laplace)
print(cars_naivebayes)
# Predict on training data
cars_naivebayes.pred <- predict(cars_naivebayes, cars)
print(head(cars_naivebayes.pred))
# Specify grid search parameters
grid_space <- list()
grid_space$laplace <- c(1,2)
grid_space$min_prob <- c(0.1,0.2)
grid_space$eps_prob <- c(0.5,0.6)
# Construct the grid of naive bayes models
cars_naivebayes_grid <- h2o.grid(x=predictors, y=response_col, training_frame=cars,
algorithm="naivebayes", grid_id="naiveBayes_grid_cars_test",
hyper_params=grid_space)
print(cars_naivebayes_grid)