Modeling In H2O¶
Supervised¶
H2OCoxProportionalHazardsEstimator
¶
-
class
h2o.estimators.coxph.
H2OCoxProportionalHazardsEstimator
(**kwargs)[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
Cox Proportional Hazards
Trains a Cox Proportional Hazards Model (CoxPH) on an H2O dataset
-
export_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.
-
ignored_columns
¶ Names of columns to ignore for training.
Type:
List[str]
.
-
init
¶ Coefficient starting value.
Type:
float
(default:0
).
-
interaction_pairs
¶ A list of pairwise (first order) column interactions.
Type:
List[tuple]
.
-
interactions
¶ A list of predictor column indices to interact. All pairwise combinations will be computed for the list.
Type:
List[str]
.
-
interactions_only
¶ A list of columns that should only be used to create interactions but should not itself participate in model training.
Type:
List[str]
.
-
lre_min
¶ Minimum log-relative error.
Type:
float
(default:9
).
-
max_iterations
¶ Maximum number of iterations.
Type:
int
(default:20
).
-
offset_column
¶ Offset column. This will be added to the combination of columns before applying the link function.
Type:
str
.
-
response_column
¶ Response variable column.
Type:
str
.
-
start_column
¶ Start Time Column.
Type:
str
.
-
stop_column
¶ Stop Time Column.
Type:
str
.
-
stratify_by
¶ List of columns to use for stratification.
Type:
List[str]
.
-
ties
¶ Method for Handling Ties.
One of:
"efron"
,"breslow"
(default:"efron"
).
-
training_frame
¶ Id of the training data frame.
Type:
H2OFrame
.
-
use_all_factor_levels
¶ (Internal. For development only!) Indicates whether to use all factor levels.
Type:
bool
(default:False
).
-
weights_column
¶ Column with observation weights. Giving some observation a weight of zero is equivalent to excluding it from the dataset; giving an observation a relative weight of 2 is equivalent to repeating that row twice. Negative weights are not allowed. Note: Weights are per-row observation weights and do not increase the size of the data frame. This is typically the number of times a row is repeated, but non-integer values are supported as well. During training, rows with higher weights matter more, due to the larger loss function pre-factor.
Type:
str
.
-
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_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.
-
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 layer sizes (e.g. [100, 100]).
Type:
List[int]
(default:[200, 200]
).
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_models
¶ Whether to keep the cross-validation models.
Type:
bool
(default:True
).
-
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 K-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). Note that custom and custom_increasing can only be used in GBM and DRF with the Python client.
One of:
"auto"
,"deviance"
,"logloss"
,"mse"
,"rmse"
,"mae"
,"rmsle"
,"auc"
,"lift_top_group"
,"misclassification"
,"mean_per_class_error"
,"custom"
,"custom_increasing"
(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.
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. Note: Weights are per-row observation weights and do not increase the size of the data frame. This is typically the number of times a row is repeated, but non-integer values are supported as well. During training, rows with higher weights matter more, due to the larger loss function pre-factor.
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
).
-
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_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.
-
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 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 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_models
¶ Whether to keep the cross-validation models.
Type:
bool
(default:True
).
-
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 K-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). Note that custom and custom_increasing can only be used in GBM and DRF with the Python client.
One of:
"auto"
,"deviance"
,"logloss"
,"mse"
,"rmse"
,"mae"
,"rmsle"
,"auc"
,"lift_top_group"
,"misclassification"
,"mean_per_class_error"
,"custom"
,"custom_increasing"
(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.
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. Note: Weights are per-row observation weights and do not increase the size of the data frame. This is typically the number of times a row is repeated, but non-integer values are supported as well. During training, rows with higher weights matter more, due to the larger loss function pre-factor.
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"
).
-
check_constant_response
¶ Check if response column is constant. If enabled, then an exception is thrown if the response column is a constant value.If disabled, then model will train regardless of the response column being a constant value or not.
Type:
bool
(default:True
).
-
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 (must be > 0.0 and <= 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
).
-
custom_metric_func
¶ Reference to custom evaluation function, format: language:keyName=funcName
Type:
str
.
-
distribution
¶ Distribution function
One of:
"auto"
,"bernoulli"
,"quasibinomial"
,"multinomial"
,"gaussian"
,"poisson"
,"gamma"
,"tweedie"
,"laplace"
,"quantile"
,"huber"
(default:"auto"
).
-
export_checkpoints_dir
¶ Automatically export generated models to this directory.
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
.
-
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_models
¶ Whether to keep the cross-validation models.
Type:
bool
(default:True
).
-
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
).
-
monotone_constraints
¶ A mapping representing monotonic constraints. Use +1 to enforce an increasing constraint and -1 to specify a decreasing constraint.
Type:
dict
.
-
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 K-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). Note that custom and custom_increasing can only be used in GBM and DRF with the Python client.
One of:
"auto"
,"deviance"
,"logloss"
,"mse"
,"rmse"
,"mae"
,"rmsle"
,"auc"
,"lift_top_group"
,"misclassification"
,"mean_per_class_error"
,"custom"
,"custom_increasing"
(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.
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. Note: Weights are per-row observation weights and do not increase the size of the data frame. This is typically the number of times a row is repeated, but non-integer values are supported as well. During training, rows with higher weights matter more, due to the larger loss function pre-factor.
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
).
-
custom_metric_func
¶ Reference to custom evaluation function, format: language:keyName=funcName
Type:
str
.
-
early_stopping
¶ Stop early when there is no more relative improvement on train or validation (if provided)
Type:
bool
(default:True
).
-
export_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.
-
family
¶ Family. Use binomial for classification with logistic regression, others are for regression problems.
One of:
"gaussian"
,"binomial"
,"quasibinomial"
,"ordinal"
,"multinomial"
,"poisson"
,"gamma"
,"tweedie"
,"negativebinomial"
(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]
.
-
interaction_pairs
¶ A list of pairwise (first order) column interactions.
Type:
List[tuple]
.
-
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_models
¶ Whether to keep the cross-validation models.
Type:
bool
(default:True
).
-
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 (the smallest lambda that drives all coefficients to zero). Default indicates: if the number of observations is greater than the number of variables, then lambda_min_ratio is set to 0.0001; if the number of observations is less than the number of variables, then lambda_min_ratio is set to 0.01.
Type:
float
(default:-1
).
-
lambda_search
¶ Use lambda search starting at lambda max, given lambda is then interpreted as lambda min
Type:
bool
(default:False
).
-
link
¶ One of:
"family_default"
,"identity"
,"logit"
,"log"
,"inverse"
,"tweedie"
,"ologit"
,"oprobit"
,"ologlog"
(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 5000 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 K-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
).
-
obj_reg
¶ Likelihood divider in objective value computation, default is 1/nobs
Type:
float
(default:-1
).
-
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.
One of:
"auto"
,"irlsm"
,"l_bfgs"
,"coordinate_descent_naive"
,"coordinate_descent"
,"gradient_descent_lh"
,"gradient_descent_sqerr"
(default:"auto"
).
-
standardize
¶ Standardize numeric columns to have zero mean and unit variance
Type:
bool
(default:True
).
-
theta
¶ Theta
Type:
float
(default:1e-10
).
-
training_frame
¶ Id of the training data frame.
Type:
H2OFrame
.
-
tweedie_link_power
¶ 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. Note: Weights are per-row observation weights and do not increase the size of the data frame. This is typically the number of times a row is repeated, but non-integer values are supported as well. During training, rows with higher weights matter more, due to the larger loss function pre-factor.
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
).
-
export_checkpoints_dir
¶ Automatically export generated models to this directory.
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
.
-
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_models
¶ Whether to keep the cross-validation models.
Type:
bool
(default:True
).
-
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 K-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.
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"
).
-
check_constant_response
¶ Check if response column is constant. If enabled, then an exception is thrown if the response column is a constant value.If disabled, then model will train regardless of the response column being a constant value or not.
Type:
bool
(default:True
).
-
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 (must be > 0.0 and <= 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
).
-
custom_metric_func
¶ Reference to custom evaluation function, format: language:keyName=funcName
Type:
str
.
-
distribution
¶ [Deprecated] Distribution function
One of:
"auto"
,"bernoulli"
,"multinomial"
,"gaussian"
,"poisson"
,"gamma"
,"tweedie"
,"laplace"
,"quantile"
,"huber"
(default:"auto"
).
-
export_checkpoints_dir
¶ Automatically export generated models to this directory.
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
.
-
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_models
¶ Whether to keep the cross-validation models.
Type:
bool
(default:True
).
-
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 K-fold cross-validation (0 to disable or >= 2).
Type:
int
(default:0
).
-
ntrees
¶ Number of trees.
Type:
int
(default:50
).
-
offset_column
¶ [Deprecated] 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). Note that custom and custom_increasing can only be used in GBM and DRF with the Python client.
One of:
"auto"
,"deviance"
,"logloss"
,"mse"
,"rmse"
,"mae"
,"rmsle"
,"auc"
,"lift_top_group"
,"misclassification"
,"mean_per_class_error"
,"custom"
,"custom_increasing"
(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.
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. Note: Weights are per-row observation weights and do not increase the size of the data frame. This is typically the number of times a row is repeated, but non-integer values are supported as well. During training, rows with higher weights matter more, due to the larger loss function pre-factor.
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 models (or model ids) to ensemble/stack together. If not using blending frame, then models must have been cross-validated using nfolds > 1, and folds must be identical across models.
Type:
List[str]
(default:[]
).
-
blending_frame
¶ Frame used to compute the predictions that serve as the training frame for the metalearner (triggers blending mode if provided)
Type:
H2OFrame
.
-
export_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.
-
keep_levelone_frame
¶ Keep level one frame used for metalearner training.
Type:
bool
(default:False
).
-
metalearner_algorithm
¶ Type of algorithm to use as the metalearner. Options include ‘AUTO’ (GLM with non negative weights; if validation_frame is present, a lambda search is performed), ‘glm’ (GLM with default parameters), ‘gbm’ (GBM with default parameters), ‘drf’ (Random Forest with default parameters), or ‘deeplearning’ (Deep Learning with default parameters).
One of:
"auto"
,"glm"
,"gbm"
,"drf"
,"deeplearning"
(default:"auto"
).
-
metalearner_fold_assignment
¶ Cross-validation fold assignment scheme for metalearner cross-validation. Defaults to AUTO (which is currently set to Random). The ‘Stratified’ option will stratify the folds based on the response variable, for classification problems.
One of:
"auto"
,"random"
,"modulo"
,"stratified"
.
-
metalearner_fold_column
¶ Column with cross-validation fold index assignment per observation for cross-validation of the metalearner.
Type:
str
.
-
metalearner_nfolds
¶ Number of folds for K-fold cross-validation of the metalearner algorithm (0 to disable or >= 2).
Type:
int
(default:0
).
-
metalearner_params
¶ Parameters for metalearner algorithm
Type:
dict
(default:None
). Example: metalearner_gbm_params = {‘max_depth’: 2, ‘col_sample_rate’: 0.3}
-
response_column
¶ Response variable column.
Type:
str
.
-
seed
¶ Seed for random numbers; passed through to the metalearner algorithm. Defaults to -1 (time-based random number)
Type:
int
(default:-1
).
-
training_frame
¶ Id of the training data frame.
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.
-
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:"auto"
).
-
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
).
-
export_checkpoints_dir
¶ Automatically export generated models to this directory.
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
.
-
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_models
¶ Whether to keep the cross-validation models.
Type:
bool
(default:True
).
-
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
).
-
monotone_constraints
¶ A mapping representing monotonic constraints. Use +1 to enforce an increasing constraint and -1 to specify a decreasing constraint.
Type:
dict
.
-
nfolds
¶ Number of folds for K-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"
).
-
nthread
¶ Number of parallel threads that can be used to run XGBoost. Cannot exceed H2O cluster limits (-nthreads parameter). Defaults to maximum available
Type:
int
(default:-1
).
-
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:1
).
-
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). Note that custom and custom_increasing can only be used in GBM and DRF with the Python client.
One of:
"auto"
,"deviance"
,"logloss"
,"mse"
,"rmse"
,"mae"
,"rmsle"
,"auc"
,"lift_top_group"
,"misclassification"
,"mean_per_class_error"
,"custom"
,"custom_increasing"
(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.
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. Note: Weights are per-row observation weights and do not increase the size of the data frame. This is typically the number of times a row is repeated, but non-integer values are supported as well. During training, rows with higher weights matter more, due to the larger loss function pre-factor.
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"
).
-
export_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.
-
ignore_const_cols
¶ Ignore constant columns.
Type:
bool
(default:True
).
-
ignored_columns
¶ Names of columns to ignore for training.
Type:
List[str]
.
-
num_iteration_without_new_exemplar
¶ The number of iterations to run before aggregator exits if the number of exemplars collected didn’t change
Type:
int
(default:500
).
-
rel_tol_num_exemplars
¶ Relative tolerance for number of exemplars (e.g, 0.5 is +/- 50 percents)
Type:
float
(default:0.5
).
-
response_column
¶ Response variable column.
Type:
str
.
-
save_mapping_frame
¶ Whether to export the mapping of the aggregated frame
Type:
bool
(default:False
).
-
target_num_exemplars
¶ Targeted number of exemplars
Type:
int
(default:5000
).
-
training_frame
¶ Id of the training data frame.
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)
H2OGenericEstimator
¶
-
class
h2o.estimators.generic.
H2OGenericEstimator
(**kwargs)[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
Generic Model
-
static
from_file
(file=<class 'str'>)[source]¶ Creates new Generic model by loading existing embedded model into library, e.g. from H2O MOJO. The imported model must be supported by H2O. :param file: A string containing path to the file to create the model from :return: H2OGenericEstimator instance representing the generic model
-
model_key
¶ Key to the self-contained model archive already uploaded to H2O.
Type:
H2OFrame
.
-
static
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
).
-
export_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.
-
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.
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
.
-
H2OIsolationForestEstimator
¶
-
class
h2o.estimators.isolation_forest.
H2OIsolationForestEstimator
(**kwargs)[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
Isolation Forest
Builds an Isolation Forest model. Isolation Forest algorithm samples the training frame and in each iteration builds a tree that partitions the space of the sample observations until it isolates each observation. Length of the path from root to a leaf node of the resulting tree is used to calculate the anomaly score. Anomalies are easier to isolate and their average tree path is expected to be shorter than paths of regular observations.
-
build_tree_one_node
¶ Run on one node only; no network overhead but fewer cpus used. Suitable for small datasets.
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"
).
-
col_sample_rate_change_per_level
¶ Relative change of the column sampling rate for every level (must be > 0.0 and <= 2.0)
Type:
float
(default:1
).
-
col_sample_rate_per_tree
¶ Column sample rate per tree (from 0.0 to 1.0)
Type:
float
(default:1
).
-
export_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.
-
ignore_const_cols
¶ Ignore constant columns.
Type:
bool
(default:True
).
-
ignored_columns
¶ Names of columns to ignore for training.
Type:
List[str]
.
-
max_depth
¶ Maximum tree depth.
Type:
int
(default:8
).
-
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
).
-
mtries
¶ Number of variables randomly sampled as candidates at each split. If set to -1, defaults (number of predictors)/3.
Type:
int
(default:-1
).
-
ntrees
¶ Number of trees.
Type:
int
(default:50
).
-
sample_rate
¶ Rate of randomly sampled observations used to train each Isolation Forest tree. Needs to be in range from 0.0 to 1.0. If set to -1, sample_rate is disabled and sample_size will be used instead.
Type:
float
(default:-1
).
-
sample_size
¶ Number of randomly sampled observations used to train each Isolation Forest tree. Only one of parameters sample_size and sample_rate should be defined. If sample_rate is defined, sample_size will be ignored.
Type:
int
(default:256
).
-
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
).
-
training_frame
¶ Id of the training 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
).
-
export_checkpoints_dir
¶ Automatically export generated models to this directory.
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
.
-
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_models
¶ Whether to keep the cross-validation models.
Type:
bool
(default:True
).
-
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 K-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.
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
).
-
export_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.
-
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
).
-
init_for_pipeline
()[source]¶ Returns H2OPCA object which implements fit and transform method to be used in sklearn.Pipeline properly. All parameters defined in self.__params, should be input parameters in H2OPCA.__init__ method.
Returns: H2OPCA object
-
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_impl
¶ Specify the implementation to use for computing PCA (via SVD or EVD): MTJ_EVD_DENSEMATRIX - eigenvalue decompositions for dense matrix using MTJ; MTJ_EVD_SYMMMATRIX - eigenvalue decompositions for symmetric matrix using MTJ; MTJ_SVD_DENSEMATRIX - singular-value decompositions for dense matrix using MTJ; JAMA - eigenvalue decompositions for dense matrix using JAMA. References: JAMA - http://math.nist.gov/javanumerics/jama/; MTJ - https://github.com/fommil/matrix-toolkits-java/
One of:
"mtj_evd_densematrix"
,"mtj_evd_symmmatrix"
,"mtj_svd_densematrix"
,"jama"
.
-
pca_method
¶ Specify the algorithm to use for computing the principal components: GramSVD - uses a distributed computation of the Gram matrix, followed by a local SVD; Power - computes the SVD using the power iteration method (experimental); Randomized - uses randomized subspace iteration method; GLRM - fits a generalized low-rank model with L2 loss function and no regularization and solves for the SVD using local matrix algebra (experimental)
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.
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
(nfolds=5, balance_classes=False, class_sampling_factors=None, max_after_balance_size=5.0, max_runtime_secs=3600, max_runtime_secs_per_model=None, max_models=None, stopping_metric='AUTO', stopping_tolerance=None, stopping_rounds=3, seed=None, project_name=None, exclude_algos=None, include_algos=None, keep_cross_validation_predictions=False, keep_cross_validation_models=False, keep_cross_validation_fold_assignment=False, sort_metric='AUTO', export_checkpoints_dir=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 (DRF), an Extremely-Randomized Forest (DRF/XRT), a random grid of Generalized Linear Models (GLM) a random grid of XGBoost (XGBoost), a random grid of Gradient Boosting Machines (GBM), a random grid of Deep Neural Nets (DeepLearning), and 2 Stacked Ensembles, one of all the models, and one of only the best models of each kind.
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 the response and set of predictors >>> y = "response" >>> x = list(train.columns) #if x is defined as all columns except the response, then x is not required >>> 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) >>> # Print Leaderboard (ranked by xval metrics) >>> aml.leaderboard >>> # (Optional) Evaluate performance on a test set >>> perf = aml.leader.model_performance(test) >>> perf.auc()
-
download_mojo
(path='.', get_genmodel_jar=False, genmodel_name='')[source]¶ Download the leader model in AutoML in MOJO format.
Parameters: - path – the path where MOJO file should be saved.
- get_genmodel_jar – if True, then also download h2o-genmodel.jar and store it in folder
path
.
:param genmodel_name Custom name of genmodel jar :returns: name of the MOJO file written.
-
download_pojo
(path='', get_genmodel_jar=False, genmodel_name='')[source]¶ Download the POJO for the leader model in AutoML to the directory specified by path.
If path is an empty string, then dump the output to screen.
Parameters: - path – An absolute path to the directory where POJO should be saved.
- get_genmodel_jar – if True, then also download h2o-genmodel.jar and store it in folder
path
.
:param genmodel_name Custom name of genmodel jar :returns: name of the POJO file written.
-
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 an AutoML run >>> aml.train(y=y, training_frame=train) >>> # Get the best model in the AutoML Leaderboard >>> 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 an AutoML run >>> aml.train(y=y, training_frame=train) >>> # Get the AutoML 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 an H2OAutoML run >>> aml.train(y=y, training_frame=train) >>> # Predict with top model from AutoML Leaderboard on a H2OFrame called 'test' >>> aml.predict(test)
-
train
(x=None, y=None, training_frame=None, fold_column=None, weights_column=None, validation_frame=None, leaderboard_frame=None, blending_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_column or weights_column).
- validation_frame – H2OFrame with validation data. This argument is ignored unless the user sets nfolds = 0. If cross-validation is turned off, then a validation frame can be specified and used for early stopping of individual models and early stopping of the grid searches. By default and when nfolds > 1, cross-validation metrics will be used for early stopping and thus validation_frame will be ignored.
- leaderboard_frame – H2OFrame with test data for scoring the leaderboard. This is optional and if this is set to None (the default), then cross-validation metrics will be used to generate the leaderboard rankings instead.
- blending_frame – H2OFrame used to train the the metalearning algorithm in Stacked Ensembles (instead of relying on cross-validated predicted values). This is optional, but when provided, it is also recommended to disable cross validation by setting nfolds=0 and to provide a leaderboard frame for scoring purposes.
Returns: An H2OAutoML object.
Examples: >>> # Set up an H2OAutoML object >>> aml = H2OAutoML(max_runtime_secs=30) >>> # Launch an AutoML run >>> aml.train(y=y, training_frame=train)
-
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 buildjoin()
- Top-level user-facing API for blocking on async model buildtrain()
- 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.
-
convert_H2OXGBoostParams_2_XGBoostParams
()[source]¶ In order to use convert_H2OXGBoostParams_2_XGBoostParams and convert_H2OFrame_2_DMatrix, you must import the following toolboxes: xgboost, pandas, numpy and scipy.sparse.
Given an H2OXGBoost model, this method will generate the corresponding parameters that should be used by native XGBoost in order to give exactly the same result, assuming that the same dataset (derived from h2oFrame) is used to train the native XGBoost model.
Follow the steps below to compare H2OXGBoost and native XGBoost:
1. Train the H2OXGBoost model with H2OFrame trainFile and generate a prediction: h2oModelD = H2OXGBoostEstimator(**h2oParamsD) # parameters specified as a dict() h2oModelD.train(x=myX, y=y, training_frame=trainFile) # train with H2OFrame trainFile h2oPredict = h2oPredictD = h2oModelD.predict(trainFile)
2. Derive the DMatrix from H2OFrame: nativeDMatrix = trainFile.convert_H2OFrame_2_DMatrix(myX, y, h2oModelD)
3. Derive the parameters for native XGBoost: nativeParams = h2oModelD.convert_H2OXGBoostParams_2_XGBoostParams()
4. Train your native XGBoost model and generate a prediction: nativeModel = xgb.train(params=nativeParams[0], dtrain=nativeDMatrix, num_boost_round=nativeParams[1]) nativePredict = nativeModel.predict(data=nativeDMatrix, ntree_limit=nativeParams[1].
- Compare the predictions h2oPredict from H2OXGBoost, nativePredict from native XGBoost.
Returns: nativeParams, num_boost_round
-
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: 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
-
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
-
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, ifnfolds
> 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.
- sort_by (str) – A metric by which to sort the models in the grid space. Choices are:
-
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.
-
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.
-
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.
-
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
, wherevar
is computed assigma^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.
-
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.
-
train
(x=None, 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.
H2OSingularValueDecompositionEstimator
¶
-
class
h2o.estimators.svd.
H2OSingularValueDecompositionEstimator
(**kwargs)[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
Singular Value Decomposition
-
export_checkpoints_dir
¶ Automatically export generated models to this directory.
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_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.
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
).
-
export_checkpoints_dir
¶ Automatically export generated models to this directory.
Type:
str
.
-
static
from_external
(external=<class 'h2o.frame.H2OFrame'>)[source]¶ Creates new H2OWord2vecEstimator based on an external model. :param external: H2OFrame with an external model :return: H2OWord2vecEstimator instance representing the external model
-
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.
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"
).
-