Modeling In H2O¶
Supervised¶
H2OANOVAGLMEstimator
¶
-
class
h2o.estimators.anovaglm.
H2OANOVAGLMEstimator
(model_id=None, training_frame=None, seed=-1, response_column=None, ignored_columns=None, ignore_const_cols=True, score_each_iteration=False, offset_column=None, weights_column=None, family='auto', tweedie_variance_power=0.0, tweedie_link_power=1.0, theta=0.0, solver='irlsm', missing_values_handling='mean_imputation', plug_values=None, compute_p_values=True, standardize=True, non_negative=False, max_iterations=0, link='family_default', prior=0.0, alpha=None, lambda_=[0.0], lambda_search=False, stopping_rounds=0, stopping_metric='auto', early_stopping=False, stopping_tolerance=0.001, balance_classes=False, class_sampling_factors=None, max_after_balance_size=5.0, max_runtime_secs=0.0, save_transformed_framekeys=False, highest_interaction_term=0, nparallelism=4, type=0)[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
ANOVA for Generalized Linear Model
H2O ANOVAGLM is used to calculate Type III SS which is used to evaluate the contributions of individual predictors and their interactions to a model. Predictors or interactions with negligible contributions to the model will have high p-values while those with more contributions will have low p-values.
-
property
Lambda
¶ DEPRECATED. Use
self.lambda_
instead
-
property
alpha
¶ Distribution of regularization between the L1 (Lasso) and L2 (Ridge) penalties. A value of 1 for alpha represents Lasso regression, a value of 0 produces Ridge regression, and anything in between specifies the amount of mixing between the two. Default value of alpha is 0 when SOLVER = ‘L-BFGS’; 0.5 otherwise.
Type:
List[float]
.
-
property
balance_classes
¶ Balance training data class counts via over/under-sampling (for imbalanced data).
Type:
bool
, defaults toFalse
.
-
property
class_sampling_factors
¶ Desired over/under-sampling ratios per class (in lexicographic order). If not specified, sampling factors will be automatically computed to obtain class balance during training. Requires balance_classes.
Type:
List[float]
.
-
property
compute_p_values
¶ Request p-values computation, p-values work only with IRLSM solver and no regularization
Type:
bool
, defaults toTrue
.
-
property
early_stopping
¶ Stop early when there is no more relative improvement on train or validation (if provided).
Type:
bool
, defaults toFalse
.
-
property
family
¶ Family. Use binomial for classification with logistic regression, others are for regression problems.
Type:
Literal["auto", "gaussian", "binomial", "fractionalbinomial", "quasibinomial", "poisson", "gamma", "tweedie", "negativebinomial"]
, defaults to"auto"
.
-
property
highest_interaction_term
¶ Limit the number of interaction terms, if 2 means interaction between 2 columns only, 3 for three columns and so on… Default to 2.
Type:
int
, defaults to0
.
-
property
ignore_const_cols
¶ Ignore constant columns.
Type:
bool
, defaults toTrue
.
-
property
ignored_columns
¶ Names of columns to ignore for training.
Type:
List[str]
.
-
property
lambda_
¶ Regularization strength
Type:
List[float]
, defaults to[0.0]
.
-
property
lambda_search
¶ Use lambda search starting at lambda max, given lambda is then interpreted as lambda min
Type:
bool
, defaults toFalse
.
-
property
link
¶ Link function.
Type:
Literal["family_default", "identity", "logit", "log", "inverse", "tweedie", "ologit"]
, defaults to"family_default"
.
-
property
max_after_balance_size
¶ Maximum relative size of the training data after balancing class counts (can be less than 1.0). Requires balance_classes.
Type:
float
, defaults to5.0
.
-
property
max_iterations
¶ Maximum number of iterations
Type:
int
, defaults to0
.
-
property
max_runtime_secs
¶ Maximum allowed runtime in seconds for model training. Use 0 to disable.
Type:
float
, defaults to0.0
.
-
property
missing_values_handling
¶ Handling of missing values. Either MeanImputation, Skip or PlugValues.
Type:
Literal["mean_imputation", "skip", "plug_values"]
, defaults to"mean_imputation"
.
-
property
non_negative
¶ Restrict coefficients (not intercept) to be non-negative
Type:
bool
, defaults toFalse
.
-
property
nparallelism
¶ Number of models to build in parallel. Default to 4. Adjust according to your system.
Type:
int
, defaults to4
.
-
property
offset_column
¶ Offset column. This will be added to the combination of columns before applying the link function.
Type:
str
.
-
property
plug_values
¶ Plug Values (a single row frame containing values that will be used to impute missing values of the training/validation frame, use with conjunction missing_values_handling = PlugValues)
Type:
Union[None, str, H2OFrame]
.
-
property
prior
¶ Prior probability for y==1. To be used only for logistic regression iff the data has been sampled and the mean of response does not reflect reality.
Type:
float
, defaults to0.0
.
-
property
response_column
¶ Response variable column.
Type:
str
.
-
result
()[source]¶ Get result frame that contains information about the model building process like for modelselection and anovaglm. :return: the H2OFrame that contains information about the model building process like for modelselection and anovaglm.
-
property
save_transformed_framekeys
¶ true to save the keys of transformed predictors and interaction column.
Type:
bool
, defaults toFalse
.
-
property
score_each_iteration
¶ Whether to score during each iteration of model training.
Type:
bool
, defaults toFalse
.
-
property
seed
¶ Seed for pseudo random number generator (if applicable)
Type:
int
, defaults to-1
.
-
property
solver
¶ AUTO will set the solver based on given data and the other parameters. IRLSM is fast on on problems with small number of predictors and for lambda-search with L1 penalty, L_BFGS scales better for datasets with many columns.
Type:
Literal["auto", "irlsm", "l_bfgs", "coordinate_descent_naive", "coordinate_descent", "gradient_descent_lh", "gradient_descent_sqerr"]
, defaults to"irlsm"
.
-
property
standardize
¶ Standardize numeric columns to have zero mean and unit variance
Type:
bool
, defaults toTrue
.
-
property
stopping_metric
¶ Metric to use for early stopping (AUTO: logloss for classification, deviance for regression and anomaly_score for Isolation Forest). Note that custom and custom_increasing can only be used in GBM and DRF with the Python client.
Type:
Literal["auto", "deviance", "logloss", "mse", "rmse", "mae", "rmsle", "auc", "aucpr", "lift_top_group", "misclassification", "mean_per_class_error", "custom", "custom_increasing"]
, defaults to"auto"
.
-
property
stopping_rounds
¶ Early stopping based on convergence of stopping_metric. Stop if simple moving average of length k of the stopping_metric does not improve for k:=stopping_rounds scoring events (0 to disable)
Type:
int
, defaults to0
.
-
property
stopping_tolerance
¶ Relative tolerance for metric-based stopping criterion (stop if relative improvement is not at least this much)
Type:
float
, defaults to0.001
.
-
property
theta
¶ Theta
Type:
float
, defaults to0.0
.
-
property
training_frame
¶ Id of the training data frame.
Type:
Union[None, str, H2OFrame]
.
-
property
tweedie_link_power
¶ Tweedie link power
Type:
float
, defaults to1.0
.
-
property
tweedie_variance_power
¶ Tweedie variance power
Type:
float
, defaults to0.0
.
-
property
type
¶ Refer to the SS type 1, 2, 3, or 4. We are currently only supporting 3
Type:
int
, defaults to0
.
-
property
weights_column
¶ Column with observation weights. Giving some observation a weight of zero is equivalent to excluding it from the dataset; giving an observation a relative weight of 2 is equivalent to repeating that row twice. Negative weights are not allowed. Note: Weights are per-row observation weights and do not increase the size of the data frame. This is typically the number of times a row is repeated, but non-integer values are supported as well. During training, rows with higher weights matter more, due to the larger loss function pre-factor. If you set weight = 0 for a row, the returned prediction frame at that row is zero and this is incorrect. To get an accurate prediction, remove all rows with weight == 0.
Type:
str
.
-
property
H2OCoxProportionalHazardsEstimator
¶
-
class
h2o.estimators.coxph.
H2OCoxProportionalHazardsEstimator
(model_id=None, training_frame=None, start_column=None, stop_column=None, response_column=None, ignored_columns=None, weights_column=None, offset_column=None, stratify_by=None, ties='efron', init=0.0, lre_min=9.0, max_iterations=20, interactions=None, interaction_pairs=None, interactions_only=None, use_all_factor_levels=False, export_checkpoints_dir=None, single_node_mode=False)[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
Cox Proportional Hazards
Trains a Cox Proportional Hazards Model (CoxPH) on an H2O dataset.
-
property
export_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.- Examples
>>> import tempfile >>> from os import listdir >>> heart = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/coxph_test/heart.csv") >>> predictor = "age" >>> response = "event" >>> checkpoints_dir = tempfile.mkdtemp() >>> coxph = H2OCoxProportionalHazardsEstimator(start_column="start", ... stop_column="stop", ... export_checkpoints_dir=checkpoints_dir) >>> coxph.train(x=predictor, ... y=response, ... training_frame=heart) >>> len(listdir(checkpoints_dir))
-
property
ignored_columns
¶ Names of columns to ignore for training.
Type:
List[str]
.
-
property
init
¶ Coefficient starting value.
Type:
float
, defaults to0.0
.- Examples
>>> heart = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/coxph_test/heart.csv") >>> predictor = "age" >>> response = "event" >>> heart_coxph = H2OCoxProportionalHazardsEstimator(start_column="start", ... stop_column="stop", ... init=2.9) >>> heart_coxph.train(x=predictor, ... y=response, ... training_frame=heart) >>> heart_coxph.scoring_history()
-
property
interaction_pairs
¶ A list of pairwise (first order) column interactions.
Type:
List[tuple]
.- Examples
>>> heart = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/coxph_test/heart.csv") >>> predictor = "age" >>> response = "event" >>> interaction_pairs = [("start","stop")] >>> heart_coxph = H2OCoxProportionalHazardsEstimator(start_column="start", ... stop_column="stop", ... interaction_pairs=interaction_pairs) >>> heart_coxph.train(x=predictor, ... y=response, ... training_frame=heart) >>> heart_coxph.scoring_history()
-
property
interactions
¶ A list of predictor column indices to interact. All pairwise combinations will be computed for the list.
Type:
List[str]
.- Examples
>>> heart = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/coxph_test/heart.csv") >>> predictor = "age" >>> response = "event" >>> interactions = ['start','stop'] >>> heart_coxph = H2OCoxProportionalHazardsEstimator(start_column="start", ... stop_column="stop", ... interactions=interactions) >>> heart_coxph.train(x=predictor, ... y=response, ... training_frame=heart) >>> heart_coxph.scoring_history()
-
property
interactions_only
¶ A list of columns that should only be used to create interactions but should not itself participate in model training.
Type:
List[str]
.- Examples
>>> heart = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/coxph_test/heart.csv") >>> predictor = "age" >>> response = "event" >>> interactions = ['start','stop'] >>> heart_coxph = H2OCoxProportionalHazardsEstimator(start_column="start", ... stop_column="stop", ... interactions_only=interactions) >>> heart_coxph.train(x=predictor, ... y=response, ... training_frame=heart) >>> heart_coxph.scoring_history()
-
property
lre_min
¶ Minimum log-relative error.
Type:
float
, defaults to9.0
.- Examples
>>> heart = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/coxph_test/heart.csv") >>> predictor = "age" >>> response = "event" >>> heart_coxph = H2OCoxProportionalHazardsEstimator(start_column="start", ... stop_column="stop", ... lre_min=5) >>> heart_coxph.train(x=predictor, ... y=response, ... training_frame=heart) >>> heart_coxph.scoring_history()
-
property
max_iterations
¶ Maximum number of iterations.
Type:
int
, defaults to20
.- Examples
>>> heart = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/coxph_test/heart.csv") >>> predictor = "age" >>> response = "event" >>> heart_coxph = H2OCoxProportionalHazardsEstimator(start_column="start", ... stop_column="stop", ... max_iterations=50) >>> heart_coxph.train(x=predictor, ... y=response, ... training_frame=heart) >>> heart_coxph.scoring_history()
-
property
offset_column
¶ Offset column. This will be added to the combination of columns before applying the link function.
Type:
str
.- Examples
>>> heart = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/coxph_test/heart.csv") >>> predictor = "age" >>> response = "event" >>> heart_coxph = H2OCoxProportionalHazardsEstimator(start_column="start", ... stop_column="stop", ... offset_column="transplant") >>> heart_coxph.train(x=predictor, ... y=response, ... training_frame=heart) >>> heart_coxph.scoring_history()
-
property
response_column
¶ Response variable column.
Type:
str
.
-
property
single_node_mode
¶ Run on a single node to reduce the effect of network overhead (for smaller datasets)
Type:
bool
, defaults toFalse
.
-
property
start_column
¶ Start Time Column.
Type:
str
.- Examples
>>> heart = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/coxph_test/heart.csv") >>> predictor = "age" >>> response = "event" >>> train, valid = heart.split_frame(ratios=[.8]) >>> heart_coxph = H2OCoxProportionalHazardsEstimator(start_column="start", ... stop_column="stop") >>> heart_coxph.train(x=predictor, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> heart_coxph.scoring_history()
-
property
stop_column
¶ Stop Time Column.
Type:
str
.- Examples
>>> heart = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/coxph_test/heart.csv") >>> predictor = "age" >>> response = "event" >>> train, valid = heart.split_frame(ratios=[.8]) >>> heart_coxph = H2OCoxProportionalHazardsEstimator(start_column="start", ... stop_column="stop") >>> heart_coxph.train(x=predictor, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> heart_coxph.scoring_history()
-
property
stratify_by
¶ List of columns to use for stratification.
Type:
List[str]
.
-
property
ties
¶ Method for Handling Ties.
Type:
Literal["efron", "breslow"]
, defaults to"efron"
.- Examples
>>> heart = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/coxph_test/heart.csv") >>> predictor = "age" >>> response = "event" >>> train, valid = heart.split_frame(ratios=[.8]) >>> heart_coxph = H2OCoxProportionalHazardsEstimator(start_column="start", ... stop_column="stop", ... ties="breslow") >>> heart_coxph.train(x=predictor, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> heart_coxph.scoring_history()
-
property
training_frame
¶ Id of the training data frame.
Type:
Union[None, str, H2OFrame]
.- Examples
>>> heart = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/coxph_test/heart.csv") >>> predictor = "age" >>> response = "event" >>> train, valid = heart.split_frame(ratios=[.8]) >>> heart_coxph = H2OCoxProportionalHazardsEstimator(start_column="start", ... stop_column="stop") >>> heart_coxph.train(x=predictor, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> heart_coxph.scoring_history()
-
property
use_all_factor_levels
¶ (Internal. For development only!) Indicates whether to use all factor levels.
Type:
bool
, defaults toFalse
.- Examples
>>> heart = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/coxph_test/heart.csv") >>> predictor = "age" >>> response = "event" >>> heart_coxph = H2OCoxProportionalHazardsEstimator(start_column="start", ... stop_column="stop", ... use_all_factor_levels=True) >>> heart_coxph.train(x=predictor, ... y=response, ... training_frame=heart) >>> heart_coxph.scoring_history()
-
property
weights_column
¶ Column with observation weights. Giving some observation a weight of zero is equivalent to excluding it from the dataset; giving an observation a relative weight of 2 is equivalent to repeating that row twice. Negative weights are not allowed. Note: Weights are per-row observation weights and do not increase the size of the data frame. This is typically the number of times a row is repeated, but non-integer values are supported as well. During training, rows with higher weights matter more, due to the larger loss function pre-factor. If you set weight = 0 for a row, the returned prediction frame at that row is zero and this is incorrect. To get an accurate prediction, remove all rows with weight == 0.
Type:
str
.
-
property
H2ODecisionTreeEstimator
¶
-
class
h2o.estimators.decision_tree.
H2ODecisionTreeEstimator
(model_id=None, training_frame=None, ignored_columns=None, ignore_const_cols=True, categorical_encoding='auto', response_column=None, seed=-1, max_depth=20, min_rows=10)[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
Decision Tree
Builds a Decision Tree (DT) on a preprocessed dataset.
-
property
categorical_encoding
¶ Encoding scheme for categorical features
Type:
Literal["auto", "enum", "one_hot_internal", "one_hot_explicit", "binary", "eigen", "label_encoder", "sort_by_response", "enum_limited"]
, defaults to"auto"
.
-
property
ignore_const_cols
¶ Ignore constant columns.
Type:
bool
, defaults toTrue
.
-
property
ignored_columns
¶ Names of columns to ignore for training.
Type:
List[str]
.
-
property
max_depth
¶ Max depth of tree.
Type:
int
, defaults to20
.
-
property
min_rows
¶ Fewest allowed (weighted) observations in a leaf.
Type:
int
, defaults to10
.
-
property
response_column
¶ Response variable column.
Type:
str
.
-
property
seed
¶ Seed for random numbers (affects sampling)
Type:
int
, defaults to-1
.
-
property
training_frame
¶ Id of the training data frame.
Type:
Union[None, str, H2OFrame]
.
-
property
H2ODeepLearningEstimator
¶
-
class
h2o.estimators.deeplearning.
H2ODeepLearningEstimator
(model_id=None, training_frame=None, validation_frame=None, nfolds=0, keep_cross_validation_models=True, keep_cross_validation_predictions=False, keep_cross_validation_fold_assignment=False, fold_assignment='auto', fold_column=None, response_column=None, ignored_columns=None, ignore_const_cols=True, score_each_iteration=False, weights_column=None, offset_column=None, balance_classes=False, class_sampling_factors=None, max_after_balance_size=5.0, max_confusion_matrix_size=20, checkpoint=None, pretrained_autoencoder=None, overwrite_with_best_model=True, use_all_factor_levels=True, standardize=True, activation='rectifier', hidden=[200, 200], epochs=10.0, train_samples_per_iteration=-2, target_ratio_comm_to_comp=0.05, seed=-1, adaptive_rate=True, rho=0.99, epsilon=1e-08, rate=0.005, rate_annealing=1e-06, rate_decay=1.0, momentum_start=0.0, momentum_ramp=1000000.0, momentum_stable=0.0, nesterov_accelerated_gradient=True, input_dropout_ratio=0.0, hidden_dropout_ratios=None, l1=0.0, l2=0.0, max_w2=3.4028235e+38, initial_weight_distribution='uniform_adaptive', initial_weight_scale=1.0, initial_weights=None, initial_biases=None, loss='automatic', distribution='auto', quantile_alpha=0.5, tweedie_power=1.5, huber_alpha=0.9, score_interval=5.0, score_training_samples=10000, score_validation_samples=0, score_duty_cycle=0.1, classification_stop=0.0, regression_stop=1e-06, stopping_rounds=5, stopping_metric='auto', stopping_tolerance=0.0, max_runtime_secs=0.0, score_validation_sampling='uniform', diagnostics=True, fast_mode=True, force_load_balance=True, variable_importances=True, replicate_training_data=True, single_node_mode=False, shuffle_training_data=False, missing_values_handling='mean_imputation', quiet_mode=False, autoencoder=False, sparse=False, col_major=False, average_activation=0.0, sparsity_beta=0.0, max_categorical_features=2147483647, reproducible=False, export_weights_and_biases=False, mini_batch_size=1, categorical_encoding='auto', elastic_averaging=False, elastic_averaging_moving_rate=0.9, elastic_averaging_regularization=0.001, export_checkpoints_dir=None, auc_type='auto')[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
Deep Learning
Build a Deep Neural Network model using CPUs Builds a feed-forward multilayer artificial neural network on an H2OFrame
- Examples
>>> from h2o.estimators.deeplearning import H2ODeepLearningEstimator >>> rows = [[1,2,3,4,0], [2,1,2,4,1], [2,1,4,2,1], ... [0,1,2,34,1], [2,3,4,1,0]] * 50 >>> fr = h2o.H2OFrame(rows) >>> fr[4] = fr[4].asfactor() >>> model = H2ODeepLearningEstimator() >>> model.train(x=range(4), y=4, training_frame=fr) >>> model.logloss()
-
property
activation
¶ Activation function.
Type:
Literal["tanh", "tanh_with_dropout", "rectifier", "rectifier_with_dropout", "maxout", "maxout_with_dropout"]
, defaults to"rectifier"
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> cars_dl = H2ODeepLearningEstimator(activation="tanh") >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
-
property
adaptive_rate
¶ Adaptive learning rate.
Type:
bool
, defaults toTrue
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> cars_dl = H2ODeepLearningEstimator(adaptive_rate=True) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
-
property
auc_type
¶ Set default multinomial AUC type.
Type:
Literal["auto", "none", "macro_ovr", "weighted_ovr", "macro_ovo", "weighted_ovo"]
, defaults to"auto"
.
-
property
autoencoder
¶ Auto-Encoder.
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> cars_dl = H2ODeepLearningEstimator(autoencoder=True) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
-
property
average_activation
¶ Average activation for sparse auto-encoder. #Experimental
Type:
float
, defaults to0.0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> cars_dl = H2ODeepLearningEstimator(average_activation=1.5, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
-
property
balance_classes
¶ Balance training data class counts via over/under-sampling (for imbalanced data).
Type:
bool
, defaults toFalse
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> predictors = covtype.columns[0:54] >>> response = 'C55' >>> train, valid = covtype.split_frame(ratios=[.8], seed=1234) >>> cov_dl = H2ODeepLearningEstimator(balance_classes=True, ... seed=1234) >>> cov_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cov_dl.mse()
-
property
categorical_encoding
¶ Encoding scheme for categorical features
Type:
Literal["auto", "enum", "one_hot_internal", "one_hot_explicit", "binary", "eigen", "label_encoder", "sort_by_response", "enum_limited"]
, defaults to"auto"
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"]= airlines["Year"].asfactor() >>> airlines["Month"]= airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8], seed=1234) >>> encoding = "one_hot_internal" >>> airlines_dl = H2ODeepLearningEstimator(categorical_encoding=encoding, ... seed=1234) >>> airlines_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_dl.mse()
-
property
checkpoint
¶ Model checkpoint to resume training with.
Type:
Union[None, str, H2OEstimator]
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(activation="tanh", ... autoencoder=True, ... seed=1234, ... model_id="cars_dl") >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse() >>> cars_cont = H2ODeepLearningEstimator(checkpoint=cars_dl, ... seed=1234) >>> cars_cont.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_cont.mse()
-
property
class_sampling_factors
¶ Desired over/under-sampling ratios per class (in lexicographic order). If not specified, sampling factors will be automatically computed to obtain class balance during training. Requires balance_classes.
Type:
List[float]
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> predictors = covtype.columns[0:54] >>> response = 'C55' >>> train, valid = covtype.split_frame(ratios=[.8], seed=1234) >>> sample_factors = [1., 0.5, 1., 1., 1., 1., 1.] >>> cars_dl = H2ODeepLearningEstimator(balance_classes=True, ... class_sampling_factors=sample_factors, ... seed=1234) >>> cov_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cov_dl.mse()
-
property
classification_stop
¶ Stopping criterion for classification error fraction on training data (-1 to disable).
Type:
float
, defaults to0.0
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> predictors = covtype.columns[0:54] >>> response = 'C55' >>> train, valid = covtype.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(classification_stop=1.5, ... seed=1234) >>> cov_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cov_dl.mse()
-
property
col_major
¶ #DEPRECATED Use a column major weight matrix for input layer. Can speed up forward propagation, but might slow down backpropagation.
Type:
bool
, defaults toFalse
.
-
property
diagnostics
¶ Enable diagnostics for hidden layers.
Type:
bool
, defaults toTrue
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> predictors = covtype.columns[0:54] >>> response = 'C55' >>> train, valid = covtype.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(diagnostics=True, ... seed=1234) >>> cov_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cov_dl.mse()
-
property
distribution
¶ Distribution function
Type:
Literal["auto", "bernoulli", "multinomial", "gaussian", "poisson", "gamma", "tweedie", "laplace", "quantile", "huber"]
, defaults to"auto"
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(distribution="poisson", ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
-
property
elastic_averaging
¶ Elastic averaging between compute nodes can improve distributed model convergence. #Experimental
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(elastic_averaging=True, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
-
property
elastic_averaging_moving_rate
¶ Elastic averaging moving rate (only if elastic averaging is enabled).
Type:
float
, defaults to0.9
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(elastic_averaging_moving_rate=.8, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
-
property
elastic_averaging_regularization
¶ Elastic averaging regularization strength (only if elastic averaging is enabled).
Type:
float
, defaults to0.001
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(elastic_averaging_regularization=.008, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
-
property
epochs
¶ How many times the dataset should be iterated (streamed), can be fractional.
Type:
float
, defaults to10.0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(epochs=15, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
-
property
epsilon
¶ Adaptive learning rate smoothing factor (to avoid divisions by zero and allow progress).
Type:
float
, defaults to1e-08
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(epsilon=1e-6, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
-
property
export_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.- Examples
>>> import tempfile >>> from os import listdir >>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> checkpoints_dir = tempfile.mkdtemp() >>> cars_dl = H2ODeepLearningEstimator(export_checkpoints_dir=checkpoints_dir, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> len(listdir(checkpoints_dir))
-
property
export_weights_and_biases
¶ Whether to export Neural Network weights and biases to H2O Frames.
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(export_weights_and_biases=True, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
-
property
fast_mode
¶ Enable fast mode (minor approximation in back-propagation).
Type:
bool
, defaults toTrue
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(fast_mode=False, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
-
property
fold_assignment
¶ Cross-validation fold assignment scheme, if fold_column is not specified. The ‘Stratified’ option will stratify the folds based on the response variable, for classification problems.
Type:
Literal["auto", "random", "modulo", "stratified"]
, defaults to"auto"
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(fold_assignment="Random", ... nfolds=5, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
-
property
fold_column
¶ Column with cross-validation fold index assignment per observation.
Type:
str
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> fold_numbers = cars.kfold_column(n_folds=5, seed=1234) >>> fold_numbers.set_names(["fold_numbers"]) >>> cars = cars.cbind(fold_numbers) >>> print(cars['fold_numbers']) >>> cars_dl = H2ODeepLearningEstimator(seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=cars, ... fold_column="fold_numbers") >>> cars_dl.mse()
-
property
force_load_balance
¶ Force extra load balancing to increase training speed for small datasets (to keep all cores busy).
Type:
bool
, defaults toTrue
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(force_load_balance=False, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
Hidden layer sizes (e.g. [100, 100]).
Type:
List[int]
, defaults to[200, 200]
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "cylinders" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(hidden=[100,100], ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.mse()
Hidden layer dropout ratios (can improve generalization), specify one value per hidden layer, defaults to 0.5.
Type:
List[float]
.- Examples
>>> train = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/mnist/train.csv.gz") >>> valid = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/mnist/test.csv.gz") >>> features = list(range(0,784)) >>> target = 784 >>> train[target] = train[target].asfactor() >>> valid[target] = valid[target].asfactor() >>> model = H2ODeepLearningEstimator(epochs=20, ... hidden=[200,200], ... hidden_dropout_ratios=[0.5,0.5], ... seed=1234, ... activation='tanhwithdropout') >>> model.train(x=features, ... y=target, ... training_frame=train, ... validation_frame=valid) >>> model.mse()
-
property
huber_alpha
¶ Desired quantile for Huber/M-regression (threshold between quadratic and linear loss, must be between 0 and 1).
Type:
float
, defaults to0.9
.- Examples
>>> insurance = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/glm_test/insurance.csv") >>> predictors = insurance.columns[0:4] >>> response = 'Claims' >>> insurance['Group'] = insurance['Group'].asfactor() >>> insurance['Age'] = insurance['Age'].asfactor() >>> train, valid = insurance.split_frame(ratios=[.8], seed=1234) >>> insurance_dl = H2ODeepLearningEstimator(distribution="huber", ... huber_alpha=0.9, ... seed=1234) >>> insurance_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> insurance_dl.mse()
-
property
ignore_const_cols
¶ Ignore constant columns.
Type:
bool
, defaults toTrue
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> cars["const_1"] = 6 >>> cars["const_2"] = 7 >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(seed=1234, ... ignore_const_cols=True) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.auc()
-
property
ignored_columns
¶ Names of columns to ignore for training.
Type:
List[str]
.
-
property
initial_biases
¶ A list of H2OFrame ids to initialize the bias vectors of this model with.
Type:
List[Union[None, str, H2OFrame]]
.- Examples
>>> iris = h2o.import_file("http://h2o-public-test-data.s3.amazonaws.com/smalldata/iris/iris.csv") >>> dl1 = H2ODeepLearningEstimator(hidden=[10,10], ... export_weights_and_biases=True) >>> dl1.train(x=list(range(4)), y=4, training_frame=iris) >>> p1 = dl1.model_performance(iris).logloss() >>> ll1 = dl1.predict(iris) >>> print(p1) >>> w1 = dl1.weights(0) >>> w2 = dl1.weights(1) >>> w3 = dl1.weights(2) >>> b1 = dl1.biases(0) >>> b2 = dl1.biases(1) >>> b3 = dl1.biases(2) >>> dl2 = H2ODeepLearningEstimator(hidden=[10,10], ... initial_weights=[w1, w2, w3], ... initial_biases=[b1, b2, b3], ... epochs=0) >>> dl2.train(x=list(range(4)), y=4, training_frame=iris) >>> dl2.initial_biases
-
property
initial_weight_distribution
¶ Initial weight distribution.
Type:
Literal["uniform_adaptive", "uniform", "normal"]
, defaults to"uniform_adaptive"
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(initial_weight_distribution="Uniform", ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.auc()
-
property
initial_weight_scale
¶ Uniform: -value…value, Normal: stddev.
Type:
float
, defaults to1.0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(initial_weight_scale=1.5, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.auc()
-
property
initial_weights
¶ A list of H2OFrame ids to initialize the weight matrices of this model with.
Type:
List[Union[None, str, H2OFrame]]
.- Examples
>>> iris = h2o.import_file("http://h2o-public-test-data.s3.amazonaws.com/smalldata/iris/iris.csv") >>> dl1 = H2ODeepLearningEstimator(hidden=[10,10], ... export_weights_and_biases=True) >>> dl1.train(x=list(range(4)), y=4, training_frame=iris) >>> p1 = dl1.model_performance(iris).logloss() >>> ll1 = dl1.predict(iris) >>> print(p1) >>> w1 = dl1.weights(0) >>> w2 = dl1.weights(1) >>> w3 = dl1.weights(2) >>> b1 = dl1.biases(0) >>> b2 = dl1.biases(1) >>> b3 = dl1.biases(2) >>> dl2 = H2ODeepLearningEstimator(hidden=[10,10], ... initial_weights=[w1, w2, w3], ... initial_biases=[b1, b2, b3], ... epochs=0) >>> dl2.train(x=list(range(4)), y=4, training_frame=iris) >>> dl2.initial_weights
-
property
input_dropout_ratio
¶ Input layer dropout ratio (can improve generalization, try 0.1 or 0.2).
Type:
float
, defaults to0.0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(input_dropout_ratio=0.2, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.auc()
-
property
keep_cross_validation_fold_assignment
¶ Whether to keep the cross-validation fold assignment.
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> cars_dl = H2ODeepLearningEstimator(keep_cross_validation_fold_assignment=True, ... nfolds=5, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=cars) >>> print(cars_dl.cross_validation_fold_assignment())
-
property
keep_cross_validation_models
¶ Whether to keep the cross-validation models.
Type:
bool
, defaults toTrue
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> cars_dl = H2ODeepLearningEstimator(keep_cross_validation_models=True, ... nfolds=5, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=cars) >>> print(cars_dl.cross_validation_models())
-
property
keep_cross_validation_predictions
¶ Whether to keep the predictions of the cross-validation models.
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> cars_dl = H2ODeepLearningEstimator(keep_cross_validation_predictions=True, ... nfolds=5, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=cars) >>> print(cars_dl.cross_validation_predictions())
-
property
l1
¶ L1 regularization (can add stability and improve generalization, causes many weights to become 0).
Type:
float
, defaults to0.0
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> hh_imbalanced = H2ODeepLearningEstimator(l1=1e-5, ... activation="Rectifier", ... loss="CrossEntropy", ... hidden=[200,200], ... epochs=1, ... balance_classes=False, ... reproducible=True, ... seed=1234) >>> hh_imbalanced.train(x=list(range(54)),y=54, training_frame=covtype) >>> hh_imbalanced.mse()
-
property
l2
¶ L2 regularization (can add stability and improve generalization, causes many weights to be small.
Type:
float
, defaults to0.0
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> hh_imbalanced = H2ODeepLearningEstimator(l2=1e-5, ... activation="Rectifier", ... loss="CrossEntropy", ... hidden=[200,200], ... epochs=1, ... balance_classes=False, ... reproducible=True, ... seed=1234) >>> hh_imbalanced.train(x=list(range(54)),y=54, training_frame=covtype) >>> hh_imbalanced.mse()
-
property
loss
¶ Loss function.
Type:
Literal["automatic", "cross_entropy", "quadratic", "huber", "absolute", "quantile"]
, defaults to"automatic"
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> hh_imbalanced = H2ODeepLearningEstimator(l1=1e-5, ... activation="Rectifier", ... loss="CrossEntropy", ... hidden=[200,200], ... epochs=1, ... balance_classes=False, ... reproducible=True, ... seed=1234) >>> hh_imbalanced.train(x=list(range(54)),y=54, training_frame=covtype) >>> hh_imbalanced.mse()
-
property
max_after_balance_size
¶ Maximum relative size of the training data after balancing class counts (can be less than 1.0). Requires balance_classes.
Type:
float
, defaults to5.0
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> predictors = covtype.columns[0:54] >>> response = 'C55' >>> train, valid = covtype.split_frame(ratios=[.8], seed=1234) >>> max = .85 >>> cov_dl = H2ODeepLearningEstimator(balance_classes=True, ... max_after_balance_size=max, ... seed=1234) >>> cov_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cov_dl.logloss()
-
property
max_categorical_features
¶ Max. number of categorical features, enforced via hashing. #Experimental
Type:
int
, defaults to2147483647
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> predictors = covtype.columns[0:54] >>> response = 'C55' >>> train, valid = covtype.split_frame(ratios=[.8], seed=1234) >>> cov_dl = H2ODeepLearningEstimator(balance_classes=True, ... max_categorical_features=2147483647, ... seed=1234) >>> cov_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cov_dl.logloss()
-
property
max_confusion_matrix_size
¶ [Deprecated] Maximum size (# classes) for confusion matrices to be printed in the Logs.
Type:
int
, defaults to20
.
-
property
max_runtime_secs
¶ Maximum allowed runtime in seconds for model training. Use 0 to disable.
Type:
float
, defaults to0.0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(max_runtime_secs=10, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.auc()
-
property
max_w2
¶ Constraint for squared sum of incoming weights per unit (e.g. for Rectifier).
Type:
float
, defaults to3.4028235e+38
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> predictors = covtype.columns[0:54] >>> response = 'C55' >>> train, valid = covtype.split_frame(ratios=[.8], seed=1234) >>> cov_dl = H2ODeepLearningEstimator(activation="RectifierWithDropout", ... hidden=[10,10], ... epochs=10, ... input_dropout_ratio=0.2, ... l1=1e-5, ... max_w2=10.5, ... stopping_rounds=0) >>> cov_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cov_dl.mse()
-
property
mini_batch_size
¶ Mini-batch size (smaller leads to better fit, larger can speed up and generalize better).
Type:
int
, defaults to1
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> predictors = covtype.columns[0:54] >>> response = 'C55' >>> train, valid = covtype.split_frame(ratios=[.8], seed=1234) >>> cov_dl = H2ODeepLearningEstimator(activation="RectifierWithDropout", ... hidden=[10,10], ... epochs=10, ... input_dropout_ratio=0.2, ... l1=1e-5, ... max_w2=10.5, ... stopping_rounds=0) ... mini_batch_size=35 >>> cov_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cov_dl.mse()
-
property
missing_values_handling
¶ Handling of missing values. Either MeanImputation or Skip.
Type:
Literal["mean_imputation", "skip"]
, defaults to"mean_imputation"
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> boston.insert_missing_values() >>> train, valid = boston.split_frame(ratios=[.8]) >>> boston_dl = H2ODeepLearningEstimator(missing_values_handling="skip") >>> boston_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> boston_dl.mse()
-
property
momentum_ramp
¶ Number of training samples for which momentum increases.
Type:
float
, defaults to1000000.0
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> predictors = ["Year","Month","DayofMonth","DayOfWeek","CRSDepTime", ... "CRSArrTime","UniqueCarrier","FlightNum"] >>> response_col = "IsDepDelayed" >>> airlines_dl = H2ODeepLearningEstimator(hidden=[200,200], ... activation="Rectifier", ... input_dropout_ratio=0.0, ... momentum_start=0.9, ... momentum_stable=0.99, ... momentum_ramp=1e7, ... epochs=100, ... stopping_rounds=4, ... train_samples_per_iteration=30000, ... mini_batch_size=32, ... score_duty_cycle=0.25, ... score_interval=1) >>> airlines_dl.train(x=predictors, ... y=response_col, ... training_frame=airlines) >>> airlines_dl.mse()
-
property
momentum_stable
¶ Final momentum after the ramp is over (try 0.99).
Type:
float
, defaults to0.0
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> predictors = ["Year","Month","DayofMonth","DayOfWeek","CRSDepTime", ... "CRSArrTime","UniqueCarrier","FlightNum"] >>> response_col = "IsDepDelayed" >>> airlines_dl = H2ODeepLearningEstimator(hidden=[200,200], ... activation="Rectifier", ... input_dropout_ratio=0.0, ... momentum_start=0.9, ... momentum_stable=0.99, ... momentum_ramp=1e7, ... epochs=100, ... stopping_rounds=4, ... train_samples_per_iteration=30000, ... mini_batch_size=32, ... score_duty_cycle=0.25, ... score_interval=1) >>> airlines_dl.train(x=predictors, ... y=response_col, ... training_frame=airlines) >>> airlines_dl.mse()
-
property
momentum_start
¶ Initial momentum at the beginning of training (try 0.5).
Type:
float
, defaults to0.0
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> predictors = ["Year","Month","DayofMonth","DayOfWeek","CRSDepTime", ... "CRSArrTime","UniqueCarrier","FlightNum"] >>> response_col = "IsDepDelayed" >>> airlines_dl = H2ODeepLearningEstimator(hidden=[200,200], ... activation="Rectifier", ... input_dropout_ratio=0.0, ... momentum_start=0.9, ... momentum_stable=0.99, ... momentum_ramp=1e7, ... epochs=100, ... stopping_rounds=4, ... train_samples_per_iteration=30000, ... mini_batch_size=32, ... score_duty_cycle=0.25, ... score_interval=1) >>> airlines_dl.train(x=predictors, ... y=response_col, ... training_frame=airlines) >>> airlines_dl.mse()
-
property
nesterov_accelerated_gradient
¶ Use Nesterov accelerated gradient (recommended).
Type:
bool
, defaults toTrue
.- Examples
>>> train = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/mnist/train.csv.gz") >>> test = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/mnist/test.csv.gz") >>> predictors = list(range(0,784)) >>> resp = 784 >>> train[resp] = train[resp].asfactor() >>> test[resp] = test[resp].asfactor() >>> nclasses = train[resp].nlevels()[0] >>> model = H2ODeepLearningEstimator(activation="RectifierWithDropout", ... adaptive_rate=False, ... rate=0.01, ... rate_decay=0.9, ... rate_annealing=1e-6, ... momentum_start=0.95, ... momentum_ramp=1e5, ... momentum_stable=0.99, ... nesterov_accelerated_gradient=False, ... input_dropout_ratio=0.2, ... train_samples_per_iteration=20000, ... classification_stop=-1, ... l1=1e-5) >>> model.train (x=predictors, ... y=resp, ... training_frame=train, ... validation_frame=test) >>> model.model_performance()
-
property
nfolds
¶ Number of folds for K-fold cross-validation (0 to disable or >= 2).
Type:
int
, defaults to0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> cars_dl = H2ODeepLearningEstimator(nfolds=5, seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=cars) >>> cars_dl.auc()
-
property
offset_column
¶ Offset column. This will be added to the combination of columns before applying the link function.
Type:
str
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> boston["offset"] = boston["medv"].log() >>> train, valid = boston.split_frame(ratios=[.8], seed=1234) >>> boston_dl = H2ODeepLearningEstimator(offset_column="offset", ... seed=1234) >>> boston_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> boston_dl.mse()
-
property
overwrite_with_best_model
¶ If enabled, override the final model with the best model found during training.
Type:
bool
, defaults toTrue
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> boston["offset"] = boston["medv"].log() >>> train, valid = boston.split_frame(ratios=[.8], seed=1234) >>> boston_dl = H2ODeepLearningEstimator(overwrite_with_best_model=True, ... seed=1234) >>> boston_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> boston_dl.mse()
-
property
pretrained_autoencoder
¶ Pretrained autoencoder model to initialize this model with.
Type:
Union[None, str, H2OEstimator]
.- Examples
>>> from h2o.estimators.deeplearning import H2OAutoEncoderEstimator >>> resp = 784 >>> nfeatures = 20 >>> train = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/mnist/train.csv.gz") >>> test = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/mnist/test.csv.gz") >>> train[resp] = train[resp].asfactor() >>> test[resp] = test[resp].asfactor() >>> sid = train[0].runif(0) >>> train_unsupervised = train[sid>=0.5] >>> train_unsupervised.pop(resp) >>> train_supervised = train[sid<0.5] >>> ae_model = H2OAutoEncoderEstimator(activation="Tanh", ... hidden=[nfeatures], ... model_id="ae_model", ... epochs=1, ... ignore_const_cols=False, ... reproducible=True, ... seed=1234) >>> ae_model.train(list(range(resp)), training_frame=train_unsupervised) >>> ae_model.mse() >>> pretrained_model = H2ODeepLearningEstimator(activation="Tanh", ... hidden=[nfeatures], ... epochs=1, ... reproducible = True, ... seed=1234, ... ignore_const_cols=False, ... pretrained_autoencoder="ae_model") >>> pretrained_model.train(list(range(resp)), resp, ... training_frame=train_supervised, ... validation_frame=test) >>> pretrained_model.mse()
-
property
quantile_alpha
¶ Desired quantile for Quantile regression, must be between 0 and 1.
Type:
float
, defaults to0.5
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> train, valid = boston.split_frame(ratios=[.8], seed=1234) >>> boston_dl = H2ODeepLearningEstimator(distribution="quantile", ... quantile_alpha=.8, ... seed=1234) >>> boston_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> boston_dl.mse()
-
property
quiet_mode
¶ Enable quiet mode for less output to standard output.
Type:
bool
, defaults toFalse
.- Examples
>>> titanic = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/titanic.csv") >>> titanic['survived'] = titanic['survived'].asfactor() >>> predictors = titanic.columns >>> del predictors[1:3] >>> response = 'survived' >>> train, valid = titanic.split_frame(ratios=[.8], seed=1234) >>> titanic_dl = H2ODeepLearningEstimator(quiet_mode=True, ... seed=1234) >>> titanic_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> titanic_dl.mse()
-
property
rate
¶ Learning rate (higher => less stable, lower => slower convergence).
Type:
float
, defaults to0.005
.- Examples
>>> train = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/mnist/train.csv.gz") >>> test = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/mnist/test.csv.gz") >>> predictors = list(range(0,784)) >>> resp = 784 >>> train[resp] = train[resp].asfactor() >>> test[resp] = test[resp].asfactor() >>> nclasses = train[resp].nlevels()[0] >>> model = H2ODeepLearningEstimator(activation="RectifierWithDropout", ... adaptive_rate=False, ... rate=0.01, ... rate_decay=0.9, ... rate_annealing=1e-6, ... momentum_start=0.95, ... momentum_ramp=1e5, ... momentum_stable=0.99, ... nesterov_accelerated_gradient=False, ... input_dropout_ratio=0.2, ... train_samples_per_iteration=20000, ... classification_stop=-1, ... l1=1e-5) >>> model.train (x=predictors,y=resp, training_frame=train, validation_frame=test) >>> model.model_performance(valid=True)
-
property
rate_annealing
¶ Learning rate annealing: rate / (1 + rate_annealing * samples).
Type:
float
, defaults to1e-06
.- Examples
>>> train = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/mnist/train.csv.gz") >>> test = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/mnist/test.csv.gz") >>> predictors = list(range(0,784)) >>> resp = 784 >>> train[resp] = train[resp].asfactor() >>> test[resp] = test[resp].asfactor() >>> nclasses = train[resp].nlevels()[0] >>> model = H2ODeepLearningEstimator(activation="RectifierWithDropout", ... adaptive_rate=False, ... rate=0.01, ... rate_decay=0.9, ... rate_annealing=1e-6, ... momentum_start=0.95, ... momentum_ramp=1e5, ... momentum_stable=0.99, ... nesterov_accelerated_gradient=False, ... input_dropout_ratio=0.2, ... train_samples_per_iteration=20000, ... classification_stop=-1, ... l1=1e-5) >>> model.train (x=predictors, ... y=resp, ... training_frame=train, ... validation_frame=test) >>> model.mse()
-
property
rate_decay
¶ Learning rate decay factor between layers (N-th layer: rate * rate_decay ^ (n - 1).
Type:
float
, defaults to1.0
.- Examples
>>> train = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/mnist/train.csv.gz") >>> test = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/mnist/test.csv.gz") >>> predictors = list(range(0,784)) >>> resp = 784 >>> train[resp] = train[resp].asfactor() >>> test[resp] = test[resp].asfactor() >>> nclasses = train[resp].nlevels()[0] >>> model = H2ODeepLearningEstimator(activation="RectifierWithDropout", ... adaptive_rate=False, ... rate=0.01, ... rate_decay=0.9, ... rate_annealing=1e-6, ... momentum_start=0.95, ... momentum_ramp=1e5, ... momentum_stable=0.99, ... nesterov_accelerated_gradient=False, ... input_dropout_ratio=0.2, ... train_samples_per_iteration=20000, ... classification_stop=-1, ... l1=1e-5) >>> model.train (x=predictors, ... y=resp, ... training_frame=train, ... validation_frame=test) >>> model.model_performance()
-
property
regression_stop
¶ Stopping criterion for regression error (MSE) on training data (-1 to disable).
Type:
float
, defaults to1e-06
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"]= airlines["Year"].asfactor() >>> airlines["Month"]= airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_dl = H2ODeepLearningEstimator(regression_stop=1e-6, ... seed=1234) >>> airlines_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_dl.auc()
-
property
replicate_training_data
¶ Replicate the entire training dataset onto every node for faster training on small datasets.
Type:
bool
, defaults toTrue
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"]= airlines["Year"].asfactor() >>> airlines["Month"]= airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> airlines_dl = H2ODeepLearningEstimator(replicate_training_data=False) >>> airlines_dl.train(x=predictors, ... y=response, ... training_frame=airlines) >>> airlines_dl.auc()
-
property
reproducible
¶ Force reproducibility on small data (will be slow - only uses 1 thread).
Type:
bool
, defaults toFalse
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"]= airlines["Year"].asfactor() >>> airlines["Month"]= airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_dl = H2ODeepLearningEstimator(reproducible=True) >>> airlines_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_dl.auc()
-
property
response_column
¶ Response variable column.
Type:
str
.
-
property
rho
¶ Adaptive learning rate time decay factor (similarity to prior updates).
Type:
float
, defaults to0.99
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> cars_dl = H2ODeepLearningEstimator(rho=0.9, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=cars) >>> cars_dl.auc()
-
property
score_duty_cycle
¶ Maximum duty cycle fraction for scoring (lower: more training, higher: more scoring).
Type:
float
, defaults to0.1
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> cars_dl = H2ODeepLearningEstimator(score_duty_cycle=0.2, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=cars) >>> cars_dl.auc()
-
property
score_each_iteration
¶ Whether to score during each iteration of model training.
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> cars_dl = H2ODeepLearningEstimator(score_each_iteration=True, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=cars) >>> cars_dl.auc()
-
property
score_interval
¶ Shortest time interval (in seconds) between model scoring.
Type:
float
, defaults to5.0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> cars_dl = H2ODeepLearningEstimator(score_interval=3, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=cars) >>> cars_dl.auc()
-
property
score_training_samples
¶ Number of training set samples for scoring (0 for all).
Type:
int
, defaults to10000
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> cars_dl = H2ODeepLearningEstimator(score_training_samples=10000, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=cars) >>> cars_dl.auc()
-
property
score_validation_samples
¶ Number of validation set samples for scoring (0 for all).
Type:
int
, defaults to0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(score_validation_samples=3, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.auc()
-
property
score_validation_sampling
¶ Method used to sample validation dataset for scoring.
Type:
Literal["uniform", "stratified"]
, defaults to"uniform"
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(score_validation_sampling="uniform", ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.auc()
-
property
seed
¶ Seed for random numbers (affects sampling) - Note: only reproducible when running single threaded.
Type:
int
, defaults to-1
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.auc()
-
property
shuffle_training_data
¶ Enable shuffling of training data (recommended if training data is replicated and train_samples_per_iteration is close to #nodes x #rows, of if using balance_classes).
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(shuffle_training_data=True, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=cars) >>> cars_dl.auc()
-
property
single_node_mode
¶ Run on a single node for fine-tuning of model parameters.
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(single_node_mode=True, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=cars) >>> cars_dl.auc()
-
property
sparse
¶ Sparse data handling (more efficient for data with lots of 0 values).
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(sparse=True, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=cars) >>> cars_dl.auc()
-
property
sparsity_beta
¶ Sparsity regularization. #Experimental
Type:
float
, defaults to0.0
.- Examples
>>> from h2o.estimators import H2OAutoEncoderEstimator >>> resp = 784 >>> nfeatures = 20 >>> train = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/mnist/train.csv.gz") >>> test = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/mnist/test.csv.gz") >>> train[resp] = train[resp].asfactor() >>> test[resp] = test[resp].asfactor() >>> sid = train[0].runif(0) >>> train_unsupervised = train[sid>=0.5] >>> train_unsupervised.pop(resp) >>> ae_model = H2OAutoEncoderEstimator(activation="Tanh", ... hidden=[nfeatures], ... epochs=1, ... ignore_const_cols=False, ... reproducible=True, ... sparsity_beta=0.5, ... seed=1234) >>> ae_model.train(list(range(resp)), ... training_frame=train_unsupervised) >>> ae_model.mse()
-
property
standardize
¶ If enabled, automatically standardize the data. If disabled, the user must provide properly scaled input data.
Type:
bool
, defaults toTrue
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> cars_dl = H2ODeepLearningEstimator(standardize=True, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=cars) >>> cars_dl.auc()
-
property
stopping_metric
¶ Metric to use for early stopping (AUTO: logloss for classification, deviance for regression and anomaly_score for Isolation Forest). Note that custom and custom_increasing can only be used in GBM and DRF with the Python client.
Type:
Literal["auto", "deviance", "logloss", "mse", "rmse", "mae", "rmsle", "auc", "aucpr", "lift_top_group", "misclassification", "mean_per_class_error", "custom", "custom_increasing"]
, defaults to"auto"
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"]= airlines["Year"].asfactor() >>> airlines["Month"]= airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_dl = H2ODeepLearningEstimator(stopping_metric="auc", ... stopping_rounds=3, ... stopping_tolerance=1e-2, ... seed=1234) >>> airlines_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_dl.auc()
-
property
stopping_rounds
¶ Early stopping based on convergence of stopping_metric. Stop if simple moving average of length k of the stopping_metric does not improve for k:=stopping_rounds scoring events (0 to disable)
Type:
int
, defaults to5
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"]= airlines["Year"].asfactor() >>> airlines["Month"]= airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_dl = H2ODeepLearningEstimator(stopping_metric="auc", ... stopping_rounds=3, ... stopping_tolerance=1e-2, ... seed=1234) >>> airlines_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_dl.auc()
-
property
stopping_tolerance
¶ Relative tolerance for metric-based stopping criterion (stop if relative improvement is not at least this much)
Type:
float
, defaults to0.0
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"]= airlines["Year"].asfactor() >>> airlines["Month"]= airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_dl = H2ODeepLearningEstimator(stopping_metric="auc", ... stopping_rounds=3, ... stopping_tolerance=1e-2, ... seed=1234) >>> airlines_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_dl.auc()
-
property
target_ratio_comm_to_comp
¶ Target ratio of communication overhead to computation. Only for multi-node operation and train_samples_per_iteration = -2 (auto-tuning).
Type:
float
, defaults to0.05
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"]= airlines["Year"].asfactor() >>> airlines["Month"]= airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_dl = H2ODeepLearningEstimator(target_ratio_comm_to_comp=0.05, ... seed=1234) >>> airlines_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_dl.auc()
-
property
train_samples_per_iteration
¶ Number of training samples (globally) per MapReduce iteration. Special values are 0: one epoch, -1: all available data (e.g., replicated training data), -2: automatic.
Type:
int
, defaults to-2
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"]= airlines["Year"].asfactor() >>> airlines["Month"]= airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_dl = H2ODeepLearningEstimator(train_samples_per_iteration=-1, ... epochs=1, ... seed=1234) >>> airlines_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_dl.auc()
-
property
training_frame
¶ Id of the training data frame.
Type:
Union[None, str, H2OFrame]
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"]= airlines["Year"].asfactor() >>> airlines["Month"]= airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_dl = H2ODeepLearningEstimator() >>> airlines_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_dl.auc()
-
property
tweedie_power
¶ Tweedie power for Tweedie regression, must be between 1 and 2.
Type:
float
, defaults to1.5
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"]= airlines["Year"].asfactor() >>> airlines["Month"]= airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_dl = H2ODeepLearningEstimator(tweedie_power=1.5, ... seed=1234) >>> airlines_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_dl.auc()
-
property
use_all_factor_levels
¶ Use all factor levels of categorical variables. Otherwise, the first factor level is omitted (without loss of accuracy). Useful for variable importances and auto-enabled for autoencoder.
Type:
bool
, defaults toTrue
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"]= airlines["Year"].asfactor() >>> airlines["Month"]= airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_dl = H2ODeepLearningEstimator(use_all_factor_levels=True, ... seed=1234) >>> airlines_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_dl.mse()
-
property
validation_frame
¶ Id of the validation data frame.
Type:
Union[None, str, H2OFrame]
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(standardize=True, ... seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.auc()
-
property
variable_importances
¶ Compute variable importances for input features (Gedeon method) - can be slow for large networks.
Type:
bool
, defaults toTrue
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"]= airlines["Year"].asfactor() >>> airlines["Month"]= airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_dl = H2ODeepLearningEstimator(variable_importances=True, ... seed=1234) >>> airlines_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_dl.mse()
-
property
weights_column
¶ Column with observation weights. Giving some observation a weight of zero is equivalent to excluding it from the dataset; giving an observation a relative weight of 2 is equivalent to repeating that row twice. Negative weights are not allowed. Note: Weights are per-row observation weights and do not increase the size of the data frame. This is typically the number of times a row is repeated, but non-integer values are supported as well. During training, rows with higher weights matter more, due to the larger loss function pre-factor. If you set weight = 0 for a row, the returned prediction frame at that row is zero and this is incorrect. To get an accurate prediction, remove all rows with weight == 0.
Type:
str
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_dl = H2ODeepLearningEstimator(seed=1234) >>> cars_dl.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_dl.auc()
H2OGeneralizedAdditiveEstimator
¶
-
class
h2o.estimators.gam.
H2OGeneralizedAdditiveEstimator
(model_id=None, training_frame=None, validation_frame=None, nfolds=0, seed=-1, keep_cross_validation_models=True, keep_cross_validation_predictions=False, keep_cross_validation_fold_assignment=False, fold_assignment='auto', fold_column=None, response_column=None, ignored_columns=None, ignore_const_cols=True, score_each_iteration=False, offset_column=None, weights_column=None, family='auto', tweedie_variance_power=0.0, tweedie_link_power=0.0, theta=0.0, solver='auto', alpha=None, lambda_=None, lambda_search=False, early_stopping=True, nlambdas=-1, standardize=False, missing_values_handling='mean_imputation', plug_values=None, compute_p_values=False, remove_collinear_columns=False, splines_non_negative=None, intercept=True, non_negative=False, max_iterations=-1, objective_epsilon=-1.0, beta_epsilon=0.0001, gradient_epsilon=-1.0, link='family_default', startval=None, prior=-1.0, cold_start=False, lambda_min_ratio=-1.0, beta_constraints=None, max_active_predictors=-1, interactions=None, interaction_pairs=None, obj_reg=-1.0, export_checkpoints_dir=None, stopping_rounds=0, stopping_metric='auto', stopping_tolerance=0.001, balance_classes=False, class_sampling_factors=None, max_after_balance_size=5.0, max_confusion_matrix_size=20, max_runtime_secs=0.0, custom_metric_func=None, num_knots=None, spline_orders=None, knot_ids=None, gam_columns=None, standardize_tp_gam_cols=False, scale_tp_penalty_mat=False, bs=None, scale=None, keep_gam_cols=False, store_knot_locations=False, auc_type='auto')[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
Generalized Additive Model
Fits a generalized additive model, specified by a response variable, a set of predictors, and a description of the error distribution.
A subclass of
ModelBase
is returned. The specific subclass depends on the machine learning task at hand (if it’s binomial classification, then an H2OBinomialModel is returned, if it’s regression then a H2ORegressionModel is returned). The default print-out of the models is shown, but further GAM-specific information can be queried out of the object. Upon completion of the GAM, the resulting object has coefficients, normalized coefficients, residual/null deviance, aic, and a host of model metrics including MSE, AUC (for logistic regression), degrees of freedom, and confusion matrices.-
property
Lambda
¶ [Deprecated] Use
lambda_
instead
-
property
alpha
¶ Distribution of regularization between the L1 (Lasso) and L2 (Ridge) penalties. A value of 1 for alpha represents Lasso regression, a value of 0 produces Ridge regression, and anything in between specifies the amount of mixing between the two. Default value of alpha is 0 when SOLVER = ‘L-BFGS’; 0.5 otherwise.
Type:
List[float]
.
-
property
auc_type
¶ Set default multinomial AUC type.
Type:
Literal["auto", "none", "macro_ovr", "weighted_ovr", "macro_ovo", "weighted_ovo"]
, defaults to"auto"
.
-
property
balance_classes
¶ Balance training data class counts via over/under-sampling (for imbalanced data).
Type:
bool
, defaults toFalse
.
-
property
beta_constraints
¶ Beta constraints
Type:
Union[None, str, H2OFrame]
.
-
property
beta_epsilon
¶ Converge if beta changes less (using L-infinity norm) than beta esilon, ONLY applies to IRLSM solver
Type:
float
, defaults to0.0001
.
-
property
bs
¶ Basis function type for each gam predictors, 0 for cr, 1 for thin plate regression with knots, 2 for monotone I-splines, 3 for NBSplineTypeI M-splines (refer to doc here: https://github.com/h2oai/h2o-3/issues/6926). If specified, must be the same size as gam_columns
Type:
List[int]
.
-
property
class_sampling_factors
¶ Desired over/under-sampling ratios per class (in lexicographic order). If not specified, sampling factors will be automatically computed to obtain class balance during training. Requires balance_classes.
Type:
List[float]
.
-
property
cold_start
¶ Only applicable to multiple alpha/lambda values when calling GLM from GAM. If false, build the next model for next set of alpha/lambda values starting from the values provided by current model. If true will start GLM model from scratch.
Type:
bool
, defaults toFalse
.
-
property
compute_p_values
¶ Request p-values computation, p-values work only with IRLSM solver and no regularization
Type:
bool
, defaults toFalse
.
-
property
custom_metric_func
¶ Reference to custom evaluation function, format: language:keyName=funcName
Type:
str
.
-
property
early_stopping
¶ Stop early when there is no more relative improvement on train or validation (if provided)
Type:
bool
, defaults toTrue
.
-
property
export_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.
-
property
family
¶ Family. Use binomial for classification with logistic regression, others are for regression problems.
Type:
Literal["auto", "gaussian", "binomial", "quasibinomial", "ordinal", "multinomial", "poisson", "gamma", "tweedie", "negativebinomial", "fractionalbinomial"]
, defaults to"auto"
.
-
property
fold_assignment
¶ Cross-validation fold assignment scheme, if fold_column is not specified. The ‘Stratified’ option will stratify the folds based on the response variable, for classification problems.
Type:
Literal["auto", "random", "modulo", "stratified"]
, defaults to"auto"
.
-
property
fold_column
¶ Column with cross-validation fold index assignment per observation.
Type:
str
.
-
property
gam_columns
¶ Arrays of predictor column names for gam for smoothers using single or multiple predictors like {{‘c1’},{‘c2’,’c3’},{‘c4’},…}
Type:
List[List[str]]
.
-
get_gam_knot_column_names
()[source]¶ Retrieve gam column names corresponding to the knot locations that will be returned if store_knot_location parameter is enabled.
- Returns
gam column names whose knot locations are stored in the knot_locations.
-
get_knot_locations
(gam_column=None)[source]¶ Retrieve gam columns knot locations if store_knot_location parameter is enabled. If a gam column name is specified, the know loations corresponding to that gam column is returned. Otherwise, all knot locations are returned for all gam columns. The order of the gam columns are specified in gam_knot_column_names of the model output.
- Returns
knot locations of gam columns.
-
property
gradient_epsilon
¶ Converge if objective changes less (using L-infinity norm) than this, ONLY applies to L-BFGS solver. Default indicates: If lambda_search is set to False and lambda is equal to zero, the default value of gradient_epsilon is equal to .000001, otherwise the default value is .0001. If lambda_search is set to True, the conditional values above are 1E-8 and 1E-6 respectively.
Type:
float
, defaults to-1.0
.
-
property
ignore_const_cols
¶ Ignore constant columns.
Type:
bool
, defaults toTrue
.
-
property
ignored_columns
¶ Names of columns to ignore for training.
Type:
List[str]
.
-
property
interaction_pairs
¶ A list of pairwise (first order) column interactions.
Type:
List[tuple]
.
-
property
interactions
¶ A list of predictor column indices to interact. All pairwise combinations will be computed for the list.
Type:
List[str]
.
-
property
intercept
¶ Include constant term in the model
Type:
bool
, defaults toTrue
.
-
property
keep_cross_validation_fold_assignment
¶ Whether to keep the cross-validation fold assignment.
Type:
bool
, defaults toFalse
.
-
property
keep_cross_validation_models
¶ Whether to keep the cross-validation models.
Type:
bool
, defaults toTrue
.
-
property
keep_cross_validation_predictions
¶ Whether to keep the predictions of the cross-validation models.
Type:
bool
, defaults toFalse
.
-
property
keep_gam_cols
¶ Save keys of model matrix
Type:
bool
, defaults toFalse
.
-
property
knot_ids
¶ Array storing frame keys of knots. One for each gam column set specified in gam_columns
Type:
List[str]
.
-
property
lambda_
¶ Regularization strength
Type:
List[float]
.
-
property
lambda_min_ratio
¶ Minimum lambda used in lambda search, specified as a ratio of lambda_max (the smallest lambda that drives all coefficients to zero). Default indicates: if the number of observations is greater than the number of variables, then lambda_min_ratio is set to 0.0001; if the number of observations is less than the number of variables, then lambda_min_ratio is set to 0.01.
Type:
float
, defaults to-1.0
.
-
property
lambda_search
¶ Use lambda search starting at lambda max, given lambda is then interpreted as lambda min
Type:
bool
, defaults toFalse
.
-
property
link
¶ Link function.
Type:
Literal["family_default", "identity", "logit", "log", "inverse", "tweedie", "ologit"]
, defaults to"family_default"
.
-
property
max_active_predictors
¶ Maximum number of active predictors during computation. Use as a stopping criterion to prevent expensive model building with many predictors. Default indicates: If the IRLSM solver is used, the value of max_active_predictors is set to 5000 otherwise it is set to 100000000.
Type:
int
, defaults to-1
.
-
property
max_after_balance_size
¶ Maximum relative size of the training data after balancing class counts (can be less than 1.0). Requires balance_classes.
Type:
float
, defaults to5.0
.
-
property
max_confusion_matrix_size
¶ [Deprecated] Maximum size (# classes) for confusion matrices to be printed in the Logs
Type:
int
, defaults to20
.
-
property
max_iterations
¶ Maximum number of iterations
Type:
int
, defaults to-1
.
-
property
max_runtime_secs
¶ Maximum allowed runtime in seconds for model training. Use 0 to disable.
Type:
float
, defaults to0.0
.
-
property
missing_values_handling
¶ Handling of missing values. Either MeanImputation, Skip or PlugValues.
Type:
Literal["mean_imputation", "skip", "plug_values"]
, defaults to"mean_imputation"
.
-
property
nfolds
¶ Number of folds for K-fold cross-validation (0 to disable or >= 2).
Type:
int
, defaults to0
.
-
property
nlambdas
¶ Number of lambdas to be used in a search. Default indicates: If alpha is zero, with lambda search set to True, the value of nlamdas is set to 30 (fewer lambdas are needed for ridge regression) otherwise it is set to 100.
Type:
int
, defaults to-1
.
-
property
non_negative
¶ Restrict coefficients (not intercept) to be non-negative
Type:
bool
, defaults toFalse
.
-
property
num_knots
¶ Number of knots for gam predictors. If specified, must specify one for each gam predictor. For monotone I-splines, mininum = 2, for cs spline, minimum = 3. For thin plate, minimum is size of polynomial basis + 2.
Type:
List[int]
.
-
property
obj_reg
¶ Likelihood divider in objective value computation, default is 1/nobs
Type:
float
, defaults to-1.0
.
-
property
objective_epsilon
¶ Converge if objective value changes less than this. Default indicates: If lambda_search is set to True the value of objective_epsilon is set to .0001. If the lambda_search is set to False and lambda is equal to zero, the value of objective_epsilon is set to .000001, for any other value of lambda the default value of objective_epsilon is set to .0001.
Type:
float
, defaults to-1.0
.
-
property
offset_column
¶ Offset column. This will be added to the combination of columns before applying the link function.
Type:
str
.
-
property
plug_values
¶ Plug Values (a single row frame containing values that will be used to impute missing values of the training/validation frame, use with conjunction missing_values_handling = PlugValues)
Type:
Union[None, str, H2OFrame]
.
-
property
prior
¶ Prior probability for y==1. To be used only for logistic regression iff the data has been sampled and the mean of response does not reflect reality.
Type:
float
, defaults to-1.0
.
-
property
remove_collinear_columns
¶ In case of linearly dependent columns, remove some of the dependent columns
Type:
bool
, defaults toFalse
.
-
property
response_column
¶ Response variable column.
Type:
str
.
-
property
scale
¶ Smoothing parameter for gam predictors. If specified, must be of the same length as gam_columns
Type:
List[float]
.
-
property
scale_tp_penalty_mat
¶ Scale penalty matrix for tp (thin plate) smoothers as in R
Type:
bool
, defaults toFalse
.
-
property
score_each_iteration
¶ Whether to score during each iteration of model training.
Type:
bool
, defaults toFalse
.
-
scoring_history
()[source]¶ Retrieve Model Score History.
- Returns
The score history as an H2OTwoDimTable or a Pandas DataFrame.
-
property
seed
¶ Seed for pseudo random number generator (if applicable)
Type:
int
, defaults to-1
.
-
property
solver
¶ AUTO will set the solver based on given data and the other parameters. IRLSM is fast on on problems with small number of predictors and for lambda-search with L1 penalty, L_BFGS scales better for datasets with many columns.
Type:
Literal["auto", "irlsm", "l_bfgs", "coordinate_descent_naive", "coordinate_descent", "gradient_descent_lh", "gradient_descent_sqerr"]
, defaults to"auto"
.
-
property
spline_orders
¶ Order of I-splines or NBSplineTypeI M-splines used for gam predictors. If specified, must be the same size as gam_columns. For I-splines, the spline_orders will be the same as the polynomials used to generate the splines. For M-splines, the polynomials used to generate the splines will be spline_order-1. Values for bs=0 or 1 will be ignored.
Type:
List[int]
.
-
property
splines_non_negative
¶ Valid for I-spline (bs=2) only. True if the I-splines are monotonically increasing (and monotonically non- decreasing) and False if the I-splines are monotonically decreasing (and monotonically non-increasing). If specified, must be the same size as gam_columns. Values for other spline types will be ignored. Default to true.
Type:
List[bool]
.
-
property
standardize
¶ Standardize numeric columns to have zero mean and unit variance
Type:
bool
, defaults toFalse
.
-
property
standardize_tp_gam_cols
¶ standardize tp (thin plate) predictor columns
Type:
bool
, defaults toFalse
.
-
property
startval
¶ double array to initialize coefficients for GAM.
Type:
List[float]
.
-
property
stopping_metric
¶ Metric to use for early stopping (AUTO: logloss for classification, deviance for regression and anomaly_score for Isolation Forest). Note that custom and custom_increasing can only be used in GBM and DRF with the Python client.
Type:
Literal["auto", "deviance", "logloss", "mse", "rmse", "mae", "rmsle", "auc", "aucpr", "lift_top_group", "misclassification", "mean_per_class_error", "custom", "custom_increasing"]
, defaults to"auto"
.
-
property
stopping_rounds
¶ Early stopping based on convergence of stopping_metric. Stop if simple moving average of length k of the stopping_metric does not improve for k:=stopping_rounds scoring events (0 to disable)
Type:
int
, defaults to0
.
-
property
stopping_tolerance
¶ Relative tolerance for metric-based stopping criterion (stop if relative improvement is not at least this much)
Type:
float
, defaults to0.001
.
-
property
store_knot_locations
¶ If set to true, will return knot locations as double[][] array for gam column names found knots_for_gam. Default to false.
Type:
bool
, defaults toFalse
.
-
property
theta
¶ Theta
Type:
float
, defaults to0.0
.
-
property
training_frame
¶ Id of the training data frame.
Type:
Union[None, str, H2OFrame]
.
-
property
tweedie_link_power
¶ Tweedie link power
Type:
float
, defaults to0.0
.
-
property
tweedie_variance_power
¶ Tweedie variance power
Type:
float
, defaults to0.0
.
-
property
validation_frame
¶ Id of the validation data frame.
Type:
Union[None, str, H2OFrame]
.
-
property
weights_column
¶ Column with observation weights. Giving some observation a weight of zero is equivalent to excluding it from the dataset; giving an observation a relative weight of 2 is equivalent to repeating that row twice. Negative weights are not allowed. Note: Weights are per-row observation weights and do not increase the size of the data frame. This is typically the number of times a row is repeated, but non-integer values are supported as well. During training, rows with higher weights matter more, due to the larger loss function pre-factor. If you set weight = 0 for a row, the returned prediction frame at that row is zero and this is incorrect. To get an accurate prediction, remove all rows with weight == 0.
Type:
str
.
-
property
H2OGradientBoostingEstimator
¶
-
class
h2o.estimators.gbm.
H2OGradientBoostingEstimator
(model_id=None, training_frame=None, validation_frame=None, nfolds=0, keep_cross_validation_models=True, keep_cross_validation_predictions=False, keep_cross_validation_fold_assignment=False, score_each_iteration=False, score_tree_interval=0, fold_assignment='auto', fold_column=None, response_column=None, ignored_columns=None, ignore_const_cols=True, offset_column=None, weights_column=None, balance_classes=False, class_sampling_factors=None, max_after_balance_size=5.0, max_confusion_matrix_size=20, ntrees=50, max_depth=5, min_rows=10.0, nbins=20, nbins_top_level=1024, nbins_cats=1024, r2_stopping=None, stopping_rounds=0, stopping_metric='auto', stopping_tolerance=0.001, max_runtime_secs=0.0, seed=-1, build_tree_one_node=False, learn_rate=0.1, learn_rate_annealing=1.0, distribution='auto', quantile_alpha=0.5, tweedie_power=1.5, huber_alpha=0.9, checkpoint=None, sample_rate=1.0, sample_rate_per_class=None, col_sample_rate=1.0, col_sample_rate_change_per_level=1.0, col_sample_rate_per_tree=1.0, min_split_improvement=1e-05, histogram_type='auto', max_abs_leafnode_pred=None, pred_noise_bandwidth=0.0, categorical_encoding='auto', calibrate_model=False, calibration_frame=None, calibration_method='auto', custom_metric_func=None, custom_distribution_func=None, export_checkpoints_dir=None, in_training_checkpoints_dir=None, in_training_checkpoints_tree_interval=1, monotone_constraints=None, check_constant_response=True, gainslift_bins=-1, auc_type='auto', interaction_constraints=None, auto_rebalance=True)[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
Gradient Boosting Machine
Builds gradient boosted trees on a parsed data set, for regression or classification. The default distribution function will guess the model type based on the response column type. Otherwise, the response column must be an enum for “bernoulli” or “multinomial”, and numeric for all other distributions.
-
property
auc_type
¶ Set default multinomial AUC type.
Type:
Literal["auto", "none", "macro_ovr", "weighted_ovr", "macro_ovo", "weighted_ovo"]
, defaults to"auto"
.
-
property
auto_rebalance
¶ Allow automatic rebalancing of training and validation datasets
Type:
bool
, defaults toTrue
.
-
property
balance_classes
¶ Balance training data class counts via over/under-sampling (for imbalanced data).
Type:
bool
, defaults toFalse
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> predictors = covtype.columns[0:54] >>> response = 'C55' >>> train, valid = covtype.split_frame(ratios=[.8], seed=1234) >>> cov_gbm = H2OGradientBoostingEstimator(balance_classes=True, ... seed=1234) >>> cov_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cov_gbm.logloss(valid=True)
-
property
build_tree_one_node
¶ Run on one node only; no network overhead but fewer cpus used. Suitable for small datasets.
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(build_tree_one_node=True, ... seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm.auc(valid=True)
-
property
calibrate_model
¶ Use Platt Scaling (default) or Isotonic Regression to calculate calibrated class probabilities. Calibration can provide more accurate estimates of class probabilities.
Type:
bool
, defaults toFalse
.- Examples
>>> ecology = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/ecology_model.csv") >>> ecology['Angaus'] = ecology['Angaus'].asfactor() >>> response = 'Angaus' >>> train, calib = ecology.split_frame(seed = 12354) >>> predictors = ecology.columns[3:13] >>> w = h2o.create_frame(binary_fraction=1, ... binary_ones_fraction=0.5, ... missing_fraction=0, ... rows=744, cols=1) >>> w.set_names(["weight"]) >>> train = train.cbind(w) >>> ecology_gbm = H2OGradientBoostingEstimator(ntrees=10, ... max_depth=5, ... min_rows=10, ... learn_rate=0.1, ... distribution="multinomial", ... weights_column="weight", ... calibrate_model=True, ... calibration_frame=calib) >>> ecology_gbm.train(x=predictors, ... y="Angaus", ... training_frame=train) >>> ecology_gbm.auc()
-
property
calibration_frame
¶ Data for model calibration
Type:
Union[None, str, H2OFrame]
.- Examples
>>> ecology = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/ecology_model.csv") >>> ecology['Angaus'] = ecology['Angaus'].asfactor() >>> response = 'Angaus' >>> predictors = ecology.columns[3:13] >>> train, calib = ecology.split_frame(seed=12354) >>> w = h2o.create_frame(binary_fraction=1, ... binary_ones_fraction=0.5, ... missing_fraction=0, ... rows=744,cols=1) >>> w.set_names(["weight"]) >>> train = train.cbind(w) >>> ecology_gbm = H2OGradientBoostingEstimator(ntrees=10, ... max_depth=5, ... min_rows=10, ... learn_rate=0.1, ... distribution="multinomial", ... calibrate_model=True, ... calibration_frame=calib) >>> ecology_gbm.train(x=predictors, ... y="Angaus", ... training_frame=train, ... weights_column="weight") >>> ecology_gbm.auc()
-
property
calibration_method
¶ Calibration method to use
Type:
Literal["auto", "platt_scaling", "isotonic_regression"]
, defaults to"auto"
.
-
property
categorical_encoding
¶ Encoding scheme for categorical features
Type:
Literal["auto", "enum", "one_hot_internal", "one_hot_explicit", "binary", "eigen", "label_encoder", "sort_by_response", "enum_limited"]
, defaults to"auto"
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid = airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_gbm = H2OGradientBoostingEstimator(categorical_encoding="labelencoder", ... seed=1234) >>> airlines_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_gbm.auc(valid=True)
-
property
check_constant_response
¶ Check if response column is constant. If enabled, then an exception is thrown if the response column is a constant value.If disabled, then model will train regardless of the response column being a constant value or not.
Type:
bool
, defaults toTrue
.- Examples
>>> train = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/iris/iris_train.csv") >>> train["constantCol"] = 1 >>> my_gbm = H2OGradientBoostingEstimator(check_constant_response=False) >>> my_gbm.train(x=list(range(1,5)), ... y="constantCol", ... training_frame=train)
-
property
checkpoint
¶ Model checkpoint to resume training with.
Type:
Union[None, str, H2OEstimator]
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(ntrees=1, ... seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> print(cars_gbm.auc(valid=True)) >>> print("Number of trees built for cars_gbm model:", cars_gbm.ntrees) >>> cars_gbm_continued = H2OGradientBoostingEstimator(checkpoint=cars_gbm.model_id, ... ntrees=50, ... seed=1234) >>> cars_gbm_continued.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm_continued.auc(valid=True) >>> print("Number of trees built for cars_gbm model:",cars_gbm_continued.ntrees)
-
property
class_sampling_factors
¶ Desired over/under-sampling ratios per class (in lexicographic order). If not specified, sampling factors will be automatically computed to obtain class balance during training. Requires balance_classes.
Type:
List[float]
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> predictors = covtype.columns[0:54] >>> response = 'C55' >>> train, valid = covtype.split_frame(ratios=[.8], seed=1234) >>> sample_factors = [1., 0.5, 1., 1., 1., 1., 1.] >>> cov_gbm = H2OGradientBoostingEstimator(balance_classes=True, ... class_sampling_factors=sample_factors, ... seed=1234) >>> cov_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cov_gbm.logloss(valid=True)
-
property
col_sample_rate
¶ Column sample rate (from 0.0 to 1.0)
Type:
float
, defaults to1.0
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid = airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_gbm = H2OGradientBoostingEstimator(col_sample_rate=.7, ... seed=1234) >>> airlines_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_gbm.auc(valid=True)
-
property
col_sample_rate_change_per_level
¶ Relative change of the column sampling rate for every level (must be > 0.0 and <= 2.0)
Type:
float
, defaults to1.0
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid = airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_gbm = H2OGradientBoostingEstimator(col_sample_rate_change_per_level=.9, ... seed=1234) >>> airlines_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_gbm.auc(valid=True)
-
property
col_sample_rate_per_tree
¶ Column sample rate per tree (from 0.0 to 1.0)
Type:
float
, defaults to1.0
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid = airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_gbm = H2OGradientBoostingEstimator(col_sample_rate_per_tree=.7, ... seed=1234) >>> airlines_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_gbm.auc(valid=True)
-
property
custom_distribution_func
¶ Reference to custom distribution, format: language:keyName=funcName
Type:
str
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid = airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_gbm = H2OGradientBoostingEstimator(ntrees=3, ... max_depth=5, ... distribution="bernoulli", ... seed=1234) >>> airlines_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame valid) >>> from h2o.utils.distributions import CustomDistributionBernoulli >>> custom_distribution_bernoulli = h2o.upload_custom_distribution(CustomDistributionBernoulli, ... func_name="custom_bernoulli", ... func_file="custom_bernoulli.py") >>> airlines_gbm_custom = H2OGradientBoostingEstimator(ntrees=3, ... max_depth=5, ... distribution="custom", ... custom_distribution_func=custom_distribution_bernoulli, ... seed=1235) >>> airlines_gbm_custom.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_gbm.auc()
-
property
custom_metric_func
¶ Reference to custom evaluation function, format: language:keyName=funcName
Type:
str
.
-
property
distribution
¶ Distribution function
Type:
Literal["auto", "bernoulli", "quasibinomial", "multinomial", "gaussian", "poisson", "gamma", "tweedie", "laplace", "quantile", "huber", "custom"]
, defaults to"auto"
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> response = "cylinders" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(distribution="poisson", ... seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm.mse(valid=True)
-
property
export_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.- Examples
>>> airlines = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip", destination_frame="air.hex") >>> predictors = ["DayofMonth", "DayOfWeek"] >>> response = "IsDepDelayed" >>> hyper_parameters = {'ntrees': [5,10]} >>> search_crit = {'strategy': "RandomDiscrete", ... 'max_models': 5, ... 'seed': 1234, ... 'stopping_rounds': 3, ... 'stopping_metric': "AUTO", ... 'stopping_tolerance': 1e-2} >>> checkpoints_dir = tempfile.mkdtemp() >>> air_grid = H2OGridSearch(H2OGradientBoostingEstimator, ... hyper_params=hyper_parameters, ... search_criteria=search_crit) >>> air_grid.train(x=predictors, ... y=response, ... training_frame=airlines, ... distribution="bernoulli", ... learn_rate=0.1, ... max_depth=3, ... export_checkpoints_dir=checkpoints_dir) >>> len(listdir(checkpoints_dir))
-
property
fold_assignment
¶ Cross-validation fold assignment scheme, if fold_column is not specified. The ‘Stratified’ option will stratify the folds based on the response variable, for classification problems.
Type:
Literal["auto", "random", "modulo", "stratified"]
, defaults to"auto"
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> assignment_type = "Random" >>> cars_gbm = H2OGradientBoostingEstimator(fold_assignment=assignment_type, ... nfolds=5, ... seed=1234) >>> cars_gbm.train(x=predictors, y=response, training_frame=cars) >>> cars_gbm.auc(xval=True)
-
property
fold_column
¶ Column with cross-validation fold index assignment per observation.
Type:
str
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> fold_numbers = cars.kfold_column(n_folds=5, ... seed=1234) >>> fold_numbers.set_names(["fold_numbers"]) >>> cars = cars.cbind(fold_numbers) >>> cars_gbm = H2OGradientBoostingEstimator(seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=cars, ... fold_column="fold_numbers") >>> cars_gbm.auc(xval=True)
-
property
gainslift_bins
¶ Gains/Lift table number of bins. 0 means disabled.. Default value -1 means automatic binning.
Type:
int
, defaults to-1
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/testng/airlines_train.csv") >>> model = H2OGradientBoostingEstimator(ntrees=1, gainslift_bins=20) >>> model.train(x=["Origin", "Distance"], ... y="IsDepDelayed", ... training_frame=airlines) >>> model.gains_lift()
-
property
histogram_type
¶ What type of histogram to use for finding optimal split points
Type:
Literal["auto", "uniform_adaptive", "random", "quantiles_global", "round_robin", "uniform_robust"]
, defaults to"auto"
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid = airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_gbm = H2OGradientBoostingEstimator(histogram_type="UniformAdaptive", ... seed=1234) >>> airlines_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_gbm.auc(valid=True)
-
property
huber_alpha
¶ Desired quantile for Huber/M-regression (threshold between quadratic and linear loss, must be between 0 and 1).
Type:
float
, defaults to0.9
.- Examples
>>> insurance = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/glm_test/insurance.csv") >>> predictors = insurance.columns[0:4] >>> response = 'Claims' >>> insurance['Group'] = insurance['Group'].asfactor() >>> insurance['Age'] = insurance['Age'].asfactor() >>> train, valid = insurance.split_frame(ratios=[.8], seed=1234) >>> insurance_gbm = H2OGradientBoostingEstimator(distribution="huber", ... huber_alpha=0.9, ... seed=1234) >>> insurance_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> insurance_gbm.mse(valid=True)
-
property
ignore_const_cols
¶ Ignore constant columns.
Type:
bool
, defaults toTrue
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> cars["const_1"] = 6 >>> cars["const_2"] = 7 >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(seed=1234, ... ignore_const_cols=True) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm.auc(valid=True)
-
property
ignored_columns
¶ Names of columns to ignore for training.
Type:
List[str]
.
-
property
in_training_checkpoints_dir
¶ Create checkpoints into defined directory while training process is still running. In case of cluster shutdown, this checkpoint can be used to restart training.
Type:
str
.
-
property
in_training_checkpoints_tree_interval
¶ Checkpoint the model after every so many trees. Parameter is used only when in_training_checkpoints_dir is defined
Type:
int
, defaults to1
.
-
property
interaction_constraints
¶ A set of allowed column interactions.
Type:
List[List[str]]
.
-
property
keep_cross_validation_fold_assignment
¶ Whether to keep the cross-validation fold assignment.
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> folds = 5 >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(keep_cross_validation_fold_assignment=True, ... nfolds=5, ... seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm.auc()
-
property
keep_cross_validation_models
¶ Whether to keep the cross-validation models.
Type:
bool
, defaults toTrue
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> folds = 5 >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(keep_cross_validation_models=True, ... nfolds=5, ... seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm.auc()
-
property
keep_cross_validation_predictions
¶ Whether to keep the predictions of the cross-validation models.
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> folds = 5 >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(keep_cross_validation_predictions=True, ... nfolds=5, ... seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm.auc()
-
property
learn_rate
¶ Learning rate (from 0.0 to 1.0)
Type:
float
, defaults to0.1
.- Examples
>>> titanic = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/titanic.csv") >>> titanic['survived'] = titanic['survived'].asfactor() >>> predictors = titanic.columns >>> del predictors[1:3] >>> response = 'survived' >>> train, valid = titanic.split_frame(ratios=[.8], seed=1234) >>> titanic_gbm = H2OGradientBoostingEstimator(ntrees=10000, ... learn_rate=0.01, ... stopping_rounds=5, ... stopping_metric="AUC", ... stopping_tolerance=1e-4, ... seed=1234) >>> titanic_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> titanic_gbm.auc(valid=True)
-
property
learn_rate_annealing
¶ Scale the learning rate by this factor after each tree (e.g., 0.99 or 0.999)
Type:
float
, defaults to1.0
.- Examples
>>> titanic = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/titanic.csv") >>> titanic['survived'] = titanic['survived'].asfactor() >>> predictors = titanic.columns >>> del predictors[1:3] >>> response = 'survived' >>> train, valid = titanic.split_frame(ratios=[.8], seed=1234) >>> titanic_gbm = H2OGradientBoostingEstimator(ntrees=10000, ... learn_rate=0.05, ... learn_rate_annealing=.9, ... stopping_rounds=5, ... stopping_metric="AUC", ... stopping_tolerance=1e-4, ... seed=1234) >>> titanic_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> titanic_gbm.auc(valid=True)
-
property
max_abs_leafnode_pred
¶ Maximum absolute value of a leaf node prediction
Type:
float
, defaults to∞
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> predictors = covtype.columns[0:54] >>> response = 'C55' >>> train, valid = covtype.split_frame(ratios=[.8], seed=1234) >>> cov_gbm = H2OGradientBoostingEstimator(max_abs_leafnode_pred=2, ... seed=1234) >>> cov_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cov_gbm.logloss(valid=True)
-
property
max_after_balance_size
¶ Maximum relative size of the training data after balancing class counts (can be less than 1.0). Requires balance_classes.
Type:
float
, defaults to5.0
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> predictors = covtype.columns[0:54] >>> response = 'C55' >>> train, valid = covtype.split_frame(ratios=[.8], seed=1234) >>> max = .85 >>> cov_gbm = H2OGradientBoostingEstimator(balance_classes=True, ... max_after_balance_size=max, ... seed=1234) >>> cov_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cov_gbm.logloss(valid=True)
-
property
max_confusion_matrix_size
¶ [Deprecated] Maximum size (# classes) for confusion matrices to be printed in the Logs
Type:
int
, defaults to20
.
-
property
max_depth
¶ Maximum tree depth (0 for unlimited).
Type:
int
, defaults to5
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(ntrees=100, ... max_depth=2, ... seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm.auc(valid=True)
-
property
max_runtime_secs
¶ Maximum allowed runtime in seconds for model training. Use 0 to disable.
Type:
float
, defaults to0.0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(max_runtime_secs=10, ... ntrees=10000, ... max_depth=10, ... seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm.auc(valid=True)
-
property
min_rows
¶ Fewest allowed (weighted) observations in a leaf.
Type:
float
, defaults to10.0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(min_rows=16, ... seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm.auc(valid=True)
-
property
min_split_improvement
¶ Minimum relative improvement in squared error reduction for a split to happen
Type:
float
, defaults to1e-05
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(min_split_improvement=1e-3, ... seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm.auc(valid=True)
-
property
monotone_constraints
¶ A mapping representing monotonic constraints. Use +1 to enforce an increasing constraint and -1 to specify a decreasing constraint.
Type:
dict
.- Examples
>>> prostate_hex = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/prostate/prostate.csv.zip") >>> prostate_hex["CAPSULE"] = prostate_hex["CAPSULE"].asfactor() >>> response = "CAPSULE" >>> seed = 42 >>> monotone_constraints = {"AGE":1} >>> gbm_model = H2OGradientBoostingEstimator(seed=seed, ... monotone_constraints=monotone_constraints) >>> gbm_model.train(y=response, ... ignored_columns=["ID"], ... training_frame=prostate_hex) >>> gbm_model.scoring_history()
-
property
nbins
¶ For numerical columns (real/int), build a histogram of (at least) this many bins, then split at the best point
Type:
int
, defaults to20
.- Examples
>>> eeg = h2o.import_file("https://h2o-public-test-data.s3.amazonaws.com/smalldata/eeg/eeg_eyestate.csv") >>> eeg['eyeDetection'] = eeg['eyeDetection'].asfactor() >>> predictors = eeg.columns[:-1] >>> response = 'eyeDetection' >>> train, valid = eeg.split_frame(ratios=[.8], seed=1234) >>> bin_num = [16, 32, 64, 128, 256, 512] >>> label = ["16", "32", "64", "128", "256", "512"] >>> for key, num in enumerate(bin_num): ... eeg_gbm = H2OGradientBoostingEstimator(nbins=num, seed=1234) ... eeg_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) ... print(label[key], 'training score', eeg_gbm.auc(train=True)) ... print(label[key], 'validation score', eeg_gbm.auc(valid=True))
-
property
nbins_cats
¶ For categorical columns (factors), build a histogram of this many bins, then split at the best point. Higher values can lead to more overfitting.
Type:
int
, defaults to1024
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid = airlines.split_frame(ratios=[.8], seed=1234) >>> bin_num = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096] >>> label = ["8", "16", "32", "64", "128", "256", "512", "1024", "2048", "4096"] >>> for key, num in enumerate(bin_num): ... airlines_gbm = H2OGradientBoostingEstimator(nbins_cats=num, seed=1234) ... airlines_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) ... print(label[key], 'training score', airlines_gbm.auc(train=True)) ... print(label[key], 'validation score', airlines_gbm.auc(valid=True))
-
property
nbins_top_level
¶ For numerical columns (real/int), build a histogram of (at most) this many bins at the root level, then decrease by factor of two per level
Type:
int
, defaults to1024
.- Examples
>>> eeg = h2o.import_file("https://h2o-public-test-data.s3.amazonaws.com/smalldata/eeg/eeg_eyestate.csv") >>> eeg['eyeDetection'] = eeg['eyeDetection'].asfactor() >>> predictors = eeg.columns[:-1] >>> response = 'eyeDetection' >>> train, valid = eeg.split_frame(ratios=[.8], seed=1234) >>> bin_num = [32, 64, 128, 256, 512, 1024, 2048, 4096] >>> label = ["32", "64", "128", "256", "512", "1024", "2048", "4096"] >>> for key, num in enumerate(bin_num): ... eeg_gbm = H2OGradientBoostingEstimator(nbins_top_level=num, seed=1234) ... eeg_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) ... print(label[key], 'training score', eeg_gbm.auc(train=True)) ... print(label[key], 'validation score', eeg_gbm.auc(valid=True))
-
property
nfolds
¶ Number of folds for K-fold cross-validation (0 to disable or >= 2).
Type:
int
, defaults to0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> folds = 5 >>> cars_gbm = H2OGradientBoostingEstimator(nfolds=folds, ... seed=1234 >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=cars) >>> cars_gbm.auc()
-
property
ntrees
¶ Number of trees.
Type:
int
, defaults to50
.- Examples
>>> titanic = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/titanic.csv") >>> titanic['survived'] = titanic['survived'].asfactor() >>> predictors = titanic.columns >>> del predictors[1:3] >>> response = 'survived' >>> train, valid = titanic.split_frame(ratios=[.8], seed=1234) >>> tree_num = [20, 50, 80, 110, 140, 170, 200] >>> label = ["20", "50", "80", "110", "140", "170", "200"] >>> for key, num in enumerate(tree_num): ... titanic_gbm = H2OGradientBoostingEstimator(ntrees=num, ... seed=1234) ... titanic_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) ... print(label[key], 'training score', titanic_gbm.auc(train=True)) ... print(label[key], 'validation score', titanic_gbm.auc(valid=True))
-
property
offset_column
¶ Offset column. This will be added to the combination of columns before applying the link function.
Type:
str
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> boston["offset"] = boston["medv"].log() >>> train, valid = boston.split_frame(ratios=[.8], seed=1234) >>> boston_gbm = H2OGradientBoostingEstimator(offset_column="offset", ... seed=1234) >>> boston_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> boston_gbm.mse(valid=True)
-
property
pred_noise_bandwidth
¶ Bandwidth (sigma) of Gaussian multiplicative noise ~N(1,sigma) for tree node predictions
Type:
float
, defaults to0.0
.- Examples
>>> titanic = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/titanic.csv") >>> titanic['survived'] = titanic['survived'].asfactor() >>> predictors = titanic.columns >>> del predictors[1:3] >>> response = 'survived' >>> train, valid = titanic.split_frame(ratios=[.8], seed=1234) >>> titanic_gbm = H2OGradientBoostingEstimator(pred_noise_bandwidth=0.1, ... seed=1234) >>> titanic_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> titanic_gbm.auc(valid = True)
-
property
quantile_alpha
¶ Desired quantile for Quantile regression, must be between 0 and 1.
Type:
float
, defaults to0.5
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> train, valid = boston.split_frame(ratios=[.8], seed=1234) >>> boston_gbm = H2OGradientBoostingEstimator(distribution="quantile", ... quantile_alpha=.8, ... seed=1234) >>> boston_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> boston_gbm.mse(valid=True)
-
property
r2_stopping
¶ r2_stopping is no longer supported and will be ignored if set - please use stopping_rounds, stopping_metric and stopping_tolerance instead. Previous version of H2O would stop making trees when the R^2 metric equals or exceeds this
Type:
float
, defaults to∞
.
-
property
response_column
¶ Response variable column.
Type:
str
.
-
property
sample_rate
¶ Row sample rate per tree (from 0.0 to 1.0)
Type:
float
, defaults to1.0
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["Year"]= airlines["Year"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid = airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_gbm = H2OGradientBoostingEstimator(sample_rate=.7, ... seed=1234) >>> airlines_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_gbm.auc(valid=True)
-
property
sample_rate_per_class
¶ A list of row sample rates per class (relative fraction for each class, from 0.0 to 1.0), for each tree
Type:
List[float]
.- Examples
>>> covtype = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/covtype/covtype.20k.data") >>> covtype[54] = covtype[54].asfactor() >>> predictors = covtype.columns[0:54] >>> response = 'C55' >>> train, valid = covtype.split_frame(ratios=[.8], seed=1234) >>> rate_per_class_list = [1, .4, 1, 1, 1, 1, 1] >>> cov_gbm = H2OGradientBoostingEstimator(sample_rate_per_class=rate_per_class_list, ... seed=1234) >>> cov_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cov_gbm.logloss(valid=True)
-
property
score_each_iteration
¶ Whether to score during each iteration of model training.
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], ... seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(score_each_iteration=True, ... ntrees=55, ... seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm.scoring_history()
-
property
score_tree_interval
¶ Score the model after every so many trees. Disabled if set to 0.
Type:
int
, defaults to0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], ... seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(score_tree_interval=True, ... ntrees=55, ... seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm.scoring_history()
-
property
seed
¶ Seed for pseudo random number generator (if applicable)
Type:
int
, defaults to-1
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid = airlines.split_frame(ratios=[.8], seed=1234) >>> gbm_w_seed_1 = H2OGradientBoostingEstimator(col_sample_rate=.7, ... seed=1234) >>> gbm_w_seed_1.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> print('auc for the 1st model built with a seed:', gbm_w_seed_1.auc(valid=True))
-
property
stopping_metric
¶ Metric to use for early stopping (AUTO: logloss for classification, deviance for regression and anomaly_score for Isolation Forest). Note that custom and custom_increasing can only be used in GBM and DRF with the Python client.
Type:
Literal["auto", "deviance", "logloss", "mse", "rmse", "mae", "rmsle", "auc", "aucpr", "lift_top_group", "misclassification", "mean_per_class_error", "custom", "custom_increasing"]
, defaults to"auto"
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid = airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_gbm = H2OGradientBoostingEstimator(stopping_metric="auc", ... stopping_rounds=3, ... stopping_tolerance=1e-2, ... seed=1234) >>> airlines_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_gbm.auc(valid=True)
-
property
stopping_rounds
¶ Early stopping based on convergence of stopping_metric. Stop if simple moving average of length k of the stopping_metric does not improve for k:=stopping_rounds scoring events (0 to disable)
Type:
int
, defaults to0
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid = airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_gbm = H2OGradientBoostingEstimator(stopping_metric="auc", ... stopping_rounds=3, ... stopping_tolerance=1e-2, ... seed=1234) >>> airlines_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_gbm.auc(valid=True)
-
property
stopping_tolerance
¶ Relative tolerance for metric-based stopping criterion (stop if relative improvement is not at least this much)
Type:
float
, defaults to0.001
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8], seed=1234) >>> airlines_gbm = H2OGradientBoostingEstimator(stopping_metric="auc", ... stopping_rounds=3, ... stopping_tolerance=1e-2, ... seed=1234) >>> airlines_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_gbm.auc(valid=True)
-
property
training_frame
¶ Id of the training data frame.
Type:
Union[None, str, H2OFrame]
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm.auc(valid=True)
-
property
tweedie_power
¶ Tweedie power for Tweedie regression, must be between 1 and 2.
Type:
float
, defaults to1.5
.- Examples
>>> insurance = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/glm_test/insurance.csv") >>> predictors = insurance.columns[0:4] >>> response = 'Claims' >>> insurance['Group'] = insurance['Group'].asfactor() >>> insurance['Age'] = insurance['Age'].asfactor() >>> train, valid = insurance.split_frame(ratios=[.8], seed=1234) >>> insurance_gbm = H2OGradientBoostingEstimator(distribution="tweedie", ... tweedie_power=1.2, ... seed=1234) >>> insurance_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> insurance_gbm.mse(valid=True)
-
property
validation_frame
¶ Id of the validation data frame.
Type:
Union[None, str, H2OFrame]
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_gbm.auc(valid=True)
-
property
weights_column
¶ Column with observation weights. Giving some observation a weight of zero is equivalent to excluding it from the dataset; giving an observation a relative weight of 2 is equivalent to repeating that row twice. Negative weights are not allowed. Note: Weights are per-row observation weights and do not increase the size of the data frame. This is typically the number of times a row is repeated, but non-integer values are supported as well. During training, rows with higher weights matter more, due to the larger loss function pre-factor. If you set weight = 0 for a row, the returned prediction frame at that row is zero and this is incorrect. To get an accurate prediction, remove all rows with weight == 0.
Type:
str
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_gbm = H2OGradientBoostingEstimator(seed=1234) >>> cars_gbm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid, ... weights_column="weight") >>> cars_gbm.auc(valid=True)
-
property
H2OGeneralizedLinearEstimator
¶
-
class
h2o.estimators.glm.
H2OGeneralizedLinearEstimator
(model_id=None, training_frame=None, validation_frame=None, nfolds=0, checkpoint=None, export_checkpoints_dir=None, seed=-1, keep_cross_validation_models=True, keep_cross_validation_predictions=False, keep_cross_validation_fold_assignment=False, fold_assignment='auto', fold_column=None, response_column=None, ignored_columns=None, random_columns=None, ignore_const_cols=True, score_each_iteration=False, score_iteration_interval=-1, offset_column=None, weights_column=None, family='auto', rand_family=None, tweedie_variance_power=0.0, tweedie_link_power=1.0, theta=1e-10, solver='auto', alpha=None, lambda_=None, lambda_search=False, early_stopping=True, nlambdas=-1, standardize=True, missing_values_handling='mean_imputation', plug_values=None, compute_p_values=False, dispersion_parameter_method='pearson', init_dispersion_parameter=1.0, remove_collinear_columns=False, intercept=True, non_negative=False, max_iterations=-1, objective_epsilon=-1.0, beta_epsilon=0.0001, gradient_epsilon=-1.0, link='family_default', rand_link=None, startval=None, calc_like=False, HGLM=False, prior=-1.0, cold_start=False, lambda_min_ratio=-1.0, beta_constraints=None, max_active_predictors=-1, interactions=None, interaction_pairs=None, obj_reg=-1.0, stopping_rounds=0, stopping_metric='auto', stopping_tolerance=0.001, balance_classes=False, class_sampling_factors=None, max_after_balance_size=5.0, max_confusion_matrix_size=20, max_runtime_secs=0.0, custom_metric_func=None, generate_scoring_history=False, auc_type='auto', dispersion_epsilon=0.0001, tweedie_epsilon=8e-17, max_iterations_dispersion=3000, build_null_model=False, fix_dispersion_parameter=False, generate_variable_inflation_factors=False, fix_tweedie_variance_power=True, dispersion_learning_rate=0.5, influence=None)[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
Generalized Linear Modeling
Fits a generalized linear model, specified by a response variable, a set of predictors, and a description of the error distribution.
A subclass of
ModelBase
is returned. The specific subclass depends on the machine learning task at hand (if it’s binomial classification, then an H2OBinomialModel is returned, if it’s regression then a H2ORegressionModel is returned). The default print-out of the models is shown, but further GLM-specific information can be queried out of the object. Upon completion of the GLM, the resulting object has coefficients, normalized coefficients, residual/null deviance, aic, and a host of model metrics including MSE, AUC (for logistic regression), degrees of freedom, and confusion matrices.-
property
HGLM
¶ If set to true, will return HGLM model. Otherwise, normal GLM model will be returned
Type:
bool
, defaults toFalse
.
-
property
Lambda
¶ [Deprecated] Use
lambda_
instead
-
property
alpha
¶ Distribution of regularization between the L1 (Lasso) and L2 (Ridge) penalties. A value of 1 for alpha represents Lasso regression, a value of 0 produces Ridge regression, and anything in between specifies the amount of mixing between the two. Default value of alpha is 0 when SOLVER = ‘L-BFGS’; 0.5 otherwise.
Type:
List[float]
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> train, valid = boston.split_frame(ratios=[.8]) >>> boston_glm = H2OGeneralizedLinearEstimator(alpha=.25) >>> boston_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> print(boston_glm.mse(valid=True))
-
property
auc_type
¶ Set default multinomial AUC type.
Type:
Literal["auto", "none", "macro_ovr", "weighted_ovr", "macro_ovo", "weighted_ovo"]
, defaults to"auto"
.
-
property
balance_classes
¶ Balance training data class counts via over/under-sampling (for imbalanced data).
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> predictors = ["displacement","power","weight","year"] >>> response = "acceleration" >>> train, valid = cars.split_frame(ratios=[.8]) >>> cars_glm = H2OGeneralizedLinearEstimator(balance_classes=True, ... seed=1234) >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_glm.mse()
-
property
beta_constraints
¶ Beta constraints
Type:
Union[None, str, H2OFrame]
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> predictors = ["displacement","power","weight","year"] >>> response = "acceleration" >>> train, valid = cars.split_frame(ratios=[.8]) >>> n = len(predictors) >>> constraints = h2o.H2OFrame({'names':predictors, ... 'lower_bounds': [-1000]*n, ... 'upper_bounds': [1000]*n, ... 'beta_given': [1]*n, ... 'rho': [0.2]*n}) >>> cars_glm = H2OGeneralizedLinearEstimator(standardize=True, ... beta_constraints=constraints) >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_glm.mse()
-
property
beta_epsilon
¶ Converge if beta changes less (using L-infinity norm) than beta esilon, ONLY applies to IRLSM solver
Type:
float
, defaults to0.0001
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> predictors = ["displacement","power","weight","year"] >>> response = "acceleration" >>> train, valid = cars.split_frame(ratios=[.8]) >>> cars_glm = H2OGeneralizedLinearEstimator(beta_epsilon=1e-3) >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_glm.mse()
-
property
build_null_model
¶ If set, will build a model with only the intercept. Default to false.
Type:
bool
, defaults toFalse
.
-
property
calc_like
¶ if true, will return likelihood function value.
Type:
bool
, defaults toFalse
.
-
property
checkpoint
¶ Model checkpoint to resume training with.
Type:
Union[None, str, H2OEstimator]
.
-
property
class_sampling_factors
¶ Desired over/under-sampling ratios per class (in lexicographic order). If not specified, sampling factors will be automatically computed to obtain class balance during training. Requires balance_classes.
Type:
List[float]
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> predictors = ["displacement","power","weight","year"] >>> response = "acceleration" >>> train, valid = cars.split_frame(ratios=[.8]) >>> sample_factors = [1., 0.5, 1., 1., 1., 1., 1.] >>> cars_glm = H2OGeneralizedLinearEstimator(balance_classes=True, ... class_sampling_factors=sample_factors, ... seed=1234) >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_glm.mse()
-
property
cold_start
¶ Only applicable to multiple alpha/lambda values. If false, build the next model for next set of alpha/lambda values starting from the values provided by current model. If true will start GLM model from scratch.
Type:
bool
, defaults toFalse
.
-
property
compute_p_values
¶ Request p-values computation, p-values work only with IRLSM solver and no regularization
Type:
bool
, defaults toFalse
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8]) >>> airlines_glm = H2OGeneralizedLinearEstimator(family='binomial', ... lambda_=0, ... remove_collinear_columns=True, ... compute_p_values=True) >>> airlines_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_glm.mse()
-
property
custom_metric_func
¶ Reference to custom evaluation function, format: language:keyName=funcName
Type:
str
.
-
property
dispersion_epsilon
¶ If changes in dispersion parameter estimation or loglikelihood value is smaller than dispersion_epsilon, will break out of the dispersion parameter estimation loop using maximum likelihood.
Type:
float
, defaults to0.0001
.
-
property
dispersion_learning_rate
¶ Dispersion learning rate is only valid for tweedie family dispersion parameter estimation using ml. It must be > 0. This controls how much the dispersion parameter estimate is to be changed when the calculated loglikelihood actually decreases with the new dispersion. In this case, instead of setting new dispersion = dispersion + change, we set new dispersion = dispersion + dispersion_learning_rate * change. Defaults to 0.5.
Type:
float
, defaults to0.5
.
-
property
dispersion_parameter_method
¶ Method used to estimate the dispersion parameter for Tweedie, Gamma and Negative Binomial only.
Type:
Literal["deviance", "pearson", "ml"]
, defaults to"pearson"
.
-
property
early_stopping
¶ Stop early when there is no more relative improvement on train or validation (if provided)
Type:
bool
, defaults toTrue
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8]) >>> cars_glm = H2OGeneralizedLinearEstimator(family='binomial', ... early_stopping=True) >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_glm.auc(valid=True)
-
property
export_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.- Examples
>>> import tempfile >>> from os import listdir >>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> predictors = ["displacement","power","weight","year"] >>> response = "acceleration" >>> train, valid = cars.split_frame(ratios=[.8]) >>> checkpoints = tempfile.mkdtemp() >>> cars_glm = H2OGeneralizedLinearEstimator(export_checkpoints_dir=checkpoints, ... seed=1234) >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_glm.mse() >>> len(listdir(checkpoints_dir))
-
property
family
¶ Family. Use binomial for classification with logistic regression, others are for regression problems.
Type:
Literal["auto", "gaussian", "binomial", "fractionalbinomial", "quasibinomial", "ordinal", "multinomial", "poisson", "gamma", "tweedie", "negativebinomial"]
, defaults to"auto"
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8]) >>> cars_glm = H2OGeneralizedLinearEstimator(family='binomial') >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_glm.auc(valid = True)
-
property
fix_dispersion_parameter
¶ Only used for Tweedie, Gamma and Negative Binomial GLM. If set, will use the dispsersion parameter in init_dispersion_parameter as the standard error and use it to calculate the p-values. Default to false.
Type:
bool
, defaults toFalse
.
-
property
fix_tweedie_variance_power
¶ If true, will fix tweedie variance power value to the value set in tweedie_variance_power.
Type:
bool
, defaults toTrue
.
-
property
fold_assignment
¶ Cross-validation fold assignment scheme, if fold_column is not specified. The ‘Stratified’ option will stratify the folds based on the response variable, for classification problems.
Type:
Literal["auto", "random", "modulo", "stratified"]
, defaults to"auto"
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> assignment_type = "Random" >>> cars_gml = H2OGeneralizedLinearEstimator(fold_assignment=assignment_type, ... nfolds=5, ... family='binomial', ... seed=1234) >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=cars) >>> cars_glm.auc(train=True)
-
property
fold_column
¶ Column with cross-validation fold index assignment per observation.
Type:
str
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> fold_numbers = cars.kfold_column(n_folds=5, seed=1234) >>> fold_numbers.set_names(["fold_numbers"]) >>> cars = cars.cbind(fold_numbers) >>> print(cars['fold_numbers']) >>> cars_glm = H2OGeneralizedLinearEstimator(seed=1234, ... family="binomial") >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=cars, ... fold_column="fold_numbers") >>> cars_glm.auc(xval=True)
-
property
generate_scoring_history
¶ If set to true, will generate scoring history for GLM. This may significantly slow down the algo.
Type:
bool
, defaults toFalse
.
-
property
generate_variable_inflation_factors
¶ if true, will generate variable inflation factors for numerical predictors. Default to false.
Type:
bool
, defaults toFalse
.- Examples
>>> training_data = h2o.import_file("http://h2o-public-test-data.s3.amazonaws.com/smalldata/glm_test/gamma_dispersion_factor_9_10kRows.csv") >>> predictors = ['abs.C1.','abs.C2.','abs.C3.','abs.C4.','abs.C5.'] >>> response = 'resp' >>> vif_glm = H2OGeneralizedLinearEstimator(family="gamma", ... lambda_=0, ... generate_variable_inflation_factors=True, ... fold_assignment="modulo", ... nfolds=3, ... keep_cross_validation_models=True) >>> vif_glm.train(x=predictors, y=response, training_frame=training_data) >>> vif_glm.get_variable_inflation_factors()
-
static
getAlphaBest
(model)[source]¶ Extract best alpha value found from glm model.
- Parameters
model – source lambda search model
- Examples
>>> d = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/prostate/prostate.csv") >>> m = H2OGeneralizedLinearEstimator(family = 'binomial', ... lambda_search = True, ... solver = 'COORDINATE_DESCENT') >>> m.train(training_frame = d, ... x = [2,3,4,5,6,7,8], ... y = 1) >>> bestAlpha = H2OGeneralizedLinearEstimator.getAlphaBest(m) >>> print("Best alpha found is {0}".format(bestAlpha))
-
static
getGLMRegularizationPath
(model)[source]¶ Extract full regularization path explored during lambda search from glm model.
- Parameters
model – source lambda search model
- Examples
>>> d = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/prostate/prostate.csv") >>> m = H2OGeneralizedLinearEstimator(family = 'binomial', ... lambda_search = True, ... solver = 'COORDINATE_DESCENT') >>> m.train(training_frame = d, ... x = [2,3,4,5,6,7,8], ... y = 1) >>> r = H2OGeneralizedLinearEstimator.getGLMRegularizationPath(m) >>> m2 = H2OGeneralizedLinearEstimator.makeGLMModel(model=m, ... coefs=r['coefficients'][10]) >>> dev1 = r['explained_deviance_train'][10] >>> p = m2.model_performance(d) >>> dev2 = 1-p.residual_deviance()/p.null_deviance() >>> print(dev1, " =?= ", dev2)
-
static
getLambdaBest
(model)[source]¶ Extract best lambda value found from glm model.
- Parameters
model – source lambda search model
- Examples
>>> d = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/prostate/prostate.csv") >>> m = H2OGeneralizedLinearEstimator(family = 'binomial', ... lambda_search = True, ... solver = 'COORDINATE_DESCENT') >>> m.train(training_frame = d, ... x = [2,3,4,5,6,7,8], ... y = 1) >>> bestLambda = H2OGeneralizedLinearEstimator.getLambdaBest(m) >>> print("Best lambda found is {0}".format(bestLambda))
-
static
getLambdaMax
(model)[source]¶ Extract the maximum lambda value used during lambda search.
- Parameters
model – source lambda search model
- Examples
>>> d = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/prostate/prostate.csv") >>> m = H2OGeneralizedLinearEstimator(family = 'binomial', ... lambda_search = True, ... solver = 'COORDINATE_DESCENT') >>> m.train(training_frame = d, ... x = [2,3,4,5,6,7,8], ... y = 1) >>> maxLambda = H2OGeneralizedLinearEstimator.getLambdaMax(m) >>> print("Maximum lambda found is {0}".format(maxLambda))
-
static
getLambdaMin
(model)[source]¶ Extract the minimum lambda value calculated during lambda search from glm model. Note that due to early stop, this minimum lambda value may not be used in the actual lambda search.
- Parameters
model – source lambda search model
- Examples
>>> d = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/prostate/prostate.csv") >>> m = H2OGeneralizedLinearEstimator(family = 'binomial', ... lambda_search = True, ... solver = 'COORDINATE_DESCENT') >>> m.train(training_frame = d, ... x = [2,3,4,5,6,7,8], ... y = 1) >>> minLambda = H2OGeneralizedLinearEstimator.getLambdaMin(m) >>> print("Minimum lambda found is {0}".format(minLambda))
-
get_regression_influence_diagnostics
()[source]¶ For GLM model, if influence is set to dfbetas, a frame containing the original predictors, response and DFBETA_ for each predictors that are used in building the model is returned.
- Returns
H2OFrame containing predictors used in building the model, response and DFBETA_ for each predictor.
- Examples
>>> d = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/prostate/prostate.csv") >>> m = H2OGeneralizedLinearEstimator(family = 'binomial', ... lambda_=0.0, ... standardize=False, ... influence="dfbetas") >>> m.train(training_frame = d, ... x = [2,3,4,5,6,7,8], ... y = 1) >>> ridFrame = m.get_regression_influence_diagnostics() >>> print("column names of regression influence diagnostics frame is {0}".format(ridFrame.names))
-
property
gradient_epsilon
¶ Converge if objective changes less (using L-infinity norm) than this, ONLY applies to L-BFGS solver. Default (of -1.0) indicates: If lambda_search is set to False and lambda is equal to zero, the default value of gradient_epsilon is equal to .000001, otherwise the default value is .0001. If lambda_search is set to True, the conditional values above are 1E-8 and 1E-6 respectively.
Type:
float
, defaults to-1.0
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> train, valid = boston.split_frame(ratios=[.8]) >>> boston_glm = H2OGeneralizedLinearEstimator(gradient_epsilon=1e-3) >>> boston_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> boston_glm.mse()
-
property
ignore_const_cols
¶ Ignore constant columns.
Type:
bool
, defaults toTrue
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> cars["const_1"] = 6 >>> cars["const_2"] = 7 >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_glm = H2OGeneralizedLinearEstimator(seed=1234, ... ignore_const_cols=True, ... family="binomial") >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_glm.auc(valid=True)
-
property
ignored_columns
¶ Names of columns to ignore for training.
Type:
List[str]
.
-
property
influence
¶ If set to dfbetas will calculate the difference in beta when a datarow is included and excluded in the dataset.
Type:
Literal["dfbetas"]
.
-
property
init_dispersion_parameter
¶ Only used for Tweedie, Gamma and Negative Binomial GLM. Store the initial value of dispersion parameter. If fix_dispersion_parameter is set, this value will be used in the calculation of p-values.Default to 1.0.
Type:
float
, defaults to1.0
.
-
property
interaction_pairs
¶ A list of pairwise (first order) column interactions.
Type:
List[tuple]
.- Examples
>>> df = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> XY = [df.names[i-1] for i in [1,2,3,4,6,8,9,13,17,18,19,31]] >>> interactions = [XY[i-1] for i in [5,7,9]] >>> m = H2OGeneralizedLinearEstimator(lambda_search=True, ... family="binomial", ... interactions=interactions) >>> m.train(x=XY[:len(XY)], y=XY[-1],training_frame=df) >>> m._model_json['output']['coefficients_table'] >>> coef_m = m._model_json['output']['coefficients_table'] >>> interaction_pairs = [("CRSDepTime", "UniqueCarrier"), ... ("CRSDepTime", "Origin"), ... ("UniqueCarrier", "Origin")] >>> mexp = H2OGeneralizedLinearEstimator(lambda_search=True, ... family="binomial", ... interaction_pairs=interaction_pairs) >>> mexp.train(x=XY[:len(XY)], y=XY[-1],training_frame=df) >>> mexp._model_json['output']['coefficients_table']
-
property
interactions
¶ A list of predictor column indices to interact. All pairwise combinations will be computed for the list.
Type:
List[str]
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> train, valid = boston.split_frame(ratios=[.8]) >>> interactions_list = ['crim', 'dis'] >>> boston_glm = H2OGeneralizedLinearEstimator(interactions=interactions_list) >>> boston_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> boston_glm.mse()
-
property
intercept
¶ Include constant term in the model
Type:
bool
, defaults toTrue
.- Examples
>>> iris = h2o.import_file("http://h2o-public-test-data.s3.amazonaws.com/smalldata/iris/iris_wheader.csv") >>> iris['class'] = iris['class'].asfactor() >>> predictors = iris.columns[:-1] >>> response = 'class' >>> train, valid = iris.split_frame(ratios=[.8]) >>> iris_glm = H2OGeneralizedLinearEstimator(family='multinomial', ... intercept=True) >>> iris_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> iris_glm.logloss(valid=True)
-
property
keep_cross_validation_fold_assignment
¶ Whether to keep the cross-validation fold assignment.
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_glm = H2OGeneralizedLinearEstimator(keep_cross_validation_fold_assignment=True, ... nfolds=5, ... seed=1234, ... family="binomial") >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train) >>> cars_glm.cross_validation_fold_assignment()
-
property
keep_cross_validation_models
¶ Whether to keep the cross-validation models.
Type:
bool
, defaults toTrue
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_glm = H2OGeneralizedLinearEstimator(keep_cross_validation_models=True, ... nfolds=5, ... seed=1234, ... family="binomial") >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train) >>> cars_glm_cv_models = cars_glm.cross_validation_models() >>> print(cars_glm.cross_validation_models())
-
property
keep_cross_validation_predictions
¶ Whether to keep the predictions of the cross-validation models.
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_glm = H2OGeneralizedLinearEstimator(keep_cross_validation_predictions=True, ... nfolds=5, ... seed=1234, ... family="binomial") >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train) >>> cars_glm.cross_validation_predictions()
-
property
lambda_
¶ Regularization strength
Type:
List[float]
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid = airlines.split_frame(ratios=[.8]) >>> airlines_glm = H2OGeneralizedLinearEstimator(family='binomial', ... lambda_=.0001) >>> airlines_glm.train(x=predictors, ... y=response ... trainig_frame=train, ... validation_frame=valid) >>> print(airlines_glm.auc(valid=True))
-
property
lambda_min_ratio
¶ Minimum lambda used in lambda search, specified as a ratio of lambda_max (the smallest lambda that drives all coefficients to zero). Default indicates: if the number of observations is greater than the number of variables, then lambda_min_ratio is set to 0.0001; if the number of observations is less than the number of variables, then lambda_min_ratio is set to 0.01.
Type:
float
, defaults to-1.0
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> train, valid = boston.split_frame(ratios=[.8]) >>> boston_glm = H2OGeneralizedLinearEstimator(lambda_min_ratio=.0001) >>> boston_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> boston_glm.mse()
-
property
lambda_search
¶ Use lambda search starting at lambda max, given lambda is then interpreted as lambda min
Type:
bool
, defaults toFalse
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> train, valid = boston.split_frame(ratios=[.8]) >>> boston_glm = H2OGeneralizedLinearEstimator(lambda_search=True) >>> boston_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> print(boston_glm.mse(valid=True))
-
property
link
¶ Link function.
Type:
Literal["family_default", "identity", "logit", "log", "inverse", "tweedie", "ologit"]
, defaults to"family_default"
.- Examples
>>> iris = h2o.import_file("http://h2o-public-test-data.s3.amazonaws.com/smalldata/iris/iris_wheader.csv") >>> iris['class'] = iris['class'].asfactor() >>> predictors = iris.columns[:-1] >>> response = 'class' >>> train, valid = iris.split_frame(ratios=[.8]) >>> iris_glm = H2OGeneralizedLinearEstimator(family='multinomial', ... link='family_default') >>> iris_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> iris_glm.logloss()
-
static
makeGLMModel
(model, coefs, threshold=0.5)[source]¶ Create a custom GLM model using the given coefficients.
Needs to be passed source model trained on the dataset to extract the dataset information from.
- Parameters
model – source model, used for extracting dataset information
coefs – dictionary containing model coefficients
threshold – (optional, only for binomial) decision threshold used for classification
- Examples
>>> d = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/prostate/prostate.csv") >>> m = H2OGeneralizedLinearEstimator(family='binomial', ... lambda_search=True, ... solver='COORDINATE_DESCENT') >>> m.train(training_frame=d, ... x=[2,3,4,5,6,7,8], ... y=1) >>> r = H2OGeneralizedLinearEstimator.getGLMRegularizationPath(m) >>> m2 = H2OGeneralizedLinearEstimator.makeGLMModel(model=m, ... coefs=r['coefficients'][10]) >>> dev1 = r['explained_deviance_train'][10] >>> p = m2.model_performance(d) >>> dev2 = 1-p.residual_deviance()/p.null_deviance() >>> print(dev1, " =?= ", dev2)
-
property
max_active_predictors
¶ Maximum number of active predictors during computation. Use as a stopping criterion to prevent expensive model building with many predictors. Default indicates: If the IRLSM solver is used, the value of max_active_predictors is set to 5000 otherwise it is set to 100000000.
Type:
int
, defaults to-1
.- Examples
>>> higgs= h2o.import_file("https://h2o-public-test-data.s3.amazonaws.com/smalldata/testng/higgs_train_5k.csv") >>> predictors = higgs.names >>> predictors.remove('response') >>> response = "response" >>> train, valid = higgs.split_frame(ratios=[.8]) >>> higgs_glm = H2OGeneralizedLinearEstimator(family='binomial', ... max_active_predictors=200) >>> higgs_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> higgs_glm.auc()
-
property
max_after_balance_size
¶ Maximum relative size of the training data after balancing class counts (can be less than 1.0). Requires balance_classes.
Type:
float
, defaults to5.0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> predictors = ["displacement","power","weight","year"] >>> response = "acceleration" >>> train, valid = cars.split_frame(ratios=[.8]) >>> max = .85 >>> cars_glm = H2OGeneralizedLinearEstimator(balance_classes=True, ... max_after_balance_size=max, ... seed=1234) >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_glm.mse()
-
property
max_confusion_matrix_size
¶ [Deprecated] Maximum size (# classes) for confusion matrices to be printed in the Logs
Type:
int
, defaults to20
.
-
property
max_iterations
¶ Maximum number of iterations
Type:
int
, defaults to-1
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8]) >>> cars_glm = H2OGeneralizedLinearEstimator(family='binomial', ... max_iterations=50) >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_glm.mse()
-
property
max_iterations_dispersion
¶ Control the maximum number of iterations in the dispersion parameter estimation loop using maximum likelihood.
Type:
int
, defaults to3000
.
-
property
max_runtime_secs
¶ Maximum allowed runtime in seconds for model training. Use 0 to disable.
Type:
float
, defaults to0.0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8]) >>> cars_glm = H2OGeneralizedLinearEstimator(max_runtime_secs=10, ... seed=1234) >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_glm.mse()
-
property
missing_values_handling
¶ Handling of missing values. Either MeanImputation, Skip or PlugValues.
Type:
Literal["mean_imputation", "skip", "plug_values"]
, defaults to"mean_imputation"
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> boston.insert_missing_values() >>> train, valid = boston.split_frame(ratios=[.8]) >>> boston_glm = H2OGeneralizedLinearEstimator(missing_values_handling="skip") >>> boston_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> boston_glm.mse()
-
property
nfolds
¶ Number of folds for K-fold cross-validation (0 to disable or >= 2).
Type:
int
, defaults to0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> folds = 5 >>> cars_glm = H2OGeneralizedLinearEstimator(nfolds=folds, ... seed=1234, ... family='binomial') >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=cars) >>> cars_glm.auc(xval=True)
-
property
nlambdas
¶ Number of lambdas to be used in a search. Default indicates: If alpha is zero, with lambda search set to True, the value of nlamdas is set to 30 (fewer lambdas are needed for ridge regression) otherwise it is set to 100.
Type:
int
, defaults to-1
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> train, valid = boston.split_frame(ratios=[.8]) >>> boston_glm = H2OGeneralizedLinearEstimator(lambda_search=True, ... nlambdas=50) >>> boston_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> print(boston_glm.mse(valid=True))
-
property
non_negative
¶ Restrict coefficients (not intercept) to be non-negative
Type:
bool
, defaults toFalse
.- Examples
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid= airlines.split_frame(ratios=[.8]) >>> airlines_glm = H2OGeneralizedLinearEstimator(family='binomial', ... non_negative=True) >>> airlines_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_glm.auc()
-
property
obj_reg
¶ Likelihood divider in objective value computation, default (of -1.0) will set it to 1/nobs
Type:
float
, defaults to-1.0
.- Examples
>>> df = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/bigdata/laptop/glm_ordinal_logit/ordinal_multinomial_training_set.csv") >>> df["C11"] = df["C11"].asfactor() >>> ordinal_fit = H2OGeneralizedLinearEstimator(family="ordinal", ... alpha=1.0, ... lambda_=0.000000001, ... obj_reg=0.00001, ... max_iterations=1000, ... beta_epsilon=1e-8, ... objective_epsilon=1e-10) >>> ordinal_fit.train(x=list(range(0,10)), ... y="C11", ... training_frame=df) >>> ordinal_fit.mse()
-
property
objective_epsilon
¶ Converge if objective value changes less than this. Default (of -1.0) indicates: If lambda_search is set to True the value of objective_epsilon is set to .0001. If the lambda_search is set to False and lambda is equal to zero, the value of objective_epsilon is set to .000001, for any other value of lambda the default value of objective_epsilon is set to .0001.
Type:
float
, defaults to-1.0
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> train, valid = boston.split_frame(ratios=[.8]) >>> boston_glm = H2OGeneralizedLinearEstimator(objective_epsilon=1e-3) >>> boston_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> boston_glm.mse()
-
property
offset_column
¶ Offset column. This will be added to the combination of columns before applying the link function.
Type:
str
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> boston["offset"] = boston["medv"].log() >>> train, valid = boston.split_frame(ratios=[.8], seed=1234) >>> boston_glm = H2OGeneralizedLinearEstimator(offset_column="offset", ... seed=1234) >>> boston_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> boston_glm.mse(valid=True)
-
property
plug_values
¶ Plug Values (a single row frame containing values that will be used to impute missing values of the training/validation frame, use with conjunction missing_values_handling = PlugValues)
Type:
Union[None, str, H2OFrame]
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars = cars.drop(0) >>> means = cars.mean() >>> means = H2OFrame._expr(ExprNode("mean", cars, True, 0)) >>> glm_means = H2OGeneralizedLinearEstimator(seed=42) >>> glm_means.train(training_frame=cars, y="cylinders") >>> glm_plugs1 = H2OGeneralizedLinearEstimator(seed=42, ... missing_values_handling="PlugValues", ... plug_values=means) >>> glm_plugs1.train(training_frame=cars, y="cylinders") >>> glm_means.coef() == glm_plugs1.coef() >>> not_means = 0.1 + (means * 0.5) >>> glm_plugs2 = H2OGeneralizedLinearEstimator(seed=42, ... missing_values_handling="PlugValues", ... plug_values=not_means) >>> glm_plugs2.train(training_frame=cars, y="cylinders") >>> glm_means.coef() != glm_plugs2.coef()
-
property
prior
¶ Prior probability for y==1. To be used only for logistic regression iff the data has been sampled and the mean of response does not reflect reality.
Type:
float
, defaults to-1.0
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8]) >>> cars_glm1 = H2OGeneralizedLinearEstimator(family='binomial', prior=0.5) >>> cars_glm1.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_glm1.mse()
-
property
rand_family
¶ Random Component Family array. One for each random component. Only support gaussian for now.
Type:
List[Literal["[gaussian]"]]
.
-
property
rand_link
¶ Link function array for random component in HGLM.
Type:
List[Literal["[identity]", "[family_default]"]]
.
-
property
random_columns
¶ random columns indices for HGLM.
Type:
List[int]
.
-
property
remove_collinear_columns
¶ In case of linearly dependent columns, remove some of the dependent columns
Type:
bool
, defaults toFalse
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid = airlines.split_frame(ratios=[.8]) >>> airlines_glm = H2OGeneralizedLinearEstimator(family='binomial', ... lambda_=0, ... remove_collinear_columns=True) >>> airlines_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> airlines_glm.auc()
-
property
response_column
¶ Response variable column.
Type:
str
.
-
property
score_each_iteration
¶ Whether to score during each iteration of model training.
Type:
bool
, defaults toFalse
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], seed=1234) >>> cars_glm = H2OGeneralizedLinearEstimator(score_each_iteration=True, ... seed=1234, ... family='binomial') >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_glm.scoring_history()
-
property
score_iteration_interval
¶ Perform scoring for every score_iteration_interval iterations
Type:
int
, defaults to-1
.
-
property
seed
¶ Seed for pseudo random number generator (if applicable)
Type:
int
, defaults to-1
.- Examples
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip") >>> airlines["Year"] = airlines["Year"].asfactor() >>> airlines["Month"] = airlines["Month"].asfactor() >>> airlines["DayOfWeek"] = airlines["DayOfWeek"].asfactor() >>> airlines["Cancelled"] = airlines["Cancelled"].asfactor() >>> airlines['FlightNum'] = airlines['FlightNum'].asfactor() >>> predictors = ["Origin", "Dest", "Year", "UniqueCarrier", ... "DayOfWeek", "Month", "Distance", "FlightNum"] >>> response = "IsDepDelayed" >>> train, valid = airlines.split_frame(ratios=[.8], seed=1234) >>> glm_w_seed = H2OGeneralizedLinearEstimator(family='binomial', ... seed=1234) >>> glm_w_seed.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> print(glm_w_seed_1.auc(valid=True))
-
property
solver
¶ AUTO will set the solver based on given data and the other parameters. IRLSM is fast on on problems with small number of predictors and for lambda-search with L1 penalty, L_BFGS scales better for datasets with many columns.
Type:
Literal["auto", "irlsm", "l_bfgs", "coordinate_descent_naive", "coordinate_descent", "gradient_descent_lh", "gradient_descent_sqerr"]
, defaults to"auto"
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> train, valid = boston.split_frame(ratios=[.8]) >>> boston_glm = H2OGeneralizedLinearEstimator(solver='irlsm') >>> boston_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> print(boston_glm.mse(valid=True))
-
property
standardize
¶ Standardize numeric columns to have zero mean and unit variance
Type:
bool
, defaults toTrue
.- Examples
>>> boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv") >>> predictors = boston.columns[:-1] >>> response = "medv" >>> boston['chas'] = boston['chas'].asfactor() >>> train, valid = boston.split_frame(ratios=[.8]) >>> boston_glm = H2OGeneralizedLinearEstimator(standardize=True) >>> boston_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> boston_glm.mse()
-
property
startval
¶ double array to initialize fixed and random coefficients for HGLM, coefficients for GLM.
Type:
List[float]
.
-
property
stopping_metric
¶ Metric to use for early stopping (AUTO: logloss for classification, deviance for regression and anomaly_score for Isolation Forest). Note that custom and custom_increasing can only be used in GBM and DRF with the Python client.
Type:
Literal["auto", "deviance", "logloss", "mse", "rmse", "mae", "rmsle", "auc", "aucpr", "lift_top_group", "misclassification", "mean_per_class_error", "custom", "custom_increasing"]
, defaults to"auto"
.
-
property
stopping_rounds
¶ Early stopping based on convergence of stopping_metric. Stop if simple moving average of length k of the stopping_metric does not improve for k:=stopping_rounds scoring events (0 to disable)
Type:
int
, defaults to0
.
-
property
stopping_tolerance
¶ Relative tolerance for metric-based stopping criterion (stop if relative improvement is not at least this much)
Type:
float
, defaults to0.001
.
-
property
theta
¶ Theta
Type:
float
, defaults to1e-10
.- Examples
>>> h2o_df = h2o.import_file("http://h2o-public-test-data.s3.amazonaws.com/smalldata/glm_test/Motor_insurance_sweden.txt") >>> predictors = ["Payment", "Insured", "Kilometres", "Zone", "Bonus", "Make"] >>> response = "Claims" >>> negativebinomial_fit = H2OGeneralizedLinearEstimator(family="negativebinomial", ... link="identity", ... theta=0.5) >>> negativebinomial_fit.train(x=predictors, ... y=response, ... training_frame=h2o_df) >>> negativebinomial_fit.scoring_history()
-
property
training_frame
¶ Id of the training data frame.
Type:
Union[None, str, H2OFrame]
.- Examples
>>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv") >>> cars["economy_20mpg"] = cars["economy_20mpg"].asfactor() >>> predictors = ["displacement","power","weight","acceleration","year"] >>> response = "economy_20mpg" >>> train, valid = cars.split_frame(ratios=[.8], ... seed=1234) >>> cars_glm = H2OGeneralizedLinearEstimator(seed=1234, ... family='binomial') >>> cars_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> cars_glm.auc(train=True)
-
property
tweedie_epsilon
¶ In estimating tweedie dispersion parameter using maximum likelihood, this is used to choose the lower and upper indices in the approximating of the infinite series summation.
Type:
float
, defaults to8e-17
.
-
property
tweedie_link_power
¶ Tweedie link power
Type:
float
, defaults to1.0
.- Examples
>>> auto = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/glm_test/auto.csv") >>> predictors = auto.names >>> predictors.remove('y') >>> response = "y" >>> train, valid = auto.split_frame(ratios=[.8]) >>> auto_glm = H2OGeneralizedLinearEstimator(family='tweedie', ... tweedie_link_power=1) >>> auto_glm.train(x=predictors, ... y=response, ... training_frame=train, ... validation_frame=valid) >>> print(auto_glm.mse(valid=True))
-
property
tweedie_variance_power
¶ Tweedie variance power
Type:
float
, defaults to0.0
.- Examples
>>> auto = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/glm_test/auto.csv"
-
property