snowflake.ml.modeling.ensemble.HistGradientBoostingClassifier¶
- class snowflake.ml.modeling.ensemble.HistGradientBoostingClassifier(*, loss='log_loss', learning_rate=0.1, max_iter=100, max_leaf_nodes=31, max_depth=None, min_samples_leaf=20, l2_regularization=0.0, max_bins=255, categorical_features=None, monotonic_cst=None, interaction_cst=None, warm_start=False, early_stopping='auto', scoring='loss', validation_fraction=0.1, n_iter_no_change=10, tol=1e-07, verbose=0, random_state=None, class_weight=None, input_cols: Optional[Union[str, Iterable[str]]] = None, output_cols: Optional[Union[str, Iterable[str]]] = None, label_cols: Optional[Union[str, Iterable[str]]] = None, drop_input_cols: Optional[bool] = False, sample_weight_col: Optional[str] = None)¶
Bases:
BaseTransformer
Histogram-based Gradient Boosting Classification Tree For more details on this class, see sklearn.ensemble.HistGradientBoostingClassifier
- loss: {‘log_loss’}, default=’log_loss’
The loss function to use in the boosting process.
For binary classification problems, ‘log_loss’ is also known as logistic loss, binomial deviance or binary crossentropy. Internally, the model fits one tree per boosting iteration and uses the logistic sigmoid function (expit) as inverse link function to compute the predicted positive class probability.
For multiclass classification problems, ‘log_loss’ is also known as multinomial deviance or categorical crossentropy. Internally, the model fits one tree per boosting iteration and per class and uses the softmax function as inverse link function to compute the predicted probabilities of the classes.
- learning_rate: float, default=0.1
The learning rate, also known as shrinkage. This is used as a multiplicative factor for the leaves values. Use
1
for no shrinkage.- max_iter: int, default=100
The maximum number of iterations of the boosting process, i.e. the maximum number of trees for binary classification. For multiclass classification, n_classes trees per iteration are built.
- max_leaf_nodes: int or None, default=31
The maximum number of leaves for each tree. Must be strictly greater than 1. If None, there is no maximum limit.
- max_depth: int or None, default=None
The maximum depth of each tree. The depth of a tree is the number of edges to go from the root to the deepest leaf. Depth isn’t constrained by default.
- min_samples_leaf: int, default=20
The minimum number of samples per leaf. For small datasets with less than a few hundred samples, it is recommended to lower this value since only very shallow trees would be built.
- l2_regularization: float, default=0
The L2 regularization parameter. Use 0 for no regularization.
- max_bins: int, default=255
The maximum number of bins to use for non-missing values. Before training, each feature of the input array X is binned into integer-valued bins, which allows for a much faster training stage. Features with a small number of unique values may use less than
max_bins
bins. In addition to themax_bins
bins, one more bin is always reserved for missing values. Must be no larger than 255.- categorical_features: array-like of {bool, int, str} of shape (n_features) or shape (n_categorical_features,), default=None
Indicates the categorical features.
None: no feature will be considered categorical.
boolean array-like: boolean mask indicating categorical features.
integer array-like: integer indices indicating categorical features.
str array-like: names of categorical features (assuming the training data has feature names).
For each categorical feature, there must be at most max_bins unique categories, and each categorical value must be less then max_bins - 1. Negative values for categorical features are treated as missing values. All categorical values are converted to floating point numbers. This means that categorical values of 1.0 and 1 are treated as the same category.
Read more in the User Guide.
- monotonic_cst: array-like of int of shape (n_features) or dict, default=None
Monotonic constraint to enforce on each feature are specified using the following integer values:
1: monotonic increase
0: no constraint
-1: monotonic decrease
If a dict with str keys, map feature to monotonic constraints by name. If an array, the features are mapped to constraints by position. See monotonic_cst_features_names for a usage example.
The constraints are only valid for binary classifications and hold over the probability of the positive class. Read more in the User Guide.
- interaction_cst: {“pairwise”, “no_interactions”} or sequence of lists/tuples/sets of int, default=None
Specify interaction constraints, the sets of features which can interact with each other in child node splits.
Each item specifies the set of feature indices that are allowed to interact with each other. If there are more features than specified in these constraints, they are treated as if they were specified as an additional set.
The strings “pairwise” and “no_interactions” are shorthands for allowing only pairwise or no interactions, respectively.
For instance, with 5 features in total, interaction_cst=[{0, 1}] is equivalent to interaction_cst=[{0, 1}, {2, 3, 4}], and specifies that each branch of a tree will either only split on features 0 and 1 or only split on features 2, 3 and 4.
- warm_start: bool, default=False
When set to
True
, reuse the solution of the previous call to fit and add more estimators to the ensemble. For results to be valid, the estimator should be re-trained on the same data only. See the Glossary.- early_stopping: ‘auto’ or bool, default=’auto’
If ‘auto’, early stopping is enabled if the sample size is larger than 10000. If True, early stopping is enabled, otherwise early stopping is disabled.
- scoring: str or callable or None, default=’loss’
Scoring parameter to use for early stopping. It can be a single string (see scoring_parameter) or a callable (see scoring). If None, the estimator’s default scorer is used. If
scoring='loss'
, early stopping is checked w.r.t the loss value. Only used if early stopping is performed.- validation_fraction: int or float or None, default=0.1
Proportion (or absolute size) of training data to set aside as validation data for early stopping. If None, early stopping is done on the training data. Only used if early stopping is performed.
- n_iter_no_change: int, default=10
Used to determine when to “early stop”. The fitting process is stopped when none of the last
n_iter_no_change
scores are better than then_iter_no_change - 1
-th-to-last one, up to some tolerance. Only used if early stopping is performed.- tol: float, default=1e-7
The absolute tolerance to use when comparing scores. The higher the tolerance, the more likely we are to early stop: higher tolerance means that it will be harder for subsequent iterations to be considered an improvement upon the reference score.
- verbose: int, default=0
The verbosity level. If not zero, print some information about the fitting process.
- random_state: int, RandomState instance or None, default=None
Pseudo-random number generator to control the subsampling in the binning process, and the train/validation data split if early stopping is enabled. Pass an int for reproducible output across multiple function calls. See Glossary.
- class_weight: dict or ‘balanced’, default=None
Weights associated with classes in the form {class_label: weight}. If not given, all classes are supposed to have weight one. The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as n_samples / (n_classes * np.bincount(y)). Note that these weights will be multiplied with sample_weight (passed through the fit method) if sample_weight is specified.
- input_cols: Optional[Union[str, List[str]]]
A string or list of strings representing column names that contain features. If this parameter is not specified, all columns in the input DataFrame except the columns specified by label_cols and sample-weight_col parameters are considered input columns.
- label_cols: Optional[Union[str, List[str]]]
A string or list of strings representing column names that contain labels. This is a required param for estimators, as there is no way to infer these columns. If this parameter is not specified, then object is fitted without labels(Like a transformer).
- output_cols: Optional[Union[str, List[str]]]
A string or list of strings representing column names that will store the output of predict and transform operations. The length of output_cols mus match the expected number of output columns from the specific estimator or transformer class used. If this parameter is not specified, output column names are derived by adding an OUTPUT_ prefix to the label column names. These inferred output column names work for estimator’s predict() method, but output_cols must be set explicitly for transformers.
- sample_weight_col: Optional[str]
A string representing the column name containing the examples’ weights. This argument is only required when working with weighted datasets.
- drop_input_cols: Optional[bool], default=False
If set, the response of predict(), transform() methods will not contain input columns.
Methods
decision_function
(dataset[, output_cols_prefix])Compute the decision function of
X
For more details on this function, see sklearn.ensemble.HistGradientBoostingClassifier.decision_functionfit
(dataset)Fit the gradient boosting model For more details on this function, see sklearn.ensemble.HistGradientBoostingClassifier.fit
predict
(dataset)Predict classes for X For more details on this function, see sklearn.ensemble.HistGradientBoostingClassifier.predict
predict_proba
(dataset[, output_cols_prefix])Predict class probabilities for X For more details on this function, see sklearn.ensemble.HistGradientBoostingClassifier.predict_proba
score
(dataset)Return the mean accuracy on the given test data and labels For more details on this function, see sklearn.ensemble.HistGradientBoostingClassifier.score
set_input_cols
(input_cols)Input columns setter.
to_sklearn
()Get sklearn.ensemble.HistGradientBoostingClassifier object.
Attributes
model_signatures
Returns model signature of current class.