skelm.utils

Functions

dummy(x)

flatten(items)

Yield items from any nested iterable.

Classes

HiddenLayerType(value)

An enumeration.

PairwiseRandomProjection([n_components, ...])

class skelm.utils.HiddenLayerType(value)[source]

An enumeration.

class skelm.utils.PairwiseRandomProjection(n_components=100, pairwise_metric='l2', n_jobs=None, random_state=None)[source]
fit(X, y=None)[source]

Generate artificial centroids.

Centroids are sampled from a normal distribution. They work best if the data is normalized.

Parameters:

X ({array-like, sparse matrix}, shape=[n_samples, n_features]) – Input data

fit_transform(X, y=None, **fit_params)

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:
  • X (array-like of shape (n_samples, n_features)) – Input samples.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) – Target values (None for unsupervised transformations).

  • **fit_params (dict) – Additional fit parameters.

Returns:

X_new – Transformed array.

Return type:

ndarray array of shape (n_samples, n_features_new)

get_params(deep=True)

Get parameters for this estimator.

Parameters:

deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:

params – Parameter names mapped to their values.

Return type:

dict

set_output(*, transform=None)

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters:

transform ({"default", "pandas"}, default=None) –

Configure output of transform and fit_transform.

  • ”default”: Default output format of a transformer

  • ”pandas”: DataFrame output

  • None: Transform configuration is unchanged

Returns:

self – Estimator instance.

Return type:

estimator instance

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params (dict) – Estimator parameters.

Returns:

self – Estimator instance.

Return type:

estimator instance

transform(X)[source]

Compute distance matrix between input data and the centroids.

Parameters:

X ({array-like, sparse matrix}, shape [n_samples, n_features]) – Input data samples.

Returns:

X_dist – Distance matrix between input data samples and centroids.

Return type:

numpy array

skelm.utils.flatten(items)[source]

Yield items from any nested iterable.