Modeling In H2O

Supervised

H2ODeepLearningEstimator

class h2o.estimators.deeplearning.H2ODeepLearningEstimator(**kwargs)[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

>>> import h2o
>>> from h2o.estimators.deeplearning import H2ODeepLearningEstimator
>>> h2o.connect()
>>> 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)
activation

Activation function.

One of: "tanh", "tanh_with_dropout", "rectifier", "rectifier_with_dropout", "maxout", "maxout_with_dropout" (default: "rectifier").

adaptive_rate

Adaptive learning rate.

Type: bool (default: True).

autoencoder

Auto-Encoder.

Type: bool (default: False).

average_activation

Average activation for sparse auto-encoder. #Experimental

Type: float (default: 0).

balance_classes

Balance training data class counts via over/under-sampling (for imbalanced data).

Type: bool (default: False).

categorical_encoding

Encoding scheme for categorical features

One of: "auto", "enum", "one_hot_internal", "one_hot_explicit", "binary", "eigen", "label_encoder", "sort_by_response", "enum_limited" (default: "auto").

checkpoint

Model checkpoint to resume training with.

Type: str.

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].

classification_stop

Stopping criterion for classification error fraction on training data (-1 to disable).

Type: float (default: 0).

col_major

#DEPRECATED Use a column major weight matrix for input layer. Can speed up forward propagation, but might slow down backpropagation.

Type: bool (default: False).

diagnostics

Enable diagnostics for hidden layers.

Type: bool (default: True).

distribution

Distribution function

One of: "auto", "bernoulli", "multinomial", "gaussian", "poisson", "gamma", "tweedie", "laplace", "quantile", "huber" (default: "auto").

elastic_averaging

Elastic averaging between compute nodes can improve distributed model convergence. #Experimental

Type: bool (default: False).

elastic_averaging_moving_rate

Elastic averaging moving rate (only if elastic averaging is enabled).

Type: float (default: 0.9).

elastic_averaging_regularization

Elastic averaging regularization strength (only if elastic averaging is enabled).

Type: float (default: 0.001).

epochs

How many times the dataset should be iterated (streamed), can be fractional.

Type: float (default: 10).

epsilon

Adaptive learning rate smoothing factor (to avoid divisions by zero and allow progress).

Type: float (default: 1e-08).

export_weights_and_biases

Whether to export Neural Network weights and biases to H2O Frames.

Type: bool (default: False).

fast_mode

Enable fast mode (minor approximation in back-propagation).

Type: bool (default: True).

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.

One of: "auto", "random", "modulo", "stratified" (default: "auto").

fold_column

Column with cross-validation fold index assignment per observation.

Type: str.

force_load_balance

Force extra load balancing to increase training speed for small datasets (to keep all cores busy).

Type: bool (default: True).

hidden

Hidden layer sizes (e.g. [100, 100]).

Type: List[int] (default: [200, 200]).

hidden_dropout_ratios

Hidden layer dropout ratios (can improve generalization), specify one value per hidden layer, defaults to 0.5.

Type: List[float].

huber_alpha

Desired quantile for Huber/M-regression (threshold between quadratic and linear loss, must be between 0 and 1).

Type: float (default: 0.9).

ignore_const_cols

Ignore constant columns.

Type: bool (default: True).

ignored_columns

Names of columns to ignore for training.

Type: List[str].

initial_biases

A list of H2OFrame ids to initialize the bias vectors of this model with.

Type: List[H2OFrame].

initial_weight_distribution

Initial weight distribution.

One of: "uniform_adaptive", "uniform", "normal" (default: "uniform_adaptive").

initial_weight_scale

Uniform: -value...value, Normal: stddev.

Type: float (default: 1).

initial_weights

A list of H2OFrame ids to initialize the weight matrices of this model with.

Type: List[H2OFrame].

input_dropout_ratio

Input layer dropout ratio (can improve generalization, try 0.1 or 0.2).

Type: float (default: 0).

keep_cross_validation_fold_assignment

Whether to keep the cross-validation fold assignment.

Type: bool (default: False).

keep_cross_validation_predictions

Whether to keep the predictions of the cross-validation models.

Type: bool (default: False).

l1

L1 regularization (can add stability and improve generalization, causes many weights to become 0).

Type: float (default: 0).

l2

