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 hyperparameters.
get_state
(self)Returns the object state dictionary.
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 object from file.
load_state
(self, path)Sets the object state from file.
regularizer
(self, *args, **kwargs)Gets value of regularizer.
save
(self, path)Save class object to file.
save_state
(self, path)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.
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 is given by 1 - l1_ratio.
ElasticNet Regularizer is given by:
- 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 hyperparameters.
get_state
(self)Returns the object state dictionary.
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 object from file.
load_state
(self, path)Sets the object state from file.
regularizer
(self, w)Returns ElasticNet Regularizer.
save
(self, path)Save class object to file.
save_state
(self, path)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.
-
dregularizer
(self, w)[source]¶ Returns the derivative of the elastic-net regularizer
- Parameters
- wCArray
Vector-like array.
-
property
l1_ratio
¶ Get l1-ratio.
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:
- 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 hyperparameters.
get_state
(self)Returns the object state dictionary.
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 object from file.
load_state
(self, path)Sets the object state from file.
regularizer
(self, w)Returns Norm-L1.
save
(self, path)Save class object to file.
save_state
(self, path)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.
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:
- 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 hyperparameters.
get_state
(self)Returns the object state dictionary.
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 object from file.
load_state
(self, path)Sets the object state from file.
regularizer
(self, w)Returns Norm-L2.
save
(self, path)Save class object to file.
save_state
(self, path)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.