Class: KBinsDiscretizer
Bin continuous data into intervals.
Read more in the User Guide.
Constructors
new KBinsDiscretizer()
new KBinsDiscretizer(
opts
?):KBinsDiscretizer
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.dtype ? | any | The desired data-type for the output. If undefined , output dtype is consistent with input dtype. Only np.float32 and np.float64 are supported. |
opts.encode ? | "onehot" | "onehot-dense" | "ordinal" | Method used to encode the transformed result. |
opts.n_bins ? | number | ArrayLike | The number of bins to produce. Raises ValueError if n_bins < 2 . |
opts.random_state ? | number | Determines random number generation for subsampling. Pass an int for reproducible results across multiple function calls. See the subsample parameter for more details. See Glossary. |
opts.strategy ? | "uniform" | "quantile" | "kmeans" | Strategy used to define the widths of the bins. |
opts.subsample ? | number | Maximum number of samples, used to fit the model, for computational efficiency. subsample=None means that all the training samples are used when computing the quantiles that determine the binning thresholds. Since quantile computation relies on sorting each column of X and that sorting has an n log(n) time complexity, it is recommended to use subsampling on datasets with a very large number of samples. |
Returns KBinsDiscretizer
Defined in generated/preprocessing/KBinsDiscretizer.ts:23
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/preprocessing/KBinsDiscretizer.ts:21 |
_isInitialized | boolean | false | generated/preprocessing/KBinsDiscretizer.ts:20 |
_py | PythonBridge | undefined | generated/preprocessing/KBinsDiscretizer.ts:19 |
id | string | undefined | generated/preprocessing/KBinsDiscretizer.ts:16 |
opts | any | undefined | generated/preprocessing/KBinsDiscretizer.ts:17 |
Accessors
bin_edges_
Get Signature
get bin_edges_():
Promise
<any
[]>
The edges of each bin. Contain arrays of varying shapes (n_bins_, )
Ignored features will have empty arrays.
Returns Promise
<any
[]>
Defined in generated/preprocessing/KBinsDiscretizer.ts:456
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/preprocessing/KBinsDiscretizer.ts:537
n_bins_
Get Signature
get n_bins_():
Promise
<ArrayLike
>
Number of bins per feature. Bins whose width are too small (i.e., <= 1e-8) are removed with a warning.
Returns Promise
<ArrayLike
>
Defined in generated/preprocessing/KBinsDiscretizer.ts:483
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/preprocessing/KBinsDiscretizer.ts:510
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge
):void
Parameters
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/preprocessing/KBinsDiscretizer.ts:66
Methods
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/preprocessing/KBinsDiscretizer.ts:120
fit()
fit(
opts
):Promise
<any
>
Fit the estimator.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Contains weight values to be associated with each sample. Cannot be used when strategy is set to "uniform" . |
opts.X ? | ArrayLike [] | Data to be discretized. |
opts.y ? | any | Ignored. This parameter exists only for compatibility with Pipeline . |
Returns Promise
<any
>
Defined in generated/preprocessing/KBinsDiscretizer.ts:137
fit_transform()
fit_transform(
opts
):Promise
<any
[]>
Fit to data, then transform it.
Fits transformer to X
and y
with optional parameters fit_params
and returns a transformed version of X
.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.fit_params ? | any | Additional fit parameters. |
opts.X ? | ArrayLike [] | Input samples. |
opts.y ? | ArrayLike | Target values (undefined for unsupervised transformations). |
Returns Promise
<any
[]>
Defined in generated/preprocessing/KBinsDiscretizer.ts:183
get_feature_names_out()
get_feature_names_out(
opts
):Promise
<any
>
Get output feature names.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.input_features ? | any | Input features. |
Returns Promise
<any
>
Defined in generated/preprocessing/KBinsDiscretizer.ts:229
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A MetadataRequest encapsulating routing information. |
Returns Promise
<any
>
Defined in generated/preprocessing/KBinsDiscretizer.ts:267
init()
init(
py
):Promise
<void
>
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Parameters
Parameter | Type |
---|---|
py | PythonBridge |
Returns Promise
<void
>
Defined in generated/preprocessing/KBinsDiscretizer.ts:79
inverse_transform()
inverse_transform(
opts
):Promise
<ArrayLike
>
Transform discretized data back to original feature space.
Note that this function does not regenerate the original data due to discretization rounding.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | Transformed data in the binned space. |
opts.Xt ? | ArrayLike [] | Transformed data in the binned space. |
Returns Promise
<ArrayLike
>
Defined in generated/preprocessing/KBinsDiscretizer.ts:305
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata routing for sample_weight parameter in fit . |
Returns Promise
<any
>
Defined in generated/preprocessing/KBinsDiscretizer.ts:350
set_output()
set_output(
opts
):Promise
<any
>
Set output container.
See Introducing the set_output API for an example on how to use the API.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.transform ? | "default" | "pandas" | "polars" | Configure output of transform and fit_transform . |
Returns Promise
<any
>
Defined in generated/preprocessing/KBinsDiscretizer.ts:388
transform()
transform(
opts
):Promise
<ArrayLike
>
Discretize the data.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | Data to be discretized. |
Returns Promise
<ArrayLike
>