Skip to contents

Generalized linear classification model. Calls h2o::h2o.glm() from package h2o with family always set to "binomial".

H2O Connection

If no running H2O connection is found, the learner will automatically start a local H2O server on 127.0.0.1 via h2o::h2o.init(). If you want to connect to a remote H2O cluster, call h2o::h2o.init() with the appropriate arguments before training or predicting.

Dictionary

This Learner can be instantiated via lrn():

lrn("classif.h2o.glm")

Meta Information

  • Task type: “classif”

  • Predict Types: “response”, “prob”

  • Feature Types: “integer”, “numeric”, “factor”

  • Required Packages: mlr3, mlr3extralearners, h2o

Parameters

IdTypeDefaultLevelsRange
alphanumeric0.5\([0, 1]\)
balance_classeslogicalFALSETRUE, FALSE-
beta_constraintsuntypedNULL-
beta_epsilonnumeric1e-04\([0, \infty)\)
build_null_modellogicalFALSETRUE, FALSE-
calc_likelogicalFALSETRUE, FALSE-
checkpointuntypedNULL-
class_sampling_factorsuntypedNULL-
cold_startlogicalFALSETRUE, FALSE-
compute_p_valueslogicalFALSETRUE, FALSE-
early_stoppinglogicalTRUETRUE, FALSE-
export_checkpoints_diruntypedNULL-
gainslift_binsinteger-1\([-1, \infty)\)
generate_scoring_historylogicalFALSETRUE, FALSE-
generate_variable_inflation_factorslogicalFALSETRUE, FALSE-
gradient_epsilonnumeric-1\([0, \infty)\)
HGLMlogicalFALSETRUE, FALSE-
ignore_const_colslogicalTRUETRUE, FALSE-
interactionsuntypedNULL-
interaction_pairsuntypedNULL-
interceptlogicalTRUETRUE, FALSE-
lambdanumeric1e-05\([0, \infty)\)
lambda_min_rationumeric-1\([0, 1]\)
lambda_searchlogicalFALSETRUE, FALSE-
linkcharacterlogitfamily_default, logit-
max_active_predictorsinteger-1\([1, \infty)\)
max_after_balance_sizenumeric5\([0, \infty)\)
max_iterationsinteger-1\([0, \infty)\)
max_runtime_secsnumeric0\([0, \infty)\)
missing_values_handlingcharacterMeanImputationMeanImputation, Skip, PlugValues-
nlambdasinteger-1\([1, \infty)\)
non_negativelogicalFALSETRUE, FALSE-
objective_epsilonnumeric-1\([0, \infty)\)
obj_regnumeric-1\([0, \infty)\)
plug_valuesuntypedNULL-
priornumeric-1\([0, \infty)\)
random_columnsuntypedNULL-
remove_collinear_columnslogicalFALSETRUE, FALSE-
score_each_iterationlogicalFALSETRUE, FALSE-
score_iteration_intervalinteger-1\((-\infty, \infty)\)
seedinteger-1\((-\infty, \infty)\)
solvercharacterAUTOAUTO, IRLSM, L_BFGS, COORDINATE_DESCENT, COORDINATE_DESCENT_NAIVE-
standardizelogicalTRUETRUE, FALSE-
startvaluntypedNULL-
stopping_metriccharacterAUTOAUTO, logloss, AUC, AUCPR, lift_top_group, misclassification, mean_per_class_error-
stopping_roundsinteger0\([0, \infty)\)
stopping_tolerancenumeric0.001\([0, \infty)\)

References

Fryda T, LeDell E, Gill N, Aiello S, Fu A, Candel A, Click C, Kraljevic T, Nykodym T, Aboyoun P, Kurka M, Malohlava M, Poirier S, Wong W (2025). h2o: R Interface for the 'H2O' Scalable Machine Learning Platform. R package version 3.46.0.9, https://github.com/h2oai/h2o-3.

See also

Author

awinterstetter

Super classes

mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifH2OGLM

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerClassifH2OGLM$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Define the Learner
learner = lrn("classif.h2o.glm")
print(learner)
#> 
#> ── <LearnerClassifH2OGLM> (classif.h2o.glm): H2O GLM ───────────────────────────
#> • Model: -
#> • Parameters: list()
#> • Packages: mlr3, mlr3extralearners, and h2o
#> • Predict Types: [response] and prob
#> • Feature Types: integer, numeric, and factor
#> • Encapsulation: none (fallback: -)
#> • Properties: missings, twoclass, and weights
#> • Other settings: use_weights = 'use', predict_raw = 'FALSE'

# Define a Task
task = tsk("sonar")

# Create train and test set
ids = partition(task)

# Train the learner on the training ids
learner$train(task, row_ids = ids$train)

print(learner$model)
#> Model Details:
#> ==============
#> 
#> H2OBinomialModel: glm
#> Model ID:  GLM_model_R_1775329217305_56 
#> GLM Model: summary
#>     family  link                               regularization
#> 1 binomial logit Elastic Net (alpha = 0.5, lambda = 0.03825 )
#>   number_of_predictors_total number_of_active_predictors number_of_iterations
#> 1                         60                          33                    7
#>     training_frame
#> 1 data_sid_837b_11
#> 
#> Coefficients: glm coefficients
#>       names coefficients standardized_coefficients
#> 1 Intercept     3.652882                 -0.375927
#> 2        V1   -10.152938                 -0.225707
#> 3       V10    -0.417609                 -0.056964
#> 4       V11    -3.475213                 -0.466538
#> 5       V12    -1.830357                 -0.261304
#> 
#> ---
#>    names coefficients standardized_coefficients
#> 56   V59     0.000000                  0.000000
#> 57    V6     0.000000                  0.000000
#> 58   V60     0.000000                  0.000000
#> 59    V7     2.555053                  0.159481
#> 60    V8     0.000000                  0.000000
#> 61    V9    -0.535558                 -0.067121
#> 
#> H2OBinomialMetrics: glm
#> ** Reported on training data. **
#> 
#> MSE:  0.1043541
#> RMSE:  0.3230388
#> LogLoss:  0.3484208
#> Mean Per-Class Error:  0.1245833
#> AUC:  0.9514583
#> AUCPR:  0.9441534
#> Gini:  0.9029167
#> R^2:  0.579953
#> Residual Deviance:  96.86097
#> AIC:  164.861
#> 
#> Confusion Matrix (vertical: actual; across: predicted) for F1-optimal threshold:
#>         M  R    Error     Rate
#> M      61 14 0.186667   =14/75
#> R       4 60 0.062500    =4/64
#> Totals 65 74 0.129496  =18/139
#> 
#> Maximum Metrics: Maximum metrics at their respective thresholds
#>                         metric threshold     value idx
#> 1                       max f1  0.432305  0.869565  73
#> 2                       max f2  0.350737  0.929204  82
#> 3                 max f0point5  0.635850  0.903846  48
#> 4                 max accuracy  0.516140  0.877698  62
#> 5                max precision  0.976045  1.000000   0
#> 6                   max recall  0.297311  1.000000  88
#> 7              max specificity  0.976045  1.000000   0
#> 8             max absolute_mcc  0.516140  0.753651  62
#> 9   max min_per_class_accuracy  0.516140  0.859375  62
#> 10 max mean_per_class_accuracy  0.516140  0.876354  62
#> 11                     max tns  0.976045 75.000000   0
#> 12                     max fns  0.976045 63.000000   0
#> 13                     max fps  0.000498 75.000000 138
#> 14                     max tps  0.297311 64.000000  88
#> 15                     max tnr  0.976045  1.000000   0
#> 16                     max fnr  0.976045  0.984375   0
#> 17                     max fpr  0.000498  1.000000 138
#> 18                     max tpr  0.297311  1.000000  88
#> 
#> Gains/Lift Table: Extract with `h2o.gainsLift(<model>, <data>)` or `h2o.gainsLift(<model>, valid=<T/F>, xval=<T/F>)`
#> 
#> 


# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)

# Score the predictions
predictions$score()
#> classif.ce 
#>  0.2173913