culebra.fitness_function.svc_optimization.C class

class C

Minimization of the C hyperparameter of RBF SVCs.

Class attributes

class culebra.fitness_function.svc_optimization.C.Fitness

Handles the values returned by the evaluate() method within a Solution.

Fitness.weights = (-1.0,)

Minimize C.

Fitness.names = ('C',)

Name of the objective.

Fitness.thresholds = [0]

Similarity threshold for fitness comparisons.

Class methods

classmethod C.load_pickle(filename: str) Base

Load a pickled object from a file.

Parameters:

filename (str) – The file name.

Raises:
classmethod C.set_fitness_thresholds(thresholds: float | Sequence[float]) None

Set new fitness thresholds.

Modifies the thresholds of the Fitness objects generated by this fitness function.

Parameters:

thresholds (float or Sequence of float) – The new thresholds. If only a single value is provided, the same threshold will be used for all the objectives. Different thresholds can be provided in a Sequence

Raises:
classmethod C.get_fitness_objective_threshold(obj_name: str) None

Get the similarity threshold for the given objective.

Parameters:

obj_name (str) – Objective name whose threshold is returned

Raises:
  • TypeError – If obj_name isn’t a string

  • ValueError – If value isn’t a valid objective name

classmethod C.set_fitness_objective_threshold(obj_name: str, value: float) None

Set a similarity threshold for the given fitness objective.

Parameters:
  • obj_name (str) – Objective name whose threshold is modified

  • value (float) – New value for the similarity threshold.

Raises:
  • TypeError – If obj_name isn’t a string or value isn’t a real number

  • ValueError – If obj_name isn’t a valid objective name or value is lower than 0

Properties

property C.is_noisy: int

Return True if the fitness function is noisy.

property C.num_obj: int

Get the number of objectives.

Type:

int

property C.num_nodes: int | None

Return the problem graph’s number of nodes for ACO-based trainers.

Subclasses solvable with ACO-based approaches should override this property to return the problem graph’s number of nodes. Otherwise, None is returned

Returns:

The problem graph’s number of nodes if an ACO-based approach is applicable or None otherwise

Return type:

int

Methods

C.save_pickle(filename: str) None

Pickle this object and save it to a file.

Parameters:

filename (str) – The file name.

Raises:
C.heuristic(species: Species) Sequence[ndarray, ...] | None

Get the heuristic matrices for ACO-based trainers.

Subclasses solvable with ACO-based approaches should override this method. Otherwise, None is returned

Parameters:

species (Species) – Species constraining the problem solutions

Returns:

A sequence of heuristic matrices if an ACO-based approach is applicable or None otherwise

Return type:

Sequence of ndarray

C.evaluate(sol: Solution, index: int | None = None, representatives: Sequence[Solution] | None = None) Tuple[float, ...]

Evaluate a solution.

Parameters:
  • sol (Solution) – Solution to be evaluated.

  • index (int, ignored) – Index where sol should be inserted in the representatives sequence to form a complete solution for the problem. Only used by cooperative problems

  • representatives (Sequence of Solution, ignored) – Representative solutions of each species being optimized. Only used by cooperative problems

Returns:

The fitness of sol

Return type:

tuple of float