Modeling In H2O¶
H2OEstimator
¶
-
class
h2o.estimators.estimator_base.
H2OEstimator
[source]¶ Bases:
h2o.model.model_base.ModelBase
H2O Estimators
- H2O Estimators implement the following methods for model construction:
- start - Top-level user-facing API for asynchronous model build
- join - Top-level user-facing API for blocking on async model build
- train - Top-level user-facing API for model building.
- fit - Used by scikit-learn.
Because H2OEstimator instances are instances of ModelBase, these objects can use the H2O model API.
-
fit
(X, y=None, **params)[source]¶ Fit an H2O model as part of a scikit-learn pipeline or grid search.
A warning will be issued if a caller other than sklearn attempts to use this method.
Parameters: X : H2OFrame
An H2OFrame consisting of the predictor variables.
- y : H2OFrame, optional
An H2OFrame consisting of the response variable.
- params : optional
Extra arguments.
Returns: The current instance of H2OEstimator for method chaining.
-
get_params
(deep=True)[source]¶ Useful method for obtaining parameters for this estimator. Used primarily for sklearn Pipelines and sklearn grid search.
Parameters: deep : bool, optional
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 : dict
A dictionary of parameters that will be set on this model.
Returns: 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]¶ Asynchronous model build by specifying the predictor columns, response column, and any additional frame-specific values.
To block for results, call join.
Parameters: x : list
A list of column names or indices indicating the predictor columns.
- y : str
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 : str, optional
The name or index of the column in training_frame that holds the offsets.
- fold_column : str, optional
The name or index of the column in training_frame that holds the per-row fold assignments.
- weights_column : str, optional
The name or index of the column in training_frame that holds the per-row weights.
- validation_frame : H2OFrame, optional
H2OFrame with validation data to be scored on while training.
-
train
(x, y=None, training_frame=None, offset_column=None, fold_column=None, weights_column=None, validation_frame=None, max_runtime_secs=None, **params)[source]¶ Train the H2O model by specifying the predictor columns, response column, and any additional frame-specific values.
Parameters: x : list
A list of column names or indices indicating the predictor columns.
- y : str | unicode
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 : str, optional
The name or index of the column in training_frame that holds the offsets.
- fold_column : str, optional
The name or index of the column in training_frame that holds the per-row fold assignments.
- weights_column : str, optional
The name or index of the column in training_frame that holds the per-row weights.
- validation_frame : H2OFrame, optional
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.
H2ODeepLearningEstimator
¶
-
class
h2o.estimators.deeplearning.
H2ODeepLearningEstimator
(**kwargs)[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
Deep Learning
Build a supervised Deep Neural Network model Builds a feed-forward multilayer artificial neural network on an H2OFrame
Parameters: model_id : str
Destination id for this model; auto-generated if not specified.
- training_frame : str
Id of the training data frame (Not required, to allow initial validation of model parameters).
- validation_frame : str
Id of the validation data frame.
- nfolds : int
Number of folds for N-fold cross-validation (0 to disable or ≥ 2). Default: 0
- keep_cross_validation_predictions : bool
Whether to keep the predictions of the cross-validation models. Default: False
- keep_cross_validation_fold_assignment : bool
Whether to keep the cross-validation fold assignment. Default: False
- fold_assignment : “AUTO” | “Random” | “Modulo” | “Stratified”
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. Default: “AUTO”
- fold_column : VecSpecifier
Column with cross-validation fold index assignment per observation.
- response_column : VecSpecifier
Response variable column.
- ignored_columns : list(str)
Names of columns to ignore for training.
- ignore_const_cols : bool
Ignore constant columns. Default: True
- score_each_iteration : bool
Whether to score during each iteration of model training. Default: False
- weights_column : VecSpecifier
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.
- offset_column : VecSpecifier
Offset column. This will be added to the combination of columns before applying the link function.
- balance_classes : bool
Balance training data class counts via over/under-sampling (for imbalanced data). Default: False
- class_sampling_factors : list(float)
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.
- max_after_balance_size : float
Maximum relative size of the training data after balancing class counts (can be less than 1.0). Requires balance_classes. Default: 5.0
- max_confusion_matrix_size : int
Maximum size (# classes) for confusion matrices to be printed in the Logs. Default: 20
- max_hit_ratio_k : int
Max. number (top K) of predictions to use for hit ratio computation (for multi-class only, 0 to disable). Default: 0
- checkpoint : str
Model checkpoint to resume training with.
- pretrained_autoencoder : str
Pretrained autoencoder model to initialize this model with.
- overwrite_with_best_model : bool
If enabled, override the final model with the best model found during training. Default: True
- use_all_factor_levels : bool
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. Default: True
- standardize : bool
If enabled, automatically standardize the data. If disabled, the user must provide properly scaled input data. Default: True
- activation : “Tanh” | “TanhWithDropout” | “Rectifier” | “RectifierWithDropout” | “Maxout” | “MaxoutWithDropout”
Activation function. Default: “Rectifier”
- hidden : list(int)
Hidden layer sizes (e.g. [100, 100]). Default: [200, 200]
- epochs : float
How many times the dataset should be iterated (streamed), can be fractional. Default: 10.0
- train_samples_per_iteration : int
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. Default: -2
- target_ratio_comm_to_comp : float
Target ratio of communication overhead to computation. Only for multi-node operation and train_samples_per_iteration = -2 (auto-tuning). Default: 0.05
- seed : int
Seed for random numbers (affects sampling) - Note: only reproducible when running single threaded. Default: -1
- adaptive_rate : bool
Adaptive learning rate. Default: True
- rho : float
Adaptive learning rate time decay factor (similarity to prior updates). Default: 0.99
- epsilon : float
Adaptive learning rate smoothing factor (to avoid divisions by zero and allow progress). Default: 1e-08
- rate : float
Learning rate (higher => less stable, lower => slower convergence). Default: 0.005
- rate_annealing : float
Learning rate annealing: rate / (1 + rate_annealing * samples). Default: 1e-06
- rate_decay : float
Learning rate decay factor between layers (N-th layer: rate·rate_decayᴺ⁻¹). Default: 1.0
- momentum_start : float
Initial momentum at the beginning of training (try 0.5). Default: 0.0
- momentum_ramp : float
Number of training samples for which momentum increases. Default: 1000000.0
- momentum_stable : float
Final momentum after the ramp is over (try 0.99). Default: 0.0
- nesterov_accelerated_gradient : bool
Use Nesterov accelerated gradient (recommended). Default: True
- input_dropout_ratio : float
Input layer dropout ratio (can improve generalization, try 0.1 or 0.2). Default: 0.0
- hidden_dropout_ratios : list(float)
Hidden layer dropout ratios (can improve generalization), specify one value per hidden layer, defaults to 0.5.
- l1 : float
L1 regularization (can add stability and improve generalization, causes many weights to become 0). Default: 0.0
- l2 : float
L2 regularization (can add stability and improve generalization, causes many weights to be small. Default: 0.0
- max_w2 : float
Constraint for squared sum of incoming weights per unit (e.g. for Rectifier). Default: ∞
- initial_weight_distribution : “UniformAdaptive” | “Uniform” | “Normal”
Initial weight distribution. Default: “UniformAdaptive”
- initial_weight_scale : float
Uniform: -value...value, Normal: stddev. Default: 1.0
- initial_weights : list(str)
A list of H2OFrame ids to initialize the weight matrices of this model with.
- initial_biases : list(str)
A list of H2OFrame ids to initialize the bias vectors of this model with.
- loss : “Automatic” | “CrossEntropy” | “Quadratic” | “Huber” | “Absolute” | “Quantile”
Loss function. Default: “Automatic”
- distribution : “AUTO” | “bernoulli” | “multinomial” | “gaussian” | “poisson” | “gamma” | “tweedie” | “laplace” |
“quantile” | “huber”
Distribution function Default: “AUTO”
- quantile_alpha : float
Desired quantile for Quantile regression, must be between 0 and 1. Default: 0.5
- tweedie_power : float
Tweedie power for Tweedie regression, must be between 1 and 2. Default: 1.5
- huber_alpha : float
Desired quantile for Huber/M-regression (threshold between quadratic and linear loss, must be between 0 and 1). Default: 0.9
- score_interval : float
Shortest time interval (in seconds) between model scoring. Default: 5.0
- score_training_samples : int
Number of training set samples for scoring (0 for all). Default: 10000
- score_validation_samples : int
Number of validation set samples for scoring (0 for all). Default: 0
- score_duty_cycle : float
Maximum duty cycle fraction for scoring (lower: more training, higher: more scoring). Default: 0.1
- classification_stop : float
Stopping criterion for classification error fraction on training data (-1 to disable). Default: 0.0
- regression_stop : float
Stopping criterion for regression error (MSE) on training data (-1 to disable). Default: 1e-06
- stopping_rounds : int
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) Default: 5
- stopping_metric : “AUTO” | “deviance” | “logloss” | “MSE” | “AUC” | “lift_top_group” | “r2” | “misclassification”
- “mean_per_class_error”
Metric to use for early stopping (AUTO: logloss for classification, deviance for regression) Default: “AUTO”
- stopping_tolerance : float
Relative tolerance for metric-based stopping criterion (stop if relative improvement is not at least this much) Default: 0.0
- max_runtime_secs : float
Maximum allowed runtime in seconds for model training. Use 0 to disable. Default: 0.0
- score_validation_sampling : “Uniform” | “Stratified”
Method used to sample validation dataset for scoring. Default: “Uniform”
- diagnostics : bool
Enable diagnostics for hidden layers. Default: True
- fast_mode : bool
Enable fast mode (minor approximation in back-propagation). Default: True
- force_load_balance : bool
Force extra load balancing to increase training speed for small datasets (to keep all cores busy). Default: True
- variable_importances : bool
Compute variable importances for input features (Gedeon method) - can be slow for large networks. Default: False
- replicate_training_data : bool
Replicate the entire training dataset onto every node for faster training on small datasets. Default: True
- single_node_mode : bool
Run on a single node for fine-tuning of model parameters. Default: False
- shuffle_training_data : bool
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). Default: False
- missing_values_handling : “Skip” | “MeanImputation”
Handling of missing values. Either Skip or MeanImputation. Default: “MeanImputation”
- quiet_mode : bool
Enable quiet mode for less output to standard output. Default: False
- autoencoder : bool
Auto-Encoder. Default: False
- sparse : bool
Sparse data handling (more efficient for data with lots of 0 values). Default: False
- col_major : bool
#DEPRECATED Use a column major weight matrix for input layer. Can speed up forward propagation, but might slow down backpropagation. Default: False
- average_activation : float
Average activation for sparse auto-encoder. #Experimental Default: 0.0
- sparsity_beta : float
Sparsity regularization. #Experimental Default: 0.0
- max_categorical_features : int
Max. number of categorical features, enforced via hashing. #Experimental Default: 2147483647
- reproducible : bool
Force reproducibility on small data (will be slow - only uses 1 thread). Default: False
- export_weights_and_biases : bool
Whether to export Neural Network weights and biases to H₂O Frames. Default: False
- mini_batch_size : int
Mini-batch size (smaller leads to better fit, larger can speed up and generalize better). Default: 1
- categorical_encoding : “AUTO” | “Enum” | “OneHotInternal” | “OneHotExplicit” | “Binary” | “Eigen”
Encoding scheme for categorical features Default: “AUTO”
- elastic_averaging : bool
Elastic averaging between compute nodes can improve distributed model convergence. #Experimental Default: False
- elastic_averaging_moving_rate : float
Elastic averaging moving rate (only if elastic averaging is enabled). Default: 0.9
- elastic_averaging_regularization : float
Elastic averaging regularization strength (only if elastic averaging is enabled). Default: 0.001
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)
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)
H2ORandomForestEstimator
¶
-
class
h2o.estimators.random_forest.
H2ORandomForestEstimator
(**kwargs)[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
Distributed Random Forest
Parameters: model_id : str
Destination id for this model; auto-generated if not specified.
- training_frame : str
Id of the training data frame (Not required, to allow initial validation of model parameters).
- validation_frame : str
Id of the validation data frame.
- nfolds : int
Number of folds for N-fold cross-validation (0 to disable or ≥ 2). Default: 0
- keep_cross_validation_predictions : bool
Whether to keep the predictions of the cross-validation models. Default: False
- keep_cross_validation_fold_assignment : bool
Whether to keep the cross-validation fold assignment. Default: False
- score_each_iteration : bool
Whether to score during each iteration of model training. Default: False
- score_tree_interval : int
Score the model after every so many trees. Disabled if set to 0. Default: 0
- fold_assignment : “AUTO” | “Random” | “Modulo” | “Stratified”
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. Default: “AUTO”
- fold_column : VecSpecifier
Column with cross-validation fold index assignment per observation.
- response_column : VecSpecifier
Response variable column.
- ignored_columns : list(str)
Names of columns to ignore for training.
- ignore_const_cols : bool
Ignore constant columns. Default: True
- offset_column : VecSpecifier
Offset column. This will be added to the combination of columns before applying the link function.
- weights_column : VecSpecifier
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.
- balance_classes : bool
Balance training data class counts via over/under-sampling (for imbalanced data). Default: False
- class_sampling_factors : list(float)
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.
- max_after_balance_size : float
Maximum relative size of the training data after balancing class counts (can be less than 1.0). Requires balance_classes. Default: 5.0
- max_confusion_matrix_size : int
Maximum size (# classes) for confusion matrices to be printed in the Logs Default: 20
- max_hit_ratio_k : int
Max. number (top K) of predictions to use for hit ratio computation (for multi-class only, 0 to disable) Default: 0
- ntrees : int
Number of trees. Default: 50
- max_depth : int
Maximum tree depth. Default: 20
- min_rows : float
Fewest allowed (weighted) observations in a leaf (in R called ‘nodesize’). Default: 1.0
- nbins : int
For numerical columns (real/int), build a histogram of (at least) this many bins, then split at the best point Default: 20
- nbins_top_level : int
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 Default: 1024
- nbins_cats : int
For categorical columns (factors), build a histogram of this many bins, then split at the best point. Higher values can lead to more overfitting. Default: 1024
- r2_stopping : float
Stop making trees when the R^2 metric equals or exceeds this Default: 1.79769313486e+308
- stopping_rounds : int
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) Default: 0
- stopping_metric : “AUTO” | “deviance” | “logloss” | “MSE” | “AUC” | “lift_top_group” | “r2” | “misclassification”
- “mean_per_class_error”
Metric to use for early stopping (AUTO: logloss for classification, deviance for regression) Default: “AUTO”
- stopping_tolerance : float
Relative tolerance for metric-based stopping criterion (stop if relative improvement is not at least this much) Default: 0.001
- max_runtime_secs : float
Maximum allowed runtime in seconds for model training. Use 0 to disable. Default: 0.0
- seed : int
Seed for pseudo random number generator (if applicable) Default: -1
- build_tree_one_node : bool
Run on one node only; no network overhead but fewer cpus used. Suitable for small datasets. Default: False
- mtries : int
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 Default: -1
- sample_rate : float
Row sample rate per tree (from 0.0 to 1.0) Default: 0.632000029087
- sample_rate_per_class : list(float)
Row sample rate per tree per class (from 0.0 to 1.0)
- binomial_double_trees : bool
For binary classification: Build 2x as many trees (one per class) - can lead to higher accuracy. Default: False
- checkpoint : str
Model checkpoint to resume training with.
- col_sample_rate_change_per_level : float
Relative change of the column sampling rate for every level (from 0.0 to 2.0) Default: 1.0
- col_sample_rate_per_tree : float
Column sample rate per tree (from 0.0 to 1.0) Default: 1.0
- min_split_improvement : float
Minimum relative improvement in squared error reduction for a split to happen Default: 1e-05
- histogram_type : “AUTO” | “UniformAdaptive” | “Random” | “QuantilesGlobal” | “RoundRobin”
What type of histogram to use for finding optimal split points Default: “AUTO”
H2OGradientBoostingEstimator
¶
-
class
h2o.estimators.gbm.
H2OGradientBoostingEstimator
(**kwargs)[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
Gradient Boosting Method
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.
Parameters: model_id : str
Destination id for this model; auto-generated if not specified.
- training_frame : str
Id of the training data frame (Not required, to allow initial validation of model parameters).
- validation_frame : str
Id of the validation data frame.
- nfolds : int
Number of folds for N-fold cross-validation (0 to disable or ≥ 2). Default: 0
- keep_cross_validation_predictions : bool
Whether to keep the predictions of the cross-validation models. Default: False
- keep_cross_validation_fold_assignment : bool
Whether to keep the cross-validation fold assignment. Default: False
- score_each_iteration : bool
Whether to score during each iteration of model training. Default: False
- score_tree_interval : int
Score the model after every so many trees. Disabled if set to 0. Default: 0
- fold_assignment : “AUTO” | “Random” | “Modulo” | “Stratified”
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. Default: “AUTO”
- fold_column : VecSpecifier
Column with cross-validation fold index assignment per observation.
- response_column : VecSpecifier
Response variable column.
- ignored_columns : list(str)
Names of columns to ignore for training.
- ignore_const_cols : bool
Ignore constant columns. Default: True
- offset_column : VecSpecifier
Offset column. This will be added to the combination of columns before applying the link function.
- weights_column : VecSpecifier
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.
- balance_classes : bool
Balance training data class counts via over/under-sampling (for imbalanced data). Default: False
- class_sampling_factors : list(float)
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.
- max_after_balance_size : float
Maximum relative size of the training data after balancing class counts (can be less than 1.0). Requires balance_classes. Default: 5.0
- max_confusion_matrix_size : int
Maximum size (# classes) for confusion matrices to be printed in the Logs Default: 20
- max_hit_ratio_k : int
Max. number (top K) of predictions to use for hit ratio computation (for multi-class only, 0 to disable) Default: 0
- ntrees : int
Number of trees. Default: 50
- max_depth : int
Maximum tree depth. Default: 5
- min_rows : float
Fewest allowed (weighted) observations in a leaf (in R called ‘nodesize’). Default: 10.0
- nbins : int
For numerical columns (real/int), build a histogram of (at least) this many bins, then split at the best point Default: 20
- nbins_top_level : int
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 Default: 1024
- nbins_cats : int
For categorical columns (factors), build a histogram of this many bins, then split at the best point. Higher values can lead to more overfitting. Default: 1024
- r2_stopping : float
Stop making trees when the R^2 metric equals or exceeds this Default: 1.79769313486e+308
- stopping_rounds : int
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) Default: 0
- stopping_metric : “AUTO” | “deviance” | “logloss” | “MSE” | “AUC” | “lift_top_group” | “r2” | “misclassification”
- “mean_per_class_error”
Metric to use for early stopping (AUTO: logloss for classification, deviance for regression) Default: “AUTO”
- stopping_tolerance : float
Relative tolerance for metric-based stopping criterion (stop if relative improvement is not at least this much) Default: 0.001
- max_runtime_secs : float
Maximum allowed runtime in seconds for model training. Use 0 to disable. Default: 0.0
- seed : int
Seed for pseudo random number generator (if applicable) Default: -1
- build_tree_one_node : bool
Run on one node only; no network overhead but fewer cpus used. Suitable for small datasets. Default: False
- learn_rate : float
Learning rate (from 0.0 to 1.0) Default: 0.1
- learn_rate_annealing : float
Scale the learning rate by this factor after each tree (e.g., 0.99 or 0.999) Default: 1.0
- distribution : “AUTO” | “bernoulli” | “multinomial” | “gaussian” | “poisson” | “gamma” | “tweedie” | “laplace” |
“quantile” | “huber”
Distribution function Default: “AUTO”
- quantile_alpha : float
Desired quantile for Quantile regression, must be between 0 and 1. Default: 0.5
- tweedie_power : float
Tweedie power for Tweedie regression, must be between 1 and 2. Default: 1.5
- huber_alpha : float
Desired quantile for Huber/M-regression (threshold between quadratic and linear loss, must be between 0 and 1). Default: 0.9
- checkpoint : str
Model checkpoint to resume training with.
- sample_rate : float
Row sample rate per tree (from 0.0 to 1.0) Default: 1.0
- sample_rate_per_class : list(float)
Row sample rate per tree per class (from 0.0 to 1.0)
- col_sample_rate : float
Column sample rate (from 0.0 to 1.0) Default: 1.0
- col_sample_rate_change_per_level : float
Relative change of the column sampling rate for every level (from 0.0 to 2.0) Default: 1.0
- col_sample_rate_per_tree : float
Column sample rate per tree (from 0.0 to 1.0) Default: 1.0
- min_split_improvement : float
Minimum relative improvement in squared error reduction for a split to happen Default: 1e-05
- histogram_type : “AUTO” | “UniformAdaptive” | “Random” | “QuantilesGlobal” | “RoundRobin”
What type of histogram to use for finding optimal split points Default: “AUTO”
- max_abs_leafnode_pred : float
Maximum absolute value of a leaf node prediction Default: 1.79769313486e+308
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.
Parameters: model_id : str
Destination id for this model; auto-generated if not specified.
- training_frame : str
Id of the training data frame (Not required, to allow initial validation of model parameters).
- validation_frame : str
Id of the validation data frame.
- nfolds : int
Number of folds for N-fold cross-validation (0 to disable or ≥ 2). Default: 0
- seed : int
Seed for pseudo random number generator (if applicable) Default: -1
- keep_cross_validation_predictions : bool
Whether to keep the predictions of the cross-validation models. Default: False
- keep_cross_validation_fold_assignment : bool
Whether to keep the cross-validation fold assignment. Default: False
- fold_assignment : “AUTO” | “Random” | “Modulo” | “Stratified”
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. Default: “AUTO”
- fold_column : VecSpecifier
Column with cross-validation fold index assignment per observation.
- response_column : VecSpecifier
Response variable column.
- ignored_columns : list(str)
Names of columns to ignore for training.
- ignore_const_cols : bool
Ignore constant columns. Default: True
- score_each_iteration : bool
Whether to score during each iteration of model training. Default: False
- offset_column : VecSpecifier
Offset column. This will be added to the combination of columns before applying the link function.
- weights_column : VecSpecifier
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.
- family : “gaussian” | “binomial” | “multinomial” | “poisson” | “gamma” | “tweedie”
Family. Use binomial for classification with logistic regression, others are for regression problems. Default: “gaussian”
- tweedie_variance_power : float
Tweedie variance power Default: 0.0
- tweedie_link_power : float
Tweedie link power Default: 1.0
- solver : “AUTO” | “IRLSM” | “L_BFGS” | “COORDINATE_DESCENT_NAIVE” | “COORDINATE_DESCENT”
AUTO will set the solver based on given data and the other parameters. IRLSM is fast on on problems with small number of predictors and for lambda-search with L1 penalty, L_BFGS scales better for datasets with many columns. Coordinate descent is experimental (beta). Default: “AUTO”
- alpha : list(float)
distribution of regularization between L1 and L2.
- lambda_ : list(float)
regularization strength
- lambda_search : bool
use lambda search starting at lambda max, given lambda is then interpreted as lambda min Default: False
- early_stopping : bool
stop early when there is no more relative improvement on train or validation (if provided) Default: True
- nlambdas : int
number of lambdas to be used in a search Default: -1
- standardize : bool
Standardize numeric columns to have zero mean and unit variance Default: True
- missing_values_handling : “Skip” | “MeanImputation”
Handling of missing values. Either Skip or MeanImputation. Default: “MeanImputation”
- compute_p_values : bool
request p-values computation, p-values work only with IRLSM solver and no regularization Default: False
- remove_collinear_columns : bool
in case of linearly dependent columns remove some of the dependent columns Default: False
- intercept : bool
include constant term in the model Default: True
- non_negative : bool
Restrict coefficients (not intercept) to be non-negative Default: False
- max_iterations : int
Maximum number of iterations Default: -1
- objective_epsilon : float
converge if objective value changes less than this Default: -1.0
- beta_epsilon : float
converge if beta changes less (using L-infinity norm) than beta esilon, ONLY applies to IRLSM solver Default: 0.0001
- gradient_epsilon : float
converge if objective changes less (using L-infinity norm) than this, ONLY applies to L-BFGS solver Default: -1.0
link : “family_default” | “identity” | “logit” | “log” | “inverse” | “tweedie”
Default: “family_default”
- prior : float
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. Default: -1.0
- lambda_min_ratio : float
min lambda used in lambda search, specified as a ratio of lambda_max Default: -1.0
- beta_constraints : str
beta constraints
- max_active_predictors : int
Maximum number of active predictors during computation. Use as a stopping criterium to prevent expensive model building with many predictors. Default: -1
- interactions : list(str)
A list of predictor column indices to interact. All pairwise combinations will be computed for the list.
- balance_classes : bool
Balance training data class counts via over/under-sampling (for imbalanced data). Default: False
- class_sampling_factors : list(float)
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.
- max_after_balance_size : float
Maximum relative size of the training data after balancing class counts (can be less than 1.0). Requires balance_classes. Default: 5.0
- max_confusion_matrix_size : int
Maximum size (# classes) for confusion matrices to be printed in the Logs Default: 20
- max_hit_ratio_k : int
Max. number (top K) of predictions to use for hit ratio computation (for multi-class only, 0 to disable) Default: 0
- max_runtime_secs : float
Maximum allowed runtime in seconds for model training. Use 0 to disable. Default: 0.0
Returns: 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
-
static
getGLMRegularizationPath
(model)[source]¶ Extract full regularization path explored during lambda search from glm model. @param model - source lambda search model
-
lambda_
¶ [DEPRECATED] Use self.lambda_ instead
-
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.
@param model - source model, used for extracting dataset information @param coefs - dictionary containing model coefficients @param threshold - (optional, only for binomial) decision threshold used for classification
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.
Parameters: model_id : str
Destination id for this model; auto-generated if not specified.
- training_frame : str
Id of the training data frame (Not required, to allow initial validation of model parameters).
- validation_frame : str
Id of the validation data frame.
- ignored_columns : list(str)
Names of columns to ignore for training.
- ignore_const_cols : bool
Ignore constant columns. Default: True
- score_each_iteration : bool
Whether to score during each iteration of model training. Default: False
- loading_name : str
Frame key to save resulting X
- transform : “NONE” | “STANDARDIZE” | “NORMALIZE” | “DEMEAN” | “DESCALE”
Transformation of training data Default: “NONE”
- k : int, required
Rank of matrix approximation Default: 1
- loss : “Quadratic” | “Absolute” | “Huber” | “Poisson” | “Hinge” | “Logistic” | “Periodic”
Numeric loss function Default: “Quadratic”
- loss_by_col : list(“Quadratic” | “Absolute” | “Huber” | “Poisson” | “Hinge” | “Logistic” | “Periodic” |
“Categorical” | “Ordinal”)
Loss function by column (override)
- loss_by_col_idx : list(int)
Loss function by column index (override)
- multi_loss : “Categorical” | “Ordinal”
Categorical loss function Default: “Categorical”
- period : int
Length of period (only used with periodic loss function) Default: 1
- regularization_x : “None” | “Quadratic” | “L2” | “L1” | “NonNegative” | “OneSparse” | “UnitOneSparse” | “Simplex”
Regularization function for X matrix Default: “None”
- regularization_y : “None” | “Quadratic” | “L2” | “L1” | “NonNegative” | “OneSparse” | “UnitOneSparse” | “Simplex”
Regularization function for Y matrix Default: “None”
- gamma_x : float
Regularization weight on X matrix Default: 0.0
- gamma_y : float
Regularization weight on Y matrix Default: 0.0
- max_iterations : int
Maximum number of iterations Default: 1000
- max_updates : int
Maximum number of updates Default: 2000
- init_step_size : float
Initial step size Default: 1.0
- min_step_size : float
Minimum step size Default: 0.0001
- seed : int
RNG seed for initialization Default: -1
- init : “Random” | “SVD” | “PlusPlus” | “User”
Initialization mode Default: “PlusPlus”
- svd_method : “GramSVD” | “Power” | “Randomized”
Method for computing SVD during initialization (Caution: Power and Randomized are currently experimental and unstable) Default: “Randomized”
- user_y : str
User-specified initial Y
- user_x : str
User-specified initial X
- expand_user_y : bool
Expand categorical columns in user-specified initial Y Default: True
- impute_original : bool
Reconstruct original training data by reversing transform Default: False
- recover_svd : bool
Recover singular values and eigenvectors of XY Default: False
- max_runtime_secs : float
Maximum allowed runtime in seconds for model training. Use 0 to disable. Default: 0.0
H2OKMeansEstimator
¶
-
class
h2o.estimators.kmeans.
H2OKMeansEstimator
(**kwargs)[source]¶ Bases:
h2o.estimators.estimator_base.H2OEstimator
K-means
Parameters: model_id : str
Destination id for this model; auto-generated if not specified.
- training_frame : str
Id of the training data frame (Not required, to allow initial validation of model parameters).
- validation_frame : str
Id of the validation data frame.
- nfolds : int
Number of folds for N-fold cross-validation (0 to disable or ≥ 2). Default: 0
- keep_cross_validation_predictions : bool
Whether to keep the predictions of the cross-validation models. Default: False
- keep_cross_validation_fold_assignment : bool
Whether to keep the cross-validation fold assignment. Default: False
- fold_assignment : “AUTO” | “Random” | “Modulo” | “Stratified”
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. Default: “AUTO”
- fold_column : VecSpecifier
Column with cross-validation fold index assignment per observation.
- ignored_columns : list(str)
Names of columns to ignore for training.
- ignore_const_cols : bool
Ignore constant columns. Default: True
- score_each_iteration : bool
Whether to score during each iteration of model training. Default: False
- k : int, required
Number of clusters Default: 1
- user_points : str
User-specified points
- max_iterations : int
Maximum training iterations Default: 1000
- standardize : bool
Standardize columns Default: True
- seed : int
RNG Seed Default: -1
- init : “Random” | “PlusPlus” | “Furthest” | “User”
Initialization mode Default: “Furthest”
- max_runtime_secs : float
Maximum allowed runtime in seconds for model training. Use 0 to disable. Default: 0.0
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.
Parameters: model_id : str
Destination id for this model; auto-generated if not specified.
- nfolds : int
Number of folds for N-fold cross-validation (0 to disable or ≥ 2). Default: 0
- seed : int
Seed for pseudo random number generator (only used for cross-validation and fold_assignment=”Random” or “AUTO”) Default: -1
- fold_assignment : “AUTO” | “Random” | “Modulo” | “Stratified”
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. Default: “AUTO”
- fold_column : VecSpecifier
Column with cross-validation fold index assignment per observation.
- keep_cross_validation_predictions : bool
Whether to keep the predictions of the cross-validation models. Default: False
- keep_cross_validation_fold_assignment : bool
Whether to keep the cross-validation fold assignment. Default: False
- training_frame : str
Id of the training data frame (Not required, to allow initial validation of model parameters).
- validation_frame : str
Id of the validation data frame.
- response_column : VecSpecifier
Response variable column.
- ignored_columns : list(str)
Names of columns to ignore for training.
- ignore_const_cols : bool
Ignore constant columns. Default: True
- score_each_iteration : bool
Whether to score during each iteration of model training. Default: False
- balance_classes : bool
Balance training data class counts via over/under-sampling (for imbalanced data). Default: False
- class_sampling_factors : list(float)
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.
- max_after_balance_size : float
Maximum relative size of the training data after balancing class counts (can be less than 1.0). Requires balance_classes. Default: 5.0
- max_confusion_matrix_size : int
Maximum size (# classes) for confusion matrices to be printed in the Logs Default: 20
- max_hit_ratio_k : int
Max. number (top K) of predictions to use for hit ratio computation (for multi-class only, 0 to disable) Default: 0
- laplace : float
Laplace smoothing parameter Default: 0.0
- min_sdev : float
Min. standard deviation to use for observations with not enough data Default: 0.001
- eps_sdev : float
Cutoff below which standard deviation is replaced with min_sdev Default: 0.0
- min_prob : float
Min. probability to use for observations with not enough data Default: 0.001
- eps_prob : float
Cutoff below which probability is replaced with min_prob Default: 0.0
- compute_metrics : bool
Compute metrics on training data Default: True
- max_runtime_secs : float
Maximum allowed runtime in seconds for model training. Use 0 to disable. Default: 0.0