L2 regularization (can add stability and improve generalization, causes many weights to be small.

Type: float (default: 0).

loss

Loss function.

One of: "automatic", "cross_entropy", "quadratic", "huber", "absolute", "quantile" (default: "automatic").

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 (default: 5).

max_categorical_features

Max. number of categorical features, enforced via hashing. #Experimental

Type: int (default: 2147483647).

max_confusion_matrix_size

[Deprecated] Maximum size (# classes) for confusion matrices to be printed in the Logs.

Type: int (default: 20).

max_hit_ratio_k

Max. number (top K) of predictions to use for hit ratio computation (for multi-class only, 0 to disable).

Type: int (default: 0).

max_runtime_secs

Maximum allowed runtime in seconds for model training. Use 0 to disable.

Type: float (default: 0).

max_w2

Constraint for squared sum of incoming weights per unit (e.g. for Rectifier).

Type: float (default: 3.4028235e+38).

mini_batch_size

Mini-batch size (smaller leads to better fit, larger can speed up and generalize better).

Type: int (default: 1).

missing_values_handling

Handling of missing values. Either MeanImputation or Skip.

One of: "mean_imputation", "skip" (default: "mean_imputation").

momentum_ramp

Number of training samples for which momentum increases.

Type: float (default: 1000000).

momentum_stable

Final momentum after the ramp is over (try 0.99).

Type: float (default: 0).

momentum_start

Initial momentum at the beginning of training (try 0.5).

Type: float (default: 0).

nesterov_accelerated_gradient

Use Nesterov accelerated gradient (recommended).

Type: bool (default: True).

nfolds

Number of folds for N-fold cross-validation (0 to disable or >= 2).

Type: int (default: 0).

offset_column

Offset column. This will be added to the combination of columns before applying the link function.

Type: str.

overwrite_with_best_model

If enabled, override the final model with the best model found during training.

Type: bool (default: True).

pretrained_autoencoder

Pretrained autoencoder model to initialize this model with.

Type: str.

quantile_alpha

Desired quantile for Quantile regression, must be between 0 and 1.

Type: float (default: 0.5).

quiet_mode

Enable quiet mode for less output to standard output.

Type: bool (default: False).

rate

Learning rate (higher => less stable, lower => slower convergence).

Type: float (default: 0.005).

rate_annealing

Learning rate annealing: rate / (1 + rate_annealing * samples).

Type: float (default: 1e-06).

rate_decay

Learning rate decay factor between layers (N-th layer: rate * rate_decay ^ (n - 1).

Type: float (default: 1).

regression_stop

Stopping criterion for regression error (MSE) on training data (-1 to disable).

Type: float (default: 1e-06).

replicate_training_data

Replicate the entire training dataset onto every node for faster training on small datasets.

Type: bool (default: True).

reproducible

Force reproducibility on small data (will be slow - only uses 1 thread).

Type: bool (default: False).

response_column

Response variable column.

Type: str.

rho

Adaptive learning rate time decay factor (similarity to prior updates).

Type: float (default: 0.99).

score_duty_cycle

Maximum duty cycle fraction for scoring (lower: more training, higher: more scoring).

Type: float (default: 0.1).

score_each_iteration

Whether to score during each iteration of model training.

Type: bool (default: False).

score_interval

Shortest time interval (in seconds) between model scoring.

Type: float (default: 5).

score_training_samples

Number of training set samples for scoring (0 for all).

Type: int (default: 10000).

score_validation_samples

Number of validation set samples for scoring (0 for all).

Type: int (default: 0).

score_validation_sampling

Method used to sample validation dataset for scoring.

One of: "uniform", "stratified" (default: "uniform").

seed

Seed for random numbers (affects sampling) - Note: only reproducible when running single threaded.

Type: int (default: -1).

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 (default: False).

single_node_mode

Run on a single node for fine-tuning of model parameters.

Type: bool (default: False).

sparse

Sparse data handling (more efficient for data with lots of 0 values).

Type: bool (default: False).

sparsity_beta

Sparsity regularization. #Experimental

Type: float (default: 0).

standardize

If enabled, automatically standardize the data. If disabled, the user must provide properly scaled input data.

Type: bool (default: True).

stopping_metric

Metric to use for early stopping (AUTO: logloss for classification, deviance for regression)

One of: "auto", "deviance", "logloss", "mse", "rmse", "mae", "rmsle", "auc", "lift_top_group", "misclassification", "mean_per_class_error" (default: "auto").

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 (default: 5).

stopping_tolerance

Relative tolerance for metric-based stopping criterion (stop if relative improvement is not at least this much)

Type: float (default: 0).

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 (default: 0.05).

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 (default: -2).

training_frame

Id of the training data frame (Not required, to allow initial validation of model parameters).

Type: H2OFrame.

tweedie_power

Tweedie power for Tweedie regression, must be between 1 and 2.

Type: float (default: 1.5).

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 (default: True).

validation_frame

Id of the validation data frame.

Type: H2OFrame.

variable_importances

Compute variable importances for input features (Gedeon method) - can be slow for large networks.

Type: bool (default: True).

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.

Type: str.

H2ODeepWaterEstimator

class h2o.estimators.deepwater.H2ODeepWaterEstimator(**kwargs)[source]

Bases: h2o.estimators.estimator_base.H2OEstimator

Deep Water

Build a Deep Learning model using multiple native GPU backends Builds a deep neural network on an H2OFrame containing various data sources

activation

Activation function. Only used if no user-defined network architecture file is provided, and only for problem_type=dataset.

One of: "rectifier", "tanh".

autoencoder

Auto-Encoder.

Type: bool (default: False).

static available()[source]

Returns True if a deep water model can be built, or False otherwise.

backend

Deep Learning Backend.

One of: "mxnet", "caffe", "tensorflow" (default: "mxnet").

balance_classes

Balance training data class counts via over/under-sampling (for imbalanced data).

Type: bool (default: False).

cache_data

Whether to cache the data in memory (automatically disabled if data size is too large).

Type: bool (default: True).

categorical_encoding

Encoding scheme for categorical features

One of: "auto", "enum", "one_hot_internal", "one_hot_explicit", "binary", "eigen", "label_encoder", "sort_by_response", "enum_limited" (default: "auto").

channels

Number of (color) channels.

Type: int (default: 3).

checkpoint

Model checkpoint to resume training with.

Type: str.

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].

classification_stop

Stopping criterion for classification error fraction on training data (-1 to disable).

Type: float (default: 0).

clip_gradient

Clip gradients once their absolute value is larger than this value.

Type: float (default: 10).

device_id

Device IDs (which GPUs to use).

Type: List[int] (default: [0]).

distribution

Distribution function

One of: "auto", "bernoulli", "multinomial", "gaussian", "poisson", "gamma", "tweedie", "laplace", "quantile", "huber" (default: "auto").

epochs

How many times the dataset should be iterated (streamed), can be fractional.

Type: float (default: 10).

export_native_parameters_prefix

Path (prefix) where to export the native model parameters after every iteration.

Type: str.

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.

One of: "auto", "random", "modulo", "stratified" (default: "auto").

fold_column

Column with cross-validation fold index assignment per observation.

Type: str.

gpu

Whether to use a GPU (if available).

Type: bool (default: True).

hidden

Hidden layer sizes (e.g. [200, 200]). Only used if no user-defined network architecture file is provided, and only for problem_type=dataset.

Type: List[int].

hidden_dropout_ratios

Hidden layer dropout ratios (can improve generalization), specify one value per hidden layer, defaults to 0.5.

Type: List[float].

ignore_const_cols

Ignore constant columns.

Type: bool (default: True).

ignored_columns

Names of columns to ignore for training.

Type: List[str].

image_shape

Width and height of image.

Type: List[int] (default: [0, 0]).

input_dropout_ratio

Input layer dropout ratio (can improve generalization, try 0.1 or 0.2).

Type: float (default: 0).

keep_cross_validation_fold_assignment

Whether to keep the cross-validation fold assignment.

Type: bool (default: False).

keep_cross_validation_predictions

Whether to keep the predictions of the cross-validation models.

Type: bool (default: False).

learning_rate

Learning rate (higher => less stable, lower => slower convergence).

Type: float (default: 0.001).

learning_rate_annealing

Learning rate annealing: rate / (1 + rate_annealing * samples).

Type: float (default: 1e-06).

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 (default: 5).

max_runtime_secs

Maximum allowed runtime in seconds for model training. Use 0 to disable.

Type: float (default: 0).

mean_image_file

Path of file containing the mean image data for data normalization.

Type: str.

mini_batch_size

Mini-batch size (smaller leads to better fit, larger can speed up and generalize better).

Type: int (default: 32).

momentum_ramp

Number of training samples for which momentum increases.

Type: float (default: 10000).

momentum_stable

Final momentum after the ramp is over (try 0.99).

Type: float (default: 0.9).

momentum_start

Initial momentum at the beginning of training (try 0.5).

Type: float (default: 0.9).

network

Network architecture.

One of: "auto", "user", "lenet", "alexnet", "vgg", "googlenet", "inception_bn", "resnet" (default: "auto").

network_definition_file

Path of file containing network definition (graph, architecture).

Type: str.

network_parameters_file

Path of file containing network (initial) parameters (weights, biases).

Type: str.

nfolds

Number of folds for N-fold cross-validation (0 to disable or >= 2).

Type: int (default: 0).

offset_column

Offset column. This will be added to the combination of columns before applying the link function.

Type: str.

overwrite_with_best_model

If enabled, override the final model with the best model found during training.

Type: bool (default: True).

problem_type

Problem type, auto-detected by default. If set to image, the H2OFrame must contain a string column containing the path (URI or URL) to the images in the first column. If set to text, the H2OFrame must contain a string column containing the text in the first column. If set to dataset, Deep Water behaves just like any other H2O Model and builds a model on the provided H2OFrame (non-String columns).

One of: "auto", "image", "dataset" (default: "auto").

regression_stop

Stopping criterion for regression error (MSE) on training data (-1 to disable).

Type: float (default: 0).

response_column

Response variable column.

Type: str.

score_duty_cycle

Maximum duty cycle fraction for scoring (lower: more training, higher: more scoring).

Type: float (default: 0.1).

score_each_iteration

Whether to score during each iteration of model training.

Type: bool (default: False).

score_interval

Shortest time interval (in seconds) between model scoring.

Type: float (default: 5).

score_training_samples

Number of training set samples for scoring (0 for all).

Type: int (default: 10000).

score_validation_samples

Number of validation set samples for scoring (0 for all).

Type: int (default: 0).

seed

Seed for random numbers (affects sampling) - Note: only reproducible when running single threaded.

Type: int (default: -1).

shuffle_training_data

Enable global shuffling of training data.

Type: bool (default: True).

sparse

Sparse data handling (more efficient for data with lots of 0 values).

Type: bool (default: False).

standardize

If enabled, automatically standardize the data. If disabled, the user must provide properly scaled input data.

Type: bool (default: True).

stopping_metric

Metric to use for early stopping (AUTO: logloss for classification, deviance for regression)

One of: "auto", "deviance", "logloss", "mse", "rmse", "mae", "rmsle", "auc", "lift_top_group", "misclassification", "mean_per_class_error" (default: "auto").

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 (default: 5).

stopping_tolerance

Relative tolerance for metric-based stopping criterion (stop if relative improvement is not at least this much)

Type: float (default: 0).

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 (default: 0.05).

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 (default: -2).

training_frame

Id of the training data frame (Not required, to allow initial validation of model parameters).

Type: H2OFrame.

validation_frame

Id of the validation data frame.

Type: H2OFrame.

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.

Type: str.

H2OGradientBoostingEstimator

class h2o.estimators.gbm.H2OGradientBoostingEstimator(**kwargs)[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.

balance_classes

Balance training data class counts via over/under-sampling (for imbalanced data).

Type: bool (default: False).

build_tree_one_node

Run on one node only; no network overhead but fewer cpus used. Suitable for small datasets.

Type: bool (default: False).

calibrate_model

Use Platt Scaling to calculate calibrated class probabilities. Calibration can provide more accurate estimates of class probabilities.

Type: bool (default: False).

calibration_frame

Calibration frame for Platt Scaling

Type: H2OFrame.

categorical_encoding

Encoding scheme for categorical features

One of: "auto", "enum", "one_hot_internal", "one_hot_explicit", "binary", "eigen", "label_encoder", "sort_by_response", "enum_limited" (default: "auto").

checkpoint

Model checkpoint to resume training with.

Type: str.

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].

col_sample_rate

Column sample rate (from 0.0 to 1.0)

Type: float (default: 1).

col_sample_rate_change_per_level

Relative change of the column sampling rate for every level (from 0.0 to 2.0)

Type: float (default: 1).

col_sample_rate_per_tree

Column sample rate per tree (from 0.0 to 1.0)

Type: float (default: 1).

distribution

Distribution function

One of: "auto", "bernoulli", "multinomial", "gaussian", "poisson", "gamma", "tweedie", "laplace", "quantile", "huber" (default: "auto").

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.

One of: "auto", "random", "modulo", "stratified" (default: "auto").

fold_column

Column with cross-validation fold index assignment per observation.

Type: str.

histogram_type

What type of histogram to use for finding optimal split points

One of: "auto", "uniform_adaptive", "random", "quantiles_global", "round_robin" (default: "auto").

huber_alpha

Desired quantile for Huber/M-regression (threshold between quadratic and linear loss, must be between 0 and 1).

Type: float (default: 0.9).

ignore_const_cols

Ignore constant columns.

Type: bool (default: True).

ignored_columns

Names of columns to ignore for training.

Type: List[str].

keep_cross_validation_fold_assignment

Whether to keep the cross-validation fold assignment.

Type: bool (default: False).

keep_cross_validation_predictions

Whether to keep the predictions of the cross-validation models.

Type: bool (default: False).

learn_rate

Learning rate (from 0.0 to 1.0)

Type: float (default: 0.1).

learn_rate_annealing

Scale the learning rate by this factor after each tree (e.g., 0.99 or 0.999)

Type: float (default: 1).

max_abs_leafnode_pred

Maximum absolute value of a leaf node prediction

Type: float (default: 1.797693135e+308).

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 (default: 5).

max_confusion_matrix_size

[Deprecated] Maximum size (# classes) for confusion matrices to be printed in the Logs

Type: int (default: 20).

max_depth

Maximum tree depth.

Type: int (default: 5).

max_hit_ratio_k

Max. number (top K) of predictions to use for hit ratio computation (for multi-class only, 0 to disable)

Type: int (default: 0).

max_runtime_secs

Maximum allowed runtime in seconds for model training. Use 0 to disable.

Type: float (default: 0).

min_rows

Fewest allowed (weighted) observations in a leaf.

Type: float (default: 10).

min_split_improvement

Minimum relative improvement in squared error reduction for a split to happen

Type: float (default: 1e-05).

nbins

For numerical columns (real/int), build a histogram of (at least) this many bins, then split at the best point

Type: int (default: 20).

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 (default: 1024).

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 (default: 1024).

nfolds

Number of folds for N-fold cross-validation (0 to disable or >= 2).

Type: int (default: 0).

ntrees

Number of trees.

Type: int (default: 50).

offset_column

Offset column. This will be added to the combination of columns before applying the link function.

Type: str.

pred_noise_bandwidth

Bandwidth (sigma) of Gaussian multiplicative noise ~N(1,sigma) for tree node predictions

Type: float (default: 0).

quantile_alpha

Desired quantile for Quantile regression, must be between 0 and 1.

Type: float (default: 0.5).

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 (default: 1.797693135e+308).

response_column

Response variable column.

Type: str.

sample_rate

Row sample rate per tree (from 0.0 to 1.0)

Type: float (default: 1).

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].

score_each_iteration

Whether to score during each iteration of model training.

Type: bool (default: False).

score_tree_interval

Score the model after every so many trees. Disabled if set to 0.

Type: int (default: 0).

seed

Seed for pseudo random number generator (if applicable)

Type: int (default: -1).

stopping_metric

Metric to use for early stopping (AUTO: logloss for classification, deviance for regression)

One of: "auto", "deviance", "logloss", "mse", "rmse", "mae", "rmsle", "auc", "lift_top_group", "misclassification", "mean_per_class_error" (default: "auto").

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 (default: 0).

stopping_tolerance

Relative tolerance for metric-based stopping criterion (stop if relative improvement is not at least this much)

Type: float (default: 0.001).

training_frame

Id of the training data frame (Not required, to allow initial validation of model parameters).

Type: H2OFrame.

tweedie_power

Tweedie power for Tweedie regression, must be between 1 and 2.

Type: float (default: 1.5).

validation_frame

Id of the validation data frame.

Type: H2OFrame.

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.

Type: str.

H2OGeneralizedLinearEstimator

class h2o.estimators.glm.H2OGeneralizedLinearEstimator(**kwargs)[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.

Lambda

DEPRECATED. Use self.lambda_ instead

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].

balance_classes

Balance training data class counts via over/under-sampling (for imbalanced data).

Type: bool (default: False).

beta_constraints

Beta constraints

Type: H2OFrame.

beta_epsilon

Converge if beta changes less (using L-infinity norm) than beta esilon, ONLY applies to IRLSM solver

Type: float (default: 0.0001).

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].

compute_p_values

Request p-values computation, p-values work only with IRLSM solver and no regularization

Type: bool (default: False).

early_stopping

Stop early when there is no more relative improvement on train or validation (if provided)

Type: bool (default: True).

family

Family. Use binomial for classification with logistic regression, others are for regression problems.

One of: "gaussian", "binomial", "quasibinomial", "multinomial", "poisson", "gamma", "tweedie" (default: "gaussian").

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.

One of: "auto", "random", "modulo", "stratified" (default: "auto").

fold_column

Column with cross-validation fold index assignment per observation.

Type: str.

static getGLMRegularizationPath(model)[source]

Extract full regularization path explored during lambda search from glm model.

Parameters:model – source lambda search model
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 (default: -1).

ignore_const_cols

Ignore constant columns.

Type: bool (default: True).

ignored_columns

Names of columns to ignore for training.

Type: List[str].

interactions

A list of predictor column indices to interact. All pairwise combinations will be computed for the list.

Type: List[str].

intercept

Include constant term in the model

Type: bool (default: True).

keep_cross_validation_fold_assignment

Whether to keep the cross-validation fold assignment.

Type: bool (default: False).

keep_cross_validation_predictions

Whether to keep the predictions of the cross-validation models.

Type: bool (default: False).

lambda_

Regularization strength

Type: List[float].

lambda_min_ratio

Minimum lambda used in lambda search, specified as a ratio of lambda_max. 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 (default: -1).

Use lambda search starting at lambda max, given lambda is then interpreted as lambda min

Type: bool (default: False).

One of: "family_default", "identity", "logit", "log", "inverse", "tweedie" (default: "family_default").

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
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 7000 otherwise it is set to 100000000.

Type: int (default: -1).

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 (default: 5).

max_confusion_matrix_size

[Deprecated] Maximum size (# classes) for confusion matrices to be printed in the Logs

Type: int (default: 20).

max_hit_ratio_k

Maximum number (top K) of predictions to use for hit ratio computation (for multi-class only, 0 to disable)

Type: int (default: 0).

max_iterations

Maximum number of iterations

Type: int (default: -1).

max_runtime_secs

Maximum allowed runtime in seconds for model training. Use 0 to disable.

Type: float (default: 0).

missing_values_handling

Handling of missing values. Either MeanImputation or Skip.

One of: "mean_imputation", "skip" (default: "mean_imputation").

nfolds

Number of folds for N-fold cross-validation (0 to disable or >= 2).

Type: int (default: 0).

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 (default: -1).

non_negative

Restrict coefficients (not intercept) to be non-negative

Type: bool (default: False).

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 (default: -1).

offset_column

Offset column. This will be added to the combination of columns before applying the link function.

Type: str.

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 (default: -1).

remove_collinear_columns

In case of linearly dependent columns, remove some of the dependent columns

Type: bool (default: False).

response_column

Response variable column.

Type: str.

score_each_iteration

Whether to score during each iteration of model training.

Type: bool (default: False).

seed

Seed for pseudo random number generator (if applicable)

Type: int (default: -1).

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. Coordinate descent is experimental (beta).

One of: "auto", "irlsm", "l_bfgs", "coordinate_descent_naive", "coordinate_descent" (default: "auto").

standardize

Standardize numeric columns to have zero mean and unit variance

Type: bool (default: True).

training_frame

Id of the training data frame (Not required, to allow initial validation of model parameters).

Type: H2OFrame.

Tweedie link power

Type: float (default: 1).

tweedie_variance_power

Tweedie variance power

Type: float (default: 0).

validation_frame

Id of the validation data frame.

Type: H2OFrame.

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.

Type: str.

H2ONaiveBayesEstimator

class h2o.estimators.naive_bayes.H2ONaiveBayesEstimator(**kwargs)[source]

Bases: h2o.estimators.estimator_base.H2OEstimator

Naive Bayes

The naive Bayes classifier assumes independence between predictor variables conditional on the response, and a Gaussian distribution of numeric predictors with mean and standard deviation computed from the training dataset. When building a naive Bayes classifier, every row in the training dataset that contains at least one NA will be skipped completely. If the test dataset has missing values, then those predictors are omitted in the probability calculation during prediction.

balance_classes

Balance training data class counts via over/under-sampling (for imbalanced data).

Type: bool (default: False).

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].

compute_metrics

Compute metrics on training data

Type: bool (default: True).

eps_prob

Cutoff below which probability is replaced with min_prob

Type: float (default: 0).

eps_sdev

Cutoff below which standard deviation is replaced with min_sdev

Type: float (default: 0).

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.

One of: "auto", "random", "modulo", "stratified" (default: "auto").

fold_column

Column with cross-validation fold index assignment per observation.

Type: str.

ignore_const_cols

Ignore constant columns.

Type: bool (default: True).

ignored_columns

Names of columns to ignore for training.

Type: List[str].

keep_cross_validation_fold_assignment

Whether to keep the cross-validation fold assignment.

Type: bool (default: False).

keep_cross_validation_predictions

Whether to keep the predictions of the cross-validation models.

Type: bool (default: False).

laplace

Laplace smoothing parameter

Type: float (default: 0).

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 (default: 5).

max_confusion_matrix_size

[Deprecated] Maximum size (# classes) for confusion matrices to be printed in the Logs

Type: int (default: 20).

max_hit_ratio_k

Max. number (top K) of predictions to use for hit ratio computation (for multi-class only, 0 to disable)

Type: int (default: 0).

max_runtime_secs

Maximum allowed runtime in seconds for model training. Use 0 to disable.

Type: float (default: 0).

min_prob

Min. probability to use for observations with not enough data

Type: float (default: 0.001).

min_sdev

Min. standard deviation to use for observations with not enough data

Type: float (default: 0.001).

nfolds

Number of folds for N-fold cross-validation (0 to disable or >= 2).

Type: int (default: 0).

response_column

Response variable column.

Type: str.

score_each_iteration

Whether to score during each iteration of model training.

Type: bool (default: False).

seed

Seed for pseudo random number generator (only used for cross-validation and fold_assignment=”Random” or “AUTO”)

Type: int (default: -1).

training_frame

Id of the training data frame (Not required, to allow initial validation of model parameters).

Type: H2OFrame.

validation_frame

Id of the validation data frame.

Type: H2OFrame.

H2ORandomForestEstimator

class h2o.estimators.random_forest.H2ORandomForestEstimator(**kwargs)[source]

Bases: h2o.estimators.estimator_base.H2OEstimator

Distributed Random Forest

balance_classes

Balance training data class counts via over/under-sampling (for imbalanced data).

Type: bool (default: False).

binomial_double_trees

For binary classification: Build 2x as many trees (one per class) - can lead to higher accuracy.

Type: bool (default: False).

build_tree_one_node

Run on one node only; no network overhead but fewer cpus used. Suitable for small datasets.

Type: bool (default: False).

calibrate_model

Use Platt Scaling to calculate calibrated class probabilities. Calibration can provide more accurate estimates of class probabilities.

Type: bool (default: False).

calibration_frame

Calibration frame for Platt Scaling

Type: H2OFrame.

categorical_encoding

Encoding scheme for categorical features

One of: "auto", "enum", "one_hot_internal", "one_hot_explicit", "binary", "eigen", "label_encoder", "sort_by_response", "enum_limited" (default: "auto").

checkpoint

Model checkpoint to resume training with.

Type: str.

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].

col_sample_rate_change_per_level

Relative change of the column sampling rate for every level (from 0.0 to 2.0)

Type: float (default: 1).

col_sample_rate_per_tree

Column sample rate per tree (from 0.0 to 1.0)

Type: float (default: 1).

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.

One of: "auto", "random", "modulo", "stratified" (default: "auto").

fold_column

Column with cross-validation fold index assignment per observation.

Type: str.

histogram_type

What type of histogram to use for finding optimal split points

One of: "auto", "uniform_adaptive", "random", "quantiles_global", "round_robin" (default: "auto").

ignore_const_cols

Ignore constant columns.

Type: bool (default: True).

ignored_columns

Names of columns to ignore for training.

Type: List[str].

keep_cross_validation_fold_assignment

Whether to keep the cross-validation fold assignment.

Type: bool (default: False).

keep_cross_validation_predictions

Whether to keep the predictions of the cross-validation models.

Type: bool (default: False).

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 (default: 5).

max_confusion_matrix_size

[Deprecated] Maximum size (# classes) for confusion matrices to be printed in the Logs

Type: int (default: 20).

max_depth

Maximum tree depth.

Type: int (default: 20).

max_hit_ratio_k

Max. number (top K) of predictions to use for hit ratio computation (for multi-class only, 0 to disable)

Type: int (default: 0).

max_runtime_secs

Maximum allowed runtime in seconds for model training. Use 0 to disable.

Type: float (default: 0).

min_rows

Fewest allowed (weighted) observations in a leaf.

Type: float (default: 1).

min_split_improvement

Minimum relative improvement in squared error reduction for a split to happen

Type: float (default: 1e-05).

mtries

Number of variables randomly sampled as candidates at each split. If set to -1, defaults to sqrt{p} for classification and p/3 for regression (where p is the # of predictors

Type: int (default: -1).

nbins

For numerical columns (real/int), build a histogram of (at least) this many bins, then split at the best point

Type: int (default: 20).

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 (default: 1024).

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 (default: 1024).

nfolds

Number of folds for N-fold cross-validation (0 to disable or >= 2).

Type: int (default: 0).

ntrees

Number of trees.

Type: int (default: 50).

offset_column

Offset column. This will be added to the combination of columns before applying the link function.

Type: str.

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 (default: 1.797693135e+308).

response_column

Response variable column.

Type: str.

sample_rate

Row sample rate per tree (from 0.0 to 1.0)

Type: float (default: 0.6320000291).

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].

score_each_iteration

Whether to score during each iteration of model training.

Type: bool (default: False).

score_tree_interval

Score the model after every so many trees. Disabled if set to 0.

Type: int (default: 0).

seed

Seed for pseudo random number generator (if applicable)

Type: int (default: -1).

stopping_metric

Metric to use for early stopping (AUTO: logloss for classification, deviance for regression)

One of: "auto", "deviance", "logloss", "mse", "rmse", "mae", "rmsle", "auc", "lift_top_group", "misclassification", "mean_per_class_error" (default: "auto").

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 (default: 0).

stopping_tolerance

Relative tolerance for metric-based stopping criterion (stop if relative improvement is not at least this much)

Type: float (default: 0.001).

training_frame

Id of the training data frame (Not required, to allow initial validation of model parameters).

Type: H2OFrame.

validation_frame

Id of the validation data frame.

Type: H2OFrame.

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.

Type: str.

H2OStackedEnsembleEstimator

class h2o.estimators.stackedensemble.H2OStackedEnsembleEstimator(**kwargs)[source]

Bases: h2o.estimators.estimator_base.H2OEstimator

Stacked Ensemble

Builds a stacked ensemble (aka “super learner”) machine learning method that uses two or more H2O learning algorithms to improve predictive performance. It is a loss-based supervised learning method that finds the optimal combination of a collection of prediction algorithms.This method supports regression and binary classification.

Examples

>>> import h2o
>>> h2o.init()
>>> from h2o.estimators.random_forest import H2ORandomForestEstimator
>>> from h2o.estimators.gbm import H2OGradientBoostingEstimator
>>> from h2o.estimators.stackedensemble import H2OStackedEnsembleEstimator
>>> col_types = ["numeric", "numeric", "numeric", "enum", "enum", "numeric", "numeric", "numeric", "numeric"]
>>> data = h2o.import_file("http://h2o-public-test-data.s3.amazonaws.com/smalldata/prostate/prostate.csv", col_types=col_types)
>>> train, test = data.split_frame(ratios=[.8], seed=1)
>>> x = ["CAPSULE","GLEASON","RACE","DPROS","DCAPS","PSA","VOL"]
>>> y = "AGE"
>>> nfolds = 5
>>> my_gbm = H2OGradientBoostingEstimator(nfolds=nfolds, fold_assignment="Modulo", keep_cross_validation_predictions=True)
>>> my_gbm.train(x=x, y=y, training_frame=train)
>>> my_rf = H2ORandomForestEstimator(nfolds=nfolds, fold_assignment="Modulo", keep_cross_validation_predictions=True)
>>> my_rf.train(x=x, y=y, training_frame=train)
>>> stack = H2OStackedEnsembleEstimator(model_id="my_ensemble", training_frame=train, validation_frame=test, base_models=[my_gbm.model_id, my_rf.model_id])
>>> stack.train(x=x, y=y, training_frame=train, validation_frame=test)
>>> stack.model_performance()
base_models

List of model ids which we can stack together. Models must have been cross-validated using nfolds > 1, and folds must be identical across models.

Type: List[str] (default: []).

response_column

Response variable column.

Type: str.

training_frame

Id of the training data frame (Not required, to allow initial validation of model parameters).

Type: H2OFrame.

validation_frame

Id of the validation data frame.

Type: H2OFrame.

H2OXGBoostEstimator

class h2o.estimators.xgboost.H2OXGBoostEstimator(**kwargs)[source]

Bases: h2o.estimators.estimator_base.H2OEstimator

XGBoost

Builds a eXtreme Gradient Boosting model using the native XGBoost backend.

static available()[source]

Returns True if a XGBoost model can be built, or False otherwise.

backend

Backend. By default (auto), a GPU is used if available.

One of: "auto", "gpu", "cpu" (default: "auto").

booster

Booster type

One of: "gbtree", "gblinear", "dart" (default: "gbtree").

categorical_encoding

Encoding scheme for categorical features

One of: "auto", "enum", "one_hot_internal", "one_hot_explicit", "binary", "eigen", "label_encoder", "sort_by_response", "enum_limited" (default: "label_encoder").

col_sample_rate

(same as colsample_bylevel) Column sample rate (from 0.0 to 1.0)

Type: float (default: 1).

col_sample_rate_per_tree

(same as colsample_bytree) Column sample rate per tree (from 0.0 to 1.0)

Type: float (default: 1).

colsample_bylevel

(same as col_sample_rate) Column sample rate (from 0.0 to 1.0)

Type: float (default: 1).

colsample_bytree

(same as col_sample_rate_per_tree) Column sample rate per tree (from 0.0 to 1.0)

Type: float (default: 1).

distribution

Distribution function

One of: "auto", "bernoulli", "multinomial", "gaussian", "poisson", "gamma", "tweedie", "laplace", "quantile", "huber" (default: "auto").

dmatrix_type

Type of DMatrix. For sparse, NAs and 0 are treated equally.

One of: "auto", "dense", "sparse" (default: "auto").

eta

(same as learn_rate) Learning rate (from 0.0 to 1.0)

Type: float (default: 0.3).

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.

One of: "auto", "random", "modulo", "stratified" (default: "auto").

fold_column

Column with cross-validation fold index assignment per observation.

Type: str.

gamma

(same as min_split_improvement) Minimum relative improvement in squared error reduction for a split to happen

Type: float (default: 0).

gpu_id

Which GPU to use.

Type: int (default: 0).

grow_policy

Grow policy - depthwise is standard GBM, lossguide is LightGBM

One of: "depthwise", "lossguide" (default: "depthwise").

ignore_const_cols

Ignore constant columns.

Type: bool (default: True).

ignored_columns

Names of columns to ignore for training.

Type: List[str].

keep_cross_validation_fold_assignment

Whether to keep the cross-validation fold assignment.

Type: bool (default: False).

keep_cross_validation_predictions

Whether to keep the predictions of the cross-validation models.

Type: bool (default: False).

learn_rate

(same as eta) Learning rate (from 0.0 to 1.0)

Type: float (default: 0.3).

max_abs_leafnode_pred

(same as max_delta_step) Maximum absolute value of a leaf node prediction

Type: float (default: 0).

max_bins

For tree_method=hist only: maximum number of bins

Type: int (default: 256).

max_delta_step

(same as max_abs_leafnode_pred) Maximum absolute value of a leaf node prediction

Type: float (default: 0).

max_depth

Maximum tree depth.

Type: int (default: 6).

max_leaves

For tree_method=hist only: maximum number of leaves

Type: int (default: 0).

max_runtime_secs

Maximum allowed runtime in seconds for model training. Use 0 to disable.

Type: float (default: 0).

min_child_weight

(same as min_rows) Fewest allowed (weighted) observations in a leaf.

Type: float (default: 1).

min_data_in_leaf

For tree_method=hist only: the mininum data in a leaf to keep splitting

Type: float (default: 0).

min_rows

(same as min_child_weight) Fewest allowed (weighted) observations in a leaf.

Type: float (default: 1).

min_split_improvement

(same as gamma) Minimum relative improvement in squared error reduction for a split to happen

Type: float (default: 0).

min_sum_hessian_in_leaf

For tree_method=hist only: the mininum sum of hessian in a leaf to keep splitting

Type: float (default: 100).

nfolds

Number of folds for N-fold cross-validation (0 to disable or >= 2).

Type: int (default: 0).

normalize_type

For booster=dart only: normalize_type

One of: "tree", "forest" (default: "tree").

ntrees

(same as n_estimators) Number of trees.

Type: int (default: 50).

offset_column

Offset column. This will be added to the combination of columns before applying the link function.

Type: str.

one_drop

For booster=dart only: one_drop

Type: bool (default: False).

quiet_mode

Enable quiet mode

Type: bool (default: True).

rate_drop

For booster=dart only: rate_drop (0..1)

Type: float (default: 0).

reg_alpha

L1 regularization

Type: float (default: 0).

reg_lambda

L2 regularization

Type: float (default: 0).

response_column

Response variable column.

Type: str.

sample_rate

(same as subsample) Row sample rate per tree (from 0.0 to 1.0)

Type: float (default: 1).

sample_type

For booster=dart only: sample_type

One of: "uniform", "weighted" (default: "uniform").

score_each_iteration

Whether to score during each iteration of model training.

Type: bool (default: False).

score_tree_interval

Score the model after every so many trees. Disabled if set to 0.

Type: int (default: 0).

seed

Seed for pseudo random number generator (if applicable)

Type: int (default: -1).

skip_drop

For booster=dart only: skip_drop (0..1)

Type: float (default: 0).

stopping_metric

Metric to use for early stopping (AUTO: logloss for classification, deviance for regression)

One of: "auto", "deviance", "logloss", "mse", "rmse", "mae", "rmsle", "auc", "lift_top_group", "misclassification", "mean_per_class_error" (default: "auto").

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 (default: 0).

stopping_tolerance

Relative tolerance for metric-based stopping criterion (stop if relative improvement is not at least this much)

Type: float (default: 0.001).

subsample

(same as sample_rate) Row sample rate per tree (from 0.0 to 1.0)

Type: float (default: 1).

training_frame

Id of the training data frame (Not required, to allow initial validation of model parameters).

Type: H2OFrame.

tree_method

Tree method

One of: "auto", "exact", "approx", "hist" (default: "auto").

tweedie_power

Tweedie power for Tweedie regression, must be between 1 and 2.

Type: float (default: 1.5).

validation_frame

Id of the validation data frame.

Type: H2OFrame.

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.

Type: str.

Unsupervised

H2OAggregatorEstimator

class h2o.estimators.aggregator.H2OAggregatorEstimator(**kwargs)[source]

Bases: h2o.estimators.estimator_base.H2OEstimator

Aggregator

categorical_encoding

Encoding scheme for categorical features

One of: "auto", "enum", "one_hot_internal", "one_hot_explicit", "binary", "eigen", "label_encoder", "sort_by_response", "enum_limited" (default: "auto").

ignore_const_cols

Ignore constant columns.

Type: bool (default: True).

ignored_columns

Names of columns to ignore for training.

Type: List[str].

rel_tol_num_exemplars

Relative tolerance for number of exemplars (e.g, 0.5 is +/- 50%)

Type: float (default: 0.5).

response_column

Response variable column.

Type: str.

target_num_exemplars

Targeted number of exemplars

Type: int (default: 5000).

training_frame

Id of the training data frame (Not required, to allow initial validation of model parameters).

Type: H2OFrame.

transform

Transformation of training data

One of: "none", "standardize", "normalize", "demean", "descale" (default: "normalize").

H2OAutoEncoderEstimator

class h2o.estimators.deeplearning.H2OAutoEncoderEstimator(**kwargs)[source]

Bases: h2o.estimators.deeplearning.H2ODeepLearningEstimator

Examples

>>> import h2o as ml
>>> from h2o.estimators.deeplearning import H2OAutoEncoderEstimator
>>> ml.init()
>>> rows = [[1,2,3,4,0]*50, [2,1,2,4,1]*50, [2,1,4,2,1]*50, [0,1,2,34,1]*50, [2,3,4,1,0]*50]
>>> fr = ml.H2OFrame(rows)
>>> fr[4] = fr[4].asfactor()
>>> model = H2OAutoEncoderEstimator()
>>> model.train(x=range(4), training_frame=fr)

H2OGeneralizedLowRankEstimator

class h2o.estimators.glrm.H2OGeneralizedLowRankEstimator(**kwargs)[source]

Bases: h2o.estimators.estimator_base.H2OEstimator

Generalized Low Rank Modeling

Builds a generalized low rank model of a H2O dataset.

expand_user_y

Expand categorical columns in user-specified initial Y

Type: bool (default: True).

gamma_x

Regularization weight on X matrix

Type: float (default: 0).

gamma_y

Regularization weight on Y matrix

Type: float (default: 0).

ignore_const_cols

Ignore constant columns.

Type: bool (default: True).

ignored_columns

Names of columns to ignore for training.

Type: List[str].

impute_original

Reconstruct original training data by reversing transform

Type: bool (default: False).

init

Initialization mode

One of: "random", "svd", "plus_plus", "user" (default: "plus_plus").

init_step_size

Initial step size

Type: float (default: 1).

k

Rank of matrix approximation

Type: int (default: 1).

loading_name

Frame key to save resulting X

Type: str.

loss

Numeric loss function

One of: "quadratic", "absolute", "huber", "poisson", "hinge", "logistic", "periodic" (default: "quadratic").

loss_by_col

Loss function by column (override)

Type: List[Enum["quadratic", "absolute", "huber", "poisson", "hinge", "logistic", "periodic", "categorical", "ordinal"]].

loss_by_col_idx

Loss function by column index (override)

Type: List[int].

max_iterations

Maximum number of iterations

Type: int (default: 1000).

max_runtime_secs

Maximum allowed runtime in seconds for model training. Use 0 to disable.

Type: float (default: 0).

max_updates

Maximum number of updates, defaults to 2*max_iterations

Type: int (default: 2000).

min_step_size

Minimum step size

Type: float (default: 0.0001).

multi_loss

Categorical loss function

One of: "categorical", "ordinal" (default: "categorical").

period

Length of period (only used with periodic loss function)

Type: int (default: 1).

recover_svd

Recover singular values and eigenvectors of XY

Type: bool (default: False).

regularization_x

Regularization function for X matrix

One of: "none", "quadratic", "l2", "l1", "non_negative", "one_sparse", "unit_one_sparse", "simplex" (default: "none").

regularization_y

Regularization function for Y matrix

One of: "none", "quadratic", "l2", "l1", "non_negative", "one_sparse", "unit_one_sparse", "simplex" (default: "none").

score_each_iteration

Whether to score during each iteration of model training.

Type: bool (default: False).

seed

RNG seed for initialization

Type: int (default: -1).

svd_method

Method for computing SVD during initialization (Caution: Randomized is currently experimental and unstable)

One of: "gram_s_v_d", "power", "randomized" (default: "randomized").

training_frame

Id of the training data frame (Not required, to allow initial validation of model parameters).

Type: H2OFrame.

transform

Transformation of training data

One of: "none", "standardize", "normalize", "demean", "descale" (default: "none").

user_x

User-specified initial X

Type: H2OFrame.

user_y

User-specified initial Y

Type: H2OFrame.

validation_frame

Id of the validation data frame.

Type: H2OFrame.

H2OKMeansEstimator

class h2o.estimators.kmeans.H2OKMeansEstimator(**kwargs)[source]

Bases: h2o.estimators.estimator_base.H2OEstimator

K-means

Performs k-means clustering on an H2O dataset.

categorical_encoding

Encoding scheme for categorical features

One of: "auto", "enum", "one_hot_internal", "one_hot_explicit", "binary", "eigen", "label_encoder", "sort_by_response", "enum_limited" (default: "auto").

estimate_k

Whether to estimate the number of clusters (<=k) iteratively and deterministically.

Type: bool (default: False).

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.

One of: "auto", "random", "modulo", "stratified" (default: "auto").

fold_column

Column with cross-validation fold index assignment per observation.

Type: str.

ignore_const_cols

Ignore constant columns.

Type: bool (default: True).

ignored_columns

Names of columns to ignore for training.

Type: List[str].

init

Initialization mode

One of: "random", "plus_plus", "furthest", "user" (default: "furthest").

k

The max. number of clusters. If estimate_k is disabled, the model will find k centroids, otherwise it will find up to k centroids.

Type: int (default: 1).

keep_cross_validation_fold_assignment

Whether to keep the cross-validation fold assignment.

Type: bool (default: False).

keep_cross_validation_predictions

Whether to keep the predictions of the cross-validation models.

Type: bool (default: False).

max_iterations

Maximum training iterations (if estimate_k is enabled, then this is for each inner Lloyds iteration)

Type: int (default: 10).

max_runtime_secs

Maximum allowed runtime in seconds for model training. Use 0 to disable.

Type: float (default: 0).

nfolds

Number of folds for N-fold cross-validation (0 to disable or >= 2).

Type: int (default: 0).

score_each_iteration

Whether to score during each iteration of model training.

Type: bool (default: False).

seed

RNG Seed

Type: int (default: -1).

standardize

Standardize columns before computing distances

Type: bool (default: True).

training_frame

Id of the training data frame (Not required, to allow initial validation of model parameters).

Type: H2OFrame.

user_points

This option allows you to specify a dataframe, where each row represents an initial cluster center. The user- specified points must have the same number of columns as the training observations. The number of rows must equal the number of clusters

Type: H2OFrame.

validation_frame

Id of the validation data frame.

Type: H2OFrame.

H2OPrincipalComponentAnalysisEstimator

class h2o.estimators.pca.H2OPrincipalComponentAnalysisEstimator(**kwargs)[source]

Bases: h2o.estimators.estimator_base.H2OEstimator

Principal Components Analysis

compute_metrics

Whether to compute metrics on the training data

Type: bool (default: True).

ignore_const_cols

Ignore constant columns.

Type: bool (default: True).

ignored_columns

Names of columns to ignore for training.

Type: List[str].

impute_missing

Whether to impute missing entries with the column mean

Type: bool (default: False).

k

Rank of matrix approximation

Type: int (default: 1).

max_iterations

Maximum training iterations

Type: int (default: 1000).

max_runtime_secs

Maximum allowed runtime in seconds for model training. Use 0 to disable.

Type: float (default: 0).

pca_method

Method for computing PCA (Caution: GLRM is currently experimental and unstable)

One of: "gram_s_v_d", "power", "randomized", "glrm" (default: "gram_s_v_d").

score_each_iteration

Whether to score during each iteration of model training.

Type: bool (default: False).

seed

RNG seed for initialization

Type: int (default: -1).

training_frame

Id of the training data frame (Not required, to allow initial validation of model parameters).

Type: H2OFrame.

transform

Transformation of training data

One of: "none", "standardize", "normalize", "demean", "descale" (default: "none").

use_all_factor_levels

Whether first factor level is included in each categorical expansion

Type: bool (default: False).

validation_frame

Id of the validation data frame.

Type: H2OFrame.

Miscellaneous

H2OAutoML

class h2o.automl.autoh2o.H2OAutoML(max_runtime_secs=3600, max_models=None, stopping_metric='AUTO', stopping_tolerance=None, stopping_rounds=3, seed=None, project_name=None)[source]

Bases: object

Automatic Machine Learning

The Automatic Machine Learning (AutoML) function automates the supervised machine learning model training process. The current version of AutoML trains and cross-validates a Random Forest, an Extremely-Randomized Forest, a random grid of Gradient Boosting Machines (GBMs), a random grid of Deep Neural Nets, and a Stacked Ensemble of all the models.

Parameters:
  • max_runtime_secs (int) – This argument controls how long the AutoML run will execute. Defaults to 3600 seconds (1 hour).
  • max_models (int) – Specify the maximum number of models to build in an AutoML run. (Does not include the Stacked Ensemble model.)
  • stopping_metric (str) – Specifies the metric to use for early stopping. Defaults to "AUTO". The available options are: AUTO (This defaults to logloss for classification, deviance for regression), deviance, logloss, mse, rmse, mae, rmsle, auc, lift_top_group, misclassification, mean_per_class_error.
  • stopping_tolerance (float) – This option specifies the relative tolerance for the metric-based stopping to stop the AutoML run if the improvement is less than this value. This value defaults to 0.001 if the dataset is at least 1 million rows; otherwise it defaults to a value determined by the size of the dataset and the non-NA-rate. In that case, the value is computed as 1/sqrt(nrows * non-NA-rate).
  • stopping_rounds (int) – This argument stops training new models in the AutoML run when the option selected for stopping_metric doesn’t improve for the specified number of models, based on a simple moving average. To disable this feature, set it to 0. Defaults to 3 and must be an non-negative integer.
  • seed (int) – Set a seed for reproducibility. AutoML can only guarantee reproducibility if max_models or early stopping is used because max_runtime_secs is resource limited, meaning that if the resources are not the same between runs, AutoML may be able to train more models on one run vs another. Defaults to None.
  • project_name (str) – Character string to identify an AutoML project. Defaults to None, which means a project name will be auto-generated based on the training frame ID. More models can be trained on an existing AutoML project by specifying the same project name in muliple calls to the AutoML function (as long as the same training frame is used in subsequent runs).
Examples:
>>> import h2o
>>> from h2o.automl import H2OAutoML
>>> h2o.init()
>>> # Import a sample binary outcome train/test set into H2O
>>> train = h2o.import_file("https://s3.amazonaws.com/erin-data/higgs/higgs_train_10k.csv")
>>> test = h2o.import_file("https://s3.amazonaws.com/erin-data/higgs/higgs_test_5k.csv")
>>> # Identify predictors and response
>>> x = train.columns
>>> y = "response"
>>> x.remove(y)
>>> # For binary classification, response should be a factor
>>> train[y] = train[y].asfactor()
>>> test[y] = test[y].asfactor()
>>> # Run AutoML for 30 seconds
>>> aml = H2OAutoML(max_runtime_secs = 30)
>>> aml.train(x = x, y = y,training_frame = train,leaderboard_frame = test)
leader

Retrieve the top model from an H2OAutoML object

Returns:an H2O model
Examples:
>>> # Set up an H2OAutoML object
>>> aml = H2OAutoML(max_runtime_secs=30)
>>> # Launch H2OAutoML
>>> aml.train(y=y, training_frame=training_frame)
>>> # Get the top model
>>> aml.leader
leaderboard

Retrieve the leaderboard from an H2OAutoML object

Returns:an H2OFrame with model ids in the first column and evaluation metric in the second column sorted by the evaluation metric
Examples:
>>> # Set up an H2OAutoML object
>>> aml = H2OAutoML(max_runtime_secs=30)
>>> # Launch H2OAutoML
>>> aml.train(y=y, training_frame=training_frame)
>>> # Get the leaderboard
>>> aml.leaderboard
predict(test_data)[source]

Predict on a dataset.

Parameters:test_data (H2OFrame) – Data on which to make predictions.
Returns:A new H2OFrame of predictions.
Examples:
>>> #Set up an H2OAutoML object
>>> aml = H2OAutoML(max_runtime_secs=30)
>>> # Launch H2OAutoML
>>> aml.train(y=y, training_frame=training_frame)
>>> #Predict with #1 model from H2OAutoML leaderboard
>>> aml.predict(test_data)
train(x=None, y=None, training_frame=None, fold_column=None, weights_column=None, validation_frame=None, leaderboard_frame=None)[source]

Begins an AutoML task, a background task that automatically builds a number of models with various algorithms and tracks their performance in a leaderboard. At any point in the process you may use H2O’s performance or prediction functions on the resulting models.

Parameters:
  • x – A list of column names or indices indicating the predictor columns.
  • y – An index or a column name indicating the response column.
  • fold_column – The name or index of the column in training_frame that holds per-row fold assignments.
  • weights_column – The name or index of the column in training_frame that holds per-row weights.
  • training_frame – The H2OFrame having the columns indicated by x and y (as well as any additional columns specified by fold, offset, and weights).
  • validation_frame – H2OFrame with validation data to be scored on while training.
  • leaderboard_frame – H2OFrame with test data to be scored on in the leaderboard.
Returns:

An H2OAutoML object.

Examples:
>>> # Set up an H2OAutoML object
>>> aml = H2OAutoML(max_runtime_secs=30)
>>> # Launch H2OAutoML
>>> aml.train(y=y, training_frame=training_frame)

H2OEstimator

class h2o.estimators.estimator_base.H2OEstimator[source]

Bases: h2o.model.model_base.ModelBase

Base class for H2O Estimators.

H2O Estimators implement the following methods for model construction:

  • start() - Top-level user-facing API for asynchronous model build
  • join() - Top-level user-facing API for blocking on async model build
  • train() - Top-level user-facing API for model building.
  • fit() - Used by scikit-learn.

Because H2OEstimator instances are instances of ModelBase, these objects can use the H2O model API.

fit(x, y=None, **params)[source]

Fit an H2O model as part of a scikit-learn pipeline or grid search.

A warning will be issued if a caller other than sklearn attempts to use this method.

Parameters:
  • x (H2OFrame) – An H2OFrame consisting of the predictor variables.
  • y (H2OFrame) – An H2OFrame consisting of the response variable.
  • params – Extra arguments.
Returns:

The current instance of H2OEstimator for method chaining.

get_params(deep=True)[source]

Obtain parameters for this estimator.

Used primarily for sklearn Pipelines and sklearn grid search.

Parameters:deep – If True, return parameters of all sub-objects that are estimators.
Returns:A dict of parameters
join()[source]

Wait until job’s completion.

set_params(**parms)[source]

Used by sklearn for updating parameters during grid search.

Parameters:parms – A dictionary of parameters that will be set on this model.
Returns:self, the current estimator object with the parameters all set as desired.
start(x, y=None, training_frame=None, offset_column=None, fold_column=None, weights_column=None, validation_frame=None, **params)[source]

Train the model asynchronously (to block for results call join()).

Parameters:
  • x – A list of column names or indices indicating the predictor columns.
  • y – An index or a column name indicating the response column.
  • training_frame (H2OFrame) – The H2OFrame having the columns indicated by x and y (as well as any additional columns specified by fold, offset, and weights).
  • offset_column – The name or index of the column in training_frame that holds the offsets.
  • fold_column – The name or index of the column in training_frame that holds the per-row fold assignments.
  • weights_column – The name or index of the column in training_frame that holds the per-row weights.
  • validation_frame – H2OFrame with validation data to be scored on while training.
train(x=None, y=None, training_frame=None, offset_column=None, fold_column=None, weights_column=None, validation_frame=None, max_runtime_secs=None, ignored_columns=None, model_id=None, verbose=False)[source]

Train the H2O model.

Parameters:
  • x – A list of column names or indices indicating the predictor columns.
  • y – An index or a column name indicating the response column.
  • training_frame (H2OFrame) – The H2OFrame having the columns indicated by x and y (as well as any additional columns specified by fold, offset, and weights).
  • offset_column – The name or index of the column in training_frame that holds the offsets.
  • fold_column – The name or index of the column in training_frame that holds the per-row fold assignments.
  • weights_column – The name or index of the column in training_frame that holds the per-row weights.
  • validation_frame – H2OFrame with validation data to be scored on while training.
  • max_runtime_secs (float) – Maximum allowed runtime in seconds for model training. Use 0 to disable.
  • verbose (bool) – Print scoring history to stdout. Defaults to False.

H2OGridSearch

class h2o.grid.grid_search.H2OGridSearch(model, hyper_params, grid_id=None, search_criteria=None)[source]

Bases: h2o.utils.backward_compatibility.BackwardsCompatibleBase

Grid Search of a Hyper-Parameter Space for a Model

Parameters:
  • model – The type of model to be explored initialized with optional parameters that will be unchanged across explored models.
  • hyper_params – A dictionary of string parameters (keys) and a list of values to be explored by grid search (values).
  • grid_id (str) – The unique id assigned to the resulting grid object. If none is given, an id will automatically be generated.
  • search_criteria

    A dictionary of directives which control the search of the hyperparameter space. The default strategy “Cartesian” covers the entire space of hyperparameter combinations. Specify the “RandomDiscrete” strategy to get random search of all the combinations of your hyperparameters. RandomDiscrete should usually be combined with at least one early stopping criterion: max_models and/or max_runtime_secs, e.g:

    >>> criteria = {"strategy": "RandomDiscrete", "max_models": 42,
    ...             "max_runtime_secs": 28800, "seed": 1234}
    >>> criteria = {"strategy": "RandomDiscrete", "stopping_metric": "AUTO",
    ...             "stopping_tolerance": 0.001, "stopping_rounds": 10}
    >>> criteria = {"strategy": "RandomDiscrete", "stopping_rounds": 5,
    ...             "stopping_metric": "misclassification",
    ...             "stopping_tolerance": 0.00001}
    
Returns:

a new H2OGridSearch instance

Examples

>>> from h2o.grid.grid_search import H2OGridSearch
>>> from h2o.estimators.glm import H2OGeneralizedLinearEstimator
>>> hyper_parameters = {'alpha': [0.01,0.5], 'lambda': [1e-5,1e-6]}
>>> gs = H2OGridSearch(H2OGeneralizedLinearEstimator(family='binomial'), hyper_parameters)
>>> training_data = h2o.import_file("smalldata/logreg/benign.csv")
>>> gs.train(x=range(3) + range(4,11),y=3, training_frame=training_data)
>>> gs.show()
aic(train=False, valid=False, xval=False)[source]

Get the AIC(s).

If all are False (default), then return the training metric value. If more than one options is set to True, then return a dictionary of metrics where the keys are “train”, “valid”, and “xval”.

Parameters:
  • train (bool) – If train is True, then return the AIC value for the training data.
  • valid (bool) – If valid is True, then return the AIC value for the validation data.
  • xval (bool) – If xval is True, then return the AIC value for the validation data.
Returns:

The AIC.

auc(train=False, valid=False, xval=False)[source]

Get the AUC(s).

If all are False (default), then return the training metric value. If more than one options is set to True, then return a dictionary of metrics where the keys are “train”, “valid”, and “xval”.

Parameters:
  • train (bool) – If train is True, then return the AUC value for the training data.
  • valid (bool) – If valid is True, then return the AUC value for the validation data.
  • xval (bool) – If xval is True, then return the AUC value for the validation data.
Returns:

The AUC.

biases(vector_id=0)[source]

Return the frame for the respective bias vector.

Param:vector_id: an integer, ranging from 0 to number of layers, that specifies the bias vector to return.
Returns:an H2OFrame which represents the bias vector identified by vector_id
build_model(algo_params)[source]

(internal)

catoffsets()[source]

Categorical offsets for one-hot encoding

coef()[source]

Return the coefficients that can be applied to the non-standardized data.

Note: standardize = True by default. If set to False, then coef() returns the coefficients that are fit directly.

coef_norm()[source]

Return coefficients fitted on the standardized data (requires standardize = True, which is on by default). These coefficients can be used to evaluate variable importance.

deepfeatures(test_data, layer)[source]

Obtain a hidden layer’s details on a dataset.

Parameters:
  • test_data – Data to create a feature space on.
  • layer (int) – Index of the hidden layer.
Returns:

A dictionary of hidden layer details for each model.

get_grid(sort_by=None, decreasing=None)[source]

Retrieve an H2OGridSearch instance.

Optionally specify a metric by which to sort models and a sort order. Note that if neither cross-validation nor a validation frame is used in the grid search, then the training metrics will display in the “get grid” output. If a validation frame is passed to the grid, and nfolds = 0, then the validation metrics will display. However, if nfolds > 1, then cross-validation metrics will display even if a validation frame is provided.

Parameters:
  • sort_by (str) – A metric by which to sort the models in the grid space. Choices are: "logloss", "residual_deviance", "mse", "auc", "r2", "accuracy", "precision", "recall", "f1", etc.
  • decreasing (bool) – Sort the models in decreasing order of metric if true, otherwise sort in increasing order (default).
Returns:

A new H2OGridSearch instance optionally sorted on the specified metric.

get_hyperparams(id, display=True)[source]

Get the hyperparameters of a model explored by grid search.

Parameters:
  • id (str) – The model id of the model with hyperparameters of interest.
  • display (bool) – Flag to indicate whether to display the hyperparameter names.
Returns:

A list of the hyperparameters for the specified model.

get_hyperparams_dict(id, display=True)[source]

Derived and returned the model parameters used to train the particular grid search model.

Parameters:
  • id (str) – The model id of the model with hyperparameters of interest.
  • display (bool) – Flag to indicate whether to display the hyperparameter names.
Returns:

A dict of model pararmeters derived from the hyper-parameters used to train this particular model.

get_xval_models(key=None)[source]

Return a Model object.

Parameters:key (str) – If None, return all cross-validated models; otherwise return the model specified by the key.
Returns:A model or a list of models.
gini(train=False, valid=False, xval=False)[source]

Get the Gini Coefficient(s).

If all are False (default), then return the training metric value. If more than one options is set to True, then return a dictionary of metrics where the keys are “train”, “valid”, and “xval”.

Parameters:
  • train (bool) – If train is True, then return the Gini Coefficient value for the training data.
  • valid (bool) – If valid is True, then return the Gini Coefficient value for the validation data.
  • xval (bool) – If xval is True, then return the Gini Coefficient value for the cross validation data.
Returns:

The Gini Coefficient for this binomial model.

grid_id

A key that identifies this grid search object in H2O.

is_cross_validated()[source]

Return True if the model was cross-validated.

join()[source]

Wait until grid finishes computing.

logloss(train=False, valid=False, xval=False)[source]

Get the Log Loss(s).

If all are False (default), then return the training metric value. If more than one options is set to True, then return a dictionary of metrics where the keys are “train”, “valid”, and “xval”.

Parameters:
  • train (bool) – If train is True, then return the Log Loss value for the training data.
  • valid (bool) – If valid is True, then return the Log Loss value for the validation data.
  • xval (bool) – If xval is True, then return the Log Loss value for the cross validation data.
Returns:

The Log Loss for this binomial model.

mean_residual_deviance(train=False, valid=False, xval=False)[source]

Get the Mean Residual Deviances(s).

If all are False (default), then return the training metric value. If more than one options is set to True, then return a dictionary of metrics where the keys are “train”, “valid”, and “xval”.

Parameters:
  • train (bool) – If train is True, then return the Mean Residual Deviance value for the training data.
  • valid (bool) – If valid is True, then return the Mean Residual Deviance value for the validation data.
  • xval (bool) – If xval is True, then return the Mean Residual Deviance value for the cross validation data.
Returns:

The Mean Residual Deviance for this regression model.

model_performance(test_data=None, train=False, valid=False, xval=False)[source]

Generate model metrics for this model on test_data.

Parameters:
  • test_data – Data set for which model metrics shall be computed against. All three of train, valid and xval arguments are ignored if test_data is not None.
  • train – Report the training metrics for the model.
  • valid – Report the validation metrics for the model.
  • xval – Report the validation metrics for the model.
Returns:

An object of class H2OModelMetrics.

mse(train=False, valid=False, xval=False)[source]

Get the MSE(s).

If all are False (default), then return the training metric value. If more than one options is set to True, then return a dictionary of metrics where the keys are “train”, “valid”, and “xval”.

Parameters:
  • train (bool) – If train is True, then return the MSE value for the training data.
  • valid (bool) – If valid is True, then return the MSE value for the validation data.
  • xval (bool) – If xval is True, then return the MSE value for the cross validation data.
Returns:

The MSE for this regression model.

normmul()[source]

Normalization/Standardization multipliers for numeric predictors.

normsub()[source]

Normalization/Standardization offsets for numeric predictors.

null_degrees_of_freedom(train=False, valid=False, xval=False)[source]

Retreive the null degress of freedom if this model has the attribute, or None otherwise.

Parameters:
  • train (bool) – Get the null dof for the training set. If both train and valid are False, then train is selected by default.
  • valid (bool) – Get the null dof for the validation set. If both train and valid are True, then train is selected by default.
  • xval (bool) – Get the null dof for the cross-validated models.
Returns:

the null dof, or None if it is not present.

null_deviance(train=False, valid=False, xval=False)[source]

Retreive the null deviance if this model has the attribute, or None otherwise.

Parameters:
  • train (bool) – Get the null deviance for the training set. If both train and valid are False, then train is selected by default.
  • valid (bool) – Get the null deviance for the validation set. If both train and valid are True, then train is selected by default.
  • xval (bool) – Get the null deviance for the cross-validated models.
Returns:

the null deviance, or None if it is not present.

pprint_coef()[source]

Pretty print the coefficents table (includes normalized coefficients).

predict(test_data)[source]

Predict on a dataset.

Parameters:test_data (H2OFrame) – Data to be predicted on.
Returns:H2OFrame filled with predictions.
r2(train=False, valid=False, xval=False)[source]

Return the R^2 for this regression model.

The R^2 value is defined to be 1 - MSE/var, where var is computed as sigma^2.

If all are False (default), then return the training metric value. If more than one options is set to True, then return a dictionary of metrics where the keys are “train”, “valid”, and “xval”.

Parameters:
  • train (bool) – If train is True, then return the R^2 value for the training data.
  • valid (bool) – If valid is True, then return the R^2 value for the validation data.
  • xval (bool) – If xval is True, then return the R^2 value for the cross validation data.
Returns:

The R^2 for this regression model.

residual_degrees_of_freedom(train=False, valid=False, xval=False)[source]

Retreive the residual degress of freedom if this model has the attribute, or None otherwise.

Parameters:
  • train (bool) – Get the residual dof for the training set. If both train and valid are False, then train is selected by default.
  • valid (bool) – Get the residual dof for the validation set. If both train and valid are True, then train is selected by default.
  • xval (bool) – Get the residual dof for the cross-validated models.
Returns:

the residual degrees of freedom, or None if they are not present.

residual_deviance(train=False, valid=False, xval=False)[source]

Retreive the residual deviance if this model has the attribute, or None otherwise.

Parameters:
  • train (bool) – Get the residual deviance for the training set. If both train and valid are False, then train is selected by default.
  • valid (bool) – Get the residual deviance for the validation set. If both train and valid are True, then train is selected by default.
  • xval (bool) – Get the residual deviance for the cross-validated models.
Returns:

the residual deviance, or None if it is not present.

respmul()[source]

Normalization/Standardization multipliers for numeric response.

respsub()[source]

Normalization/Standardization offsets for numeric response.

scoring_history()[source]

Retrieve model scoring history.

Returns:Score history (H2OTwoDimTable)
show()[source]

Print models sorted by metric.

sort_by(*args, **kwargs)[source]

grid.sort_by() is deprecated; use grid.get_grid() instead

sorted_metric_table()[source]

Retrieve summary table of an H2O Grid Search.

Returns:The summary table as an H2OTwoDimTable or a Pandas DataFrame.
start(x, y=None, training_frame=None, offset_column=None, fold_column=None, weights_column=None, validation_frame=None, **params)[source]

Asynchronous model build by specifying the predictor columns, response column, and any additional frame-specific values.

To block for results, call join().

Parameters:
  • x – A list of column names or indices indicating the predictor columns.
  • y – An index or a column name indicating the response column.
  • training_frame – The H2OFrame having the columns indicated by x and y (as well as any additional columns specified by fold, offset, and weights).
  • offset_column – The name or index of the column in training_frame that holds the offsets.
  • fold_column – The name or index of the column in training_frame that holds the per-row fold assignments.
  • weights_column – The name or index of the column in training_frame that holds the per-row weights.
  • validation_frame – H2OFrame with validation data to be scored on while training.
summary(header=True)[source]

Print a detailed summary of the explored models.

train(x, y=None, training_frame=None, offset_column=None, fold_column=None, weights_column=None, validation_frame=None, **params)[source]

Train the model synchronously (i.e. do not return until the model finishes training).

To train asynchronously call start().

Parameters:
  • x – A list of column names or indices indicating the predictor columns.
  • y – An index or a column name indicating the response column.
  • training_frame – The H2OFrame having the columns indicated by x and y (as well as any additional columns specified by fold, offset, and weights).
  • offset_column – The name or index of the column in training_frame that holds the offsets.
  • fold_column – The name or index of the column in training_frame that holds the per-row fold assignments.
  • weights_column – The name or index of the column in training_frame that holds the per-row weights.
  • validation_frame – H2OFrame with validation data to be scored on while training.
varimp(use_pandas=False)[source]

Pretty print the variable importances, or return them in a list/pandas DataFrame.

Parameters:use_pandas (bool) – If True, then the variable importances will be returned as a pandas data frame.
Returns:A dictionary of lists or Pandas DataFrame instances.
weights(matrix_id=0)[source]

Return the frame for the respective weight matrix.

Param:matrix_id: an integer, ranging from 0 to number of layers, that specifies the weight matrix to return.
Returns:an H2OFrame which represents the weight matrix identified by matrix_id
xval_keys()[source]

Model keys for the cross-validated model.

xvals()[source]

Return the list of cross-validated models.

H2OSingularValueDecompositionEstimator

class h2o.estimators.svd.H2OSingularValueDecompositionEstimator(**kwargs)[source]

Bases: h2o.estimators.estimator_base.H2OEstimator

Singular Value Decomposition

ignore_const_cols

Ignore constant columns.

Type: bool (default: True).

ignored_columns

Names of columns to ignore for training.

Type: List[str].

keep_u

Save left singular vectors?

Type: bool (default: True).

max_iterations

Maximum iterations

Type: int (default: 1000).

max_runtime_secs

Maximum allowed runtime in seconds for model training. Use 0 to disable.

Type: float (default: 0).

nv

Number of right singular vectors

Type: int (default: 1).

score_each_iteration

Whether to score during each iteration of model training.

Type: bool (default: False).

seed

RNG seed for k-means++ initialization

Type: int (default: -1).

svd_method

Method for computing SVD (Caution: Randomized is currently experimental and unstable)

One of: "gram_s_v_d", "power", "randomized" (default: "gram_s_v_d").

training_frame

Id of the training data frame (Not required, to allow initial validation of model parameters).

Type: H2OFrame.

transform

Transformation of training data

One of: "none", "standardize", "normalize", "demean", "descale" (default: "none").

u_name

Frame key to save left singular vectors

Type: str.

use_all_factor_levels

Whether first factor level is included in each categorical expansion

Type: bool (default: True).

validation_frame

Id of the validation data frame.

Type: H2OFrame.

H2OWord2vecEstimator

class h2o.estimators.word2vec.H2OWord2vecEstimator(**kwargs)[source]

Bases: h2o.estimators.estimator_base.H2OEstimator

Word2Vec

epochs

Number of training iterations to run

Type: int (default: 5).

init_learning_rate

Set the starting learning rate

Type: float (default: 0.025).

max_runtime_secs

Maximum allowed runtime in seconds for model training. Use 0 to disable.

Type: float (default: 0).

min_word_freq

This will discard words that appear less than <int> times

Type: int (default: 5).

norm_model

Use Hierarchical Softmax

One of: "hsm" (default: "hsm").

pre_trained

Id of a data frame that contains a pre-trained (external) word2vec model

Type: H2OFrame.

sent_sample_rate

Set threshold for occurrence of words. Those that appear with higher frequency in the training data will be randomly down-sampled; useful range is (0, 1e-5)

Type: float (default: 0.001).

training_frame

Id of the training data frame (Not required, to allow initial validation of model parameters).

Type: H2OFrame.

vec_size

Set size of word vectors

Type: int (default: 100).

window_size

Set max skip length between words

Type: int (default: 5).

word_model

Use the Skip-Gram model

One of: "skip_gram" (default: "skip_gram").