bigframes.ml.preprocessing.KBinsDiscretizer#

class bigframes.ml.preprocessing.KBinsDiscretizer(n_bins: int = 5, strategy: Literal['uniform', 'quantile'] = 'quantile')[source]#

Bin continuous data into intervals.

Parameters:
  • n_bins (int, default 5) – The number of bins to produce. Raises ValueError if n_bins < 2.

  • strategy ({'uniform', 'quantile'}, default='quantile') – Strategy used to define the widths of the bins. ‘uniform’: All bins in each feature have identical widths. ‘quantile’: All bins in each feature have the same number of points.

fit(X: DataFrame | Series | DataFrame | Series, y=None) → KBinsDiscretizer[source]#

Fit the estimator.

Parameters:
Returns:

Fitted scaler.

Return type:

KBinsDiscretizer

fit_transform(X: DataFrame | Series | DataFrame | Series, y: DataFrame | Series | DataFrame | Series | None = None) → DataFrame#

Fit to data, then transform it.

Parameters:
Returns:

DataFrame of shape (n_samples, n_features_new).

Transformed DataFrame.

Return type:

bigframes.dataframe.DataFrame

to_gbq(model_name: str, replace: bool = False) → _T#

Save the transformer as a BigQuery model.

Parameters:
  • model_name (str) – The name of the model.

  • replace (bool, default False) – Determine whether to replace if the model already exists. Default to False.

Returns:

Saved transformer.

transform(X: DataFrame | Series | DataFrame | Series) → DataFrame[source]#

Discretize the data.

Parameters:

X (bigframes.dataframe.DataFrame or bigframes.series.Series or pandas.core.frame.DataFrame or pandas.core.series.Series) – The DataFrame or Series to be transformed.

Returns:

Transformed result.

Return type:

bigframes.dataframe.DataFrame