ddl.local.ImageFeaturePairs

class ddl.local.ImageFeaturePairs(image_shape=None, relative_position=None, init_offset=None, step=None, wrap=True)[source]

Bases: sklearn.base.BaseEstimator

Generate pairs of pixels based on image layout.

For use with FeatureGroupsDestructor.

Parameters:
image_shape : array-like, shape (n_image_dimensions,)

The shape such that X[0,:].reshape(image_shape) is converted to an image. Note that image_shape could have any length depending on the number of image channels, e.g. color images with rgb channels.

relative_position : array-like, shape (n_image_dimensions,)

A relative position to pair with a selected feature. For example, if relative_position = (1, 0), then the pixels will be paired horizontally whereas if relative_position = (0, 1), then the pixels will be paired vertically.

init_offset: array-like, shape (n_image_dimensions,)

The amount to offset in all directions on the image. For example, one might first do a init_offset of (0, 0) and then a init_offset of (1, 0) to couple the all horizontal pixels.

wrap : bool

Whether to wrap the pixels to the other side so that all features are paired. For example, if relative_position = (1,0) and init_offset = (1,0), the last pixel on the row will match with the first pixel on the row.

Attributes:
groups_ : array-like, shape (n_groups, 2)

Feature indices for each group. Note that there should be no duplicate indices so that each group can be transformed independently.

Methods

fit(self, X[, y]) Fit estimator to X.
get_params(self[, deep]) Get parameters for this estimator.
set_params(self, \*\*params) Set the parameters of this estimator.
__init__(self, image_shape=None, relative_position=None, init_offset=None, step=None, wrap=True)[source]

Initialize self. See help(type(self)) for accurate signature.

fit(self, X, y=None)[source]

Fit estimator to X.

Parameters:
X : array-like, shape (n_samples, n_features)

Training data, where n_samples is the number of samples and n_features is the number of features.

y : None, default=None

Not used in the fitting process but kept for compatibility.

Returns:
self : estimator

Returns the instance itself.

get_params(self, deep=True)

Get parameters for this estimator.

Parameters:
deep : boolean, optional

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
params : mapping of string to any

Parameter names mapped to their values.

set_params(self, **params)

Set the parameters of this estimator.

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

Returns:
self