secml.ml.classifiers.regularizer

CRegularizer

class secml.ml.classifiers.regularizer.c_regularizer.CRegularizer[source]

Bases: secml.core.c_creator.CCreator

Abstract class that defines basic methods for regularizer functions.

Attributes
class_type

Defines class type.

logger

Logger for current object.

verbose

Verbosity level of logger output.

Methods

copy(self)

Returns a shallow copy of current class.

create([class_item])

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

deepcopy(self)

Returns a deep copy of current class.

dregularizer(self, \*args, \*\*kwargs)

Gets the derivative of regularizer.

get_class_from_type(class_type)

Return the class associated with input type.

get_params(self)

Returns the dictionary of class parameters.

get_subclasses()

Get all the subclasses of the calling class.

list_class_types()

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

load(path)

Loads class from pickle object.

regularizer(self, \*args, \*\*kwargs)

Gets value of regularizer.

save(self, path)

Save class object using pickle.

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

Set a parameter that has a specific name to a specific value.

set_params(self, params_dict[, copy])

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

timed([msg])

Timer decorator.

dregularizer(self, *args, **kwargs)[source]

Gets the derivative of regularizer.

abstract regularizer(self, *args, **kwargs)[source]

Gets value of regularizer.

CRegularizerElasticNet

class secml.ml.classifiers.regularizer.c_regularizer_elastic_net.CRegularizerElasticNet(l1_ratio=0.15)[source]

Bases: secml.ml.classifiers.regularizer.c_regularizer.CRegularizer

ElasticNet Regularizer.

A convex combination of L2 and L1, where \rho is given by 1 - l1_ratio.

ElasticNet Regularizer is given by:

R(w) := \frac{\rho}{2} \sum_{i=1}^{n} w_i^2 + (1-\rho)
                         \sum_{i=1}^{n} |w_i|

Attributes
class_type‘elastic-net’

Defines class type.

Methods

copy(self)

Returns a shallow copy of current class.

create([class_item])

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

deepcopy(self)

Returns a deep copy of current class.

dregularizer(self, w)

Returns the derivative of the elastic-net regularizer

get_class_from_type(class_type)

Return the class associated with input type.

get_params(self)

Returns the dictionary of class parameters.

get_subclasses()

Get all the subclasses of the calling class.

list_class_types()

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

load(path)

Loads class from pickle object.

regularizer(self, w)

Returns ElasticNet Regularizer.

save(self, path)

Save class object using pickle.

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

Set a parameter that has a specific name to a specific value.

set_params(self, params_dict[, copy])

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

timed([msg])

Timer decorator.

dregularizer(self, w)[source]

Returns the derivative of the elastic-net regularizer

Parameters
wCArray

Vector-like array.

property l1_ratio

Get l1-ratio.

regularizer(self, w)[source]

Returns ElasticNet Regularizer.

Parameters
wCArray

Vector-like array.

CRegularizerL1

class secml.ml.classifiers.regularizer.c_regularizer_l1.CRegularizerL1[source]

Bases: secml.ml.classifiers.regularizer.c_regularizer.CRegularizer

Norm-L1 Regularizer.

This function leads to sparse solutions.

L1 Regularizer is given by:

R(w) := \sum_{i=1}^{n} |w_i|

Attributes
class_type‘l1’

Defines class type.

Methods

copy(self)

Returns a shallow copy of current class.

create([class_item])

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

deepcopy(self)

Returns a deep copy of current class.

dregularizer(self, w)

Returns Norm-L1 derivative.

get_class_from_type(class_type)

Return the class associated with input type.

get_params(self)

Returns the dictionary of class parameters.

get_subclasses()

Get all the subclasses of the calling class.

list_class_types()

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

load(path)

Loads class from pickle object.

regularizer(self, w)

Returns Norm-L1.

save(self, path)

Save class object using pickle.

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

Set a parameter that has a specific name to a specific value.

set_params(self, params_dict[, copy])

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

timed([msg])

Timer decorator.

dregularizer(self, w)[source]

Returns Norm-L1 derivative.

Parameters
wCArray

Vector-like array.

regularizer(self, w)[source]

Returns Norm-L1.

Parameters
wCArray

Vector-like array.

CRegularizerL2

class secml.ml.classifiers.regularizer.c_regularizer_l2.CRegularizerL2[source]

Bases: secml.ml.classifiers.regularizer.c_regularizer.CRegularizer

Norm-L2 Regularizer.

L2 Regularizer is given by:

R(w) := \frac {1}{2} \sum_{i=1}^{n} w_i^2

Attributes
class_type‘l2’

Defines class type.

Methods

copy(self)

Returns a shallow copy of current class.

create([class_item])

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

deepcopy(self)

Returns a deep copy of current class.

dregularizer(self, w)

Return Norm-L2 derivative.

get_class_from_type(class_type)

Return the class associated with input type.

get_params(self)

Returns the dictionary of class parameters.

get_subclasses()

Get all the subclasses of the calling class.

list_class_types()

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

load(path)

Loads class from pickle object.

regularizer(self, w)

Returns Norm-L2.

save(self, path)

Save class object using pickle.

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

Set a parameter that has a specific name to a specific value.

set_params(self, params_dict[, copy])

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

timed([msg])

Timer decorator.

dregularizer(self, w)[source]

Return Norm-L2 derivative.

Parameters
wCArray

Vector-like array.

regularizer(self, w)[source]

Returns Norm-L2.

Parameters
wCArray

Vector-like array.