vaep.sklearn package#

Scikit-learn related functions for the project for ALD part.

Might be moved to a separate package in the future.

vaep.sklearn.get_PCA(df, n_components=2, imputer=<class 'sklearn.impute._base.SimpleImputer'>)[source]#

Submodules#

vaep.sklearn.ae_transformer module#

Scikit-learn style interface for Denoising and Variational Autoencoder model.

class vaep.sklearn.ae_transformer.AETransformer(hidden_layers: list[int], latent_dim: int = 15, out_folder: str = '.', model='VAE', batch_size: int = 64)[source]#

Bases: TransformerMixin, BaseEstimator

Collaborative Filtering transformer.

Parameters:

demo_param (str, default='demo') – A parameter used for demonstation of how to pass and store paramters.

n_features_#

The number of features of the data passed to fit().

Type:

int

fit(X: DataFrame, y: Optional[DataFrame] = None, epochs_max: int = 100, cuda: bool = True, patience: Optional[int] = None)[source]#
set_fit_request(*, cuda: Union[bool, None, str] = '$UNCHANGED$', epochs_max: Union[bool, None, str] = '$UNCHANGED$', patience: Union[bool, None, str] = '$UNCHANGED$') AETransformer#

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:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
  • cuda (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for cuda parameter in fit.

  • epochs_max (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for epochs_max parameter in fit.

  • patience (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for patience parameter in fit.

Returns:

self – The updated object.

Return type:

object

transform(X)[source]#

A reference implementation of a transform function.

Parameters:

X ({array-like, sparse-matrix}, shape (n_samples, n_features)) – The input samples.

Returns:

X_transformed – The array containing the element-wise square roots of the values in X.

Return type:

array, shape (n_samples, n_features)

vaep.sklearn.cf_transformer module#

Scikit-learn style interface for Collaborative Filtering model.

class vaep.sklearn.cf_transformer.CollaborativeFilteringTransformer(target_column: str, sample_column: str, item_column: str, n_factors: int = 15, out_folder: str = '.', batch_size: int = 4096)[source]#

Bases: TransformerMixin, BaseEstimator

Collaborative Filtering transformer.

Parameters:

demo_param (str, default='demo') – A parameter used for demonstation of how to pass and store paramters.

n_features_#

The number of features of the data passed to fit().

Type:

int

fit(X: Series, y: Optional[Series] = None, cuda: bool = True, patience: int = 1, epochs_max=20)[source]#

A reference implementation of a fitting function for a transformer.

Parameters:
  • X ({array-like, sparse matrix}, shape (n_samples, n_features)) – The training input samples.

  • y (None) – There is no need of a target in a transformer, yet the pipeline API requires this parameter.

Returns:

self – Returns self.

Return type:

object

plot_loss(y, figsize=(8, 4))[source]#
set_fit_request(*, cuda: Union[bool, None, str] = '$UNCHANGED$', epochs_max: Union[bool, None, str] = '$UNCHANGED$', patience: Union[bool, None, str] = '$UNCHANGED$') CollaborativeFilteringTransformer#

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:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
  • cuda (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for cuda parameter in fit.

  • epochs_max (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for epochs_max parameter in fit.

  • patience (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for patience parameter in fit.

Returns:

self – The updated object.

Return type:

object

transform(X)[source]#

A reference implementation of a transform function.

Parameters:

X ({array-like, sparse-matrix}, shape (n_samples, n_features)) – The input samples.

Returns:

X_transformed – The array containing the element-wise square roots of the values in X.

Return type:

array, shape (n_samples, n_features)