DocumentationClassesHistGradientBoostingClassifier

Class: HistGradientBoostingClassifier

Histogram-based Gradient Boosting Classification Tree.

This estimator is much faster than GradientBoostingClassifier for big datasets (n_samples >= 10 000).

This estimator has native support for missing values (NaNs). During training, the tree grower learns at each split point whether samples with missing values should go to the left or right child, based on the potential gain. When predicting, samples with missing values are assigned to the left or right child consequently. If no missing values were encountered for a given feature during training, then samples with missing values are mapped to whichever child has the most samples.

This implementation is inspired by LightGBM.

Read more in the User Guide.

Python Reference

Constructors

new HistGradientBoostingClassifier()

new HistGradientBoostingClassifier(opts?): HistGradientBoostingClassifier

Parameters

ParameterTypeDescription
opts?object-
opts.categorical_features?numberIndicates the categorical features.
opts.class_weight?anyWeights 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.
opts.early_stopping?boolean | "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.
opts.interaction_cst?"pairwise" | "no_interactions"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.
opts.l2_regularization?numberThe L2 regularization parameter penalizing leaves with small hessians. Use 0 for no regularization (default).
opts.learning_rate?numberThe learning rate, also known as shrinkage. This is used as a multiplicative factor for the leaves values. Use 1 for no shrinkage.
opts.loss?"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.
opts.max_bins?numberThe 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 the max_bins bins, one more bin is always reserved for missing values. Must be no larger than 255.
opts.max_depth?numberThe 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.
opts.max_features?numberProportion of randomly chosen features in each and every node split. This is a form of regularization, smaller values make the trees weaker learners and might prevent overfitting. If interaction constraints from interaction_cst are present, only allowed features are taken into account for the subsampling.
opts.max_iter?numberThe 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.
opts.max_leaf_nodes?numberThe maximum number of leaves for each tree. Must be strictly greater than 1. If undefined, there is no maximum limit.
opts.min_samples_leaf?numberThe 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.
opts.monotonic_cst?anyMonotonic constraint to enforce on each feature are specified using the following integer values:
opts.n_iter_no_change?numberUsed to determine when to “early stop”. The fitting process is stopped when none of the last n_iter_no_change scores are better than the n_iter_no_change \- 1 -th-to-last one, up to some tolerance. Only used if early stopping is performed.
opts.random_state?numberPseudo-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.
opts.scoring?stringScoring parameter to use for early stopping. It can be a single string (see The scoring parameter: defining model evaluation rules) or a callable (see Defining your scoring strategy from metric functions). If undefined, 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.
opts.tol?numberThe 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.
opts.validation_fraction?numberProportion (or absolute size) of training data to set aside as validation data for early stopping. If undefined, early stopping is done on the training data. Only used if early stopping is performed.
opts.verbose?numberThe verbosity level. If not zero, print some information about the fitting process.
opts.warm_start?booleanWhen 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.

Returns HistGradientBoostingClassifier

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:29

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/ensemble/HistGradientBoostingClassifier.ts:27
_isInitializedbooleanfalsegenerated/ensemble/HistGradientBoostingClassifier.ts:26
_pyPythonBridgeundefinedgenerated/ensemble/HistGradientBoostingClassifier.ts:25
idstringundefinedgenerated/ensemble/HistGradientBoostingClassifier.ts:22
optsanyundefinedgenerated/ensemble/HistGradientBoostingClassifier.ts:23

Accessors

classes_

Get Signature

get classes_(): Promise<any>

Class labels.

Returns Promise<any>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:686


do_early_stopping_

Get Signature

get do_early_stopping_(): Promise<boolean>

Indicates whether early stopping is used during training.

Returns Promise<boolean>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:713


feature_names_in_

Get Signature

get feature_names_in_(): Promise<ArrayLike>

Names of features seen during fit. Defined only when X has feature names that are all strings.

Returns Promise<ArrayLike>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:875


is_categorical_

Get Signature

get is_categorical_(): Promise<ArrayLike>

Boolean mask for the categorical features. undefined if there are no categorical features.

Returns Promise<ArrayLike>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:821


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:848


n_trees_per_iteration_

Get Signature

get n_trees_per_iteration_(): Promise<number>

The number of tree that are built at each iteration. This is equal to 1 for binary classification, and to n_classes for multiclass classification.

Returns Promise<number>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:740


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:179


train_score_

Get Signature

get train_score_(): Promise<ArrayLike>

The scores at each iteration on the training data. The first entry is the score of the ensemble before the first iteration. Scores are computed according to the scoring parameter. If scoring is not ‘loss’, scores are computed on a subset of at most 10 000 samples. Empty if no early stopping.

Returns Promise<ArrayLike>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:767


validation_score_

Get Signature

get validation_score_(): Promise<ArrayLike>

The scores at each iteration on the held-out validation data. The first entry is the score of the ensemble before the first iteration. Scores are computed according to the scoring parameter. Empty if no early stopping or if validation_fraction is undefined.

Returns Promise<ArrayLike>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:794

Methods

decision_function()

decision_function(opts): Promise<ArrayLike>

Compute the decision function of X.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeThe input samples.

Returns Promise<ArrayLike>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:252


dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Returns Promise<void>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:235


fit()

fit(opts): Promise<any>

Fit the gradient boosting model.

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?anyWeights of training data.
opts.X?ArrayLike[]The input samples.
opts.y?ArrayLikeTarget values.

Returns Promise<any>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:288


get_metadata_routing()

get_metadata_routing(opts): Promise<any>

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Parameters

ParameterTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns Promise<any>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:336


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:192


predict()

predict(opts): Promise<ArrayLike>

Predict classes for X.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeThe input samples.

Returns Promise<ArrayLike>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:372


predict_proba()

predict_proba(opts): Promise<ArrayLike>

Predict class probabilities for X.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeThe input samples.

Returns Promise<ArrayLike>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:408


score()

score(opts): Promise<number>

Return the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeSample weights.
opts.X?ArrayLike[]Test samples.
opts.y?ArrayLikeTrue labels for X.

Returns Promise<number>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:446


set_fit_request()

set_fit_request(opts): Promise<any>

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in fit.

Returns Promise<any>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:496


set_score_request()

set_score_request(opts): Promise<any>

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in score.

Returns Promise<any>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:536


staged_decision_function()

staged_decision_function(opts): Promise<any[]>

Compute decision function of X for each iteration.

This method allows monitoring (i.e. determine error on testing set) after each stage.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]The input samples.

Returns Promise<any[]>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:574


staged_predict()

staged_predict(opts): Promise<any[]>

Predict classes at each iteration.

This method allows monitoring (i.e. determine error on testing set) after each stage.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]The input samples.

Returns Promise<any[]>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:612


staged_predict_proba()

staged_predict_proba(opts): Promise<any[]>

Predict class probabilities at each iteration.

This method allows monitoring (i.e. determine error on testing set) after each stage.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]The input samples.

Returns Promise<any[]>

Defined in generated/ensemble/HistGradientBoostingClassifier.ts:650