secml.ml.features.reduction

CReducer

class secml.ml.features.reduction.c_reducer.CReducer(preprocess=None)[source]

Bases: secml.ml.features.c_preprocess.CPreProcess

Interface for feature dimensionality reduction algorithms.

Attributes
class_type

Defines class type.

logger

Logger for current object.

n_jobs
preprocess

Inner preprocessor (if any).

verbose

Verbosity level of logger output.

Methods

backward(self[, w])

Returns the preprocessor gradient wrt data.

copy(self)

Returns a shallow copy of current class.

create([class_item])

This method creates an instance of a class with given type.

create_chain(class_items, kwargs_list)

Creates a chain of preprocessors.

deepcopy(self)

Returns a deep copy of current class.

fit(self, x[, y])

Fit the preprocessor.

fit_forward(self, x[, y, caching])

Fit estimator using data and then execute forward on the data.

fit_transform(self, x[, y])

Fit preprocessor using data and then transform data.

forward(self, x[, caching])

Forward pass on input x.

get_class_from_type(class_type)

Return the class associated with input type.

get_params(self)

Returns the dictionary of class hyperparameters.

get_state(self, **kwargs)

Returns the object state dictionary.

get_subclasses()

Get all the subclasses of the calling class.

gradient(self, x[, w])

Compute gradient at x by doing a backward pass.

inverse_transform(self, x)

Revert data to original form.

list_class_types()

This method lists all types of available subclasses of calling one.

load(path)

Loads object from file.

load_state(self, path)

Sets the object state from file.

save(self, path)

Save class object to file.

save_state(self, path, **kwargs)

Store the object state to file.

set(self, param_name, param_value[, copy])

Set a parameter of the class.

set_params(self, params_dict[, copy])

Set all parameters passed as a dictionary {key: value}.

set_state(self, state_dict[, copy])

Sets the object state using input dictionary.

timed([msg])

Timer decorator.

transform(self, x)

Apply the transformation algorithm on data.

CLDA

class secml.ml.features.reduction.c_reducer_lda.CLDA(n_components=None, preprocess=None)[source]

Bases: secml.ml.features.reduction.c_reducer.CReducer

Linear Discriminant Analysis (LDA).

Parameters
preprocessCPreProcess or str or None, optional

Features preprocess to be applied to input data. Can be a CPreProcess subclass or a string with the type of the desired preprocessor. If None, input data is used as is.

Attributes
class_type‘lda’

Defines class type.

Methods

backward(self[, w])

Returns the preprocessor gradient wrt data.

copy(self)

Returns a shallow copy of current class.

create([class_item])

This method creates an instance of a class with given type.

create_chain(class_items, kwargs_list)

Creates a chain of preprocessors.

deepcopy(self)

Returns a deep copy of current class.

fit(self, x[, y])

Fit the preprocessor.

fit_forward(self, x[, y, caching])

Fit estimator using data and then execute forward on the data.

fit_transform(self, x[, y])

Fit preprocessor using data and then transform data.

forward(self, x[, caching])

Forward pass on input x.

get_class_from_type(class_type)

Return the class associated with input type.

get_params(self)

Returns the dictionary of class hyperparameters.

get_state(self, **kwargs)

Returns the object state dictionary.

get_subclasses()

Get all the subclasses of the calling class.

gradient(self, x[, w])

Compute gradient at x by doing a backward pass.

inverse_transform(self, x)

Revert data to original form.

list_class_types()

This method lists all types of available subclasses of calling one.

load(path)

Loads object from file.

load_state(self, path)

Sets the object state from file.

save(self, path)

Save class object to file.

save_state(self, path, **kwargs)

Store the object state to file.

set(self, param_name, param_value[, copy])

Set a parameter of the class.

set_params(self, params_dict[, copy])

Set all parameters passed as a dictionary {key: value}.

set_state(self, state_dict[, copy])

Sets the object state using input dictionary.

timed([msg])

Timer decorator.

transform(self, x)

Apply the transformation algorithm on data.

property classes

Unique targets used for training.

property eigenvec

Eigenvectors estimated from the training data. Is a matrix of shape: n_eigenvectors * n_features.

property lda

Trained sklearn LDA transformer.

property mean

Per-feature empirical mean, estimated from the training data.

CPCA

class secml.ml.features.reduction.c_reducer_pca.CPCA(n_components=None, preprocess=None)[source]

Bases: secml.ml.features.reduction.c_reducer.CReducer

Principal Component Analysis (PCA).

Parameters
preprocessCPreProcess or str or None, optional

Features preprocess to be applied to input data. Can be a CPreProcess subclass or a string with the type of the desired preprocessor. If None, input data is used as is.

Attributes
class_type‘pca’

Defines class type.

Methods

backward(self[, w])

Returns the preprocessor gradient wrt data.

copy(self)

Returns a shallow copy of current class.

create([class_item])

This method creates an instance of a class with given type.

create_chain(class_items, kwargs_list)

Creates a chain of preprocessors.

deepcopy(self)

Returns a deep copy of current class.

fit(self, x[, y])

Fit the preprocessor.

fit_forward(self, x[, y, caching])

Fit estimator using data and then execute forward on the data.

fit_transform(self, x[, y])

Fit preprocessor using data and then transform data.

forward(self, x[, caching])

Forward pass on input x.

get_class_from_type(class_type)

Return the class associated with input type.

get_params(self)

Returns the dictionary of class hyperparameters.

get_state(self, **kwargs)

Returns the object state dictionary.

get_subclasses()

Get all the subclasses of the calling class.

gradient(self, x[, w])

Compute gradient at x by doing a backward pass.

inverse_transform(self, x)

Revert data to original form.

list_class_types()

This method lists all types of available subclasses of calling one.

load(path)

Loads object from file.

load_state(self, path)

Sets the object state from file.

save(self, path)

Save class object to file.

save_state(self, path, **kwargs)

Store the object state to file.

set(self, param_name, param_value[, copy])

Set a parameter of the class.

set_params(self, params_dict[, copy])

Set all parameters passed as a dictionary {key: value}.

set_state(self, state_dict[, copy])

Sets the object state using input dictionary.

timed([msg])

Timer decorator.

transform(self, x)

Apply the transformation algorithm on data.

property components

Eigenvectors of inverse training array.

property eigenval

Eigenvalues estimated from the training data.

property eigenvec

Eigenvectors estimated from the training data.

property explained_variance

Variance explained by each of the selected components.

property explained_variance_ratio

Percentage of variance explained by each of the selected components.

If n_components is None, then all components are stored and the sum of explained variances is equal to 1.0

property mean

Per-feature empirical mean, estimated from the training data.