Modules#

gpr_algorithm.algorithm#

class gpr_algorithm.algorithm.GPR(feature_names: typing.List[str], target_names=None, n_populations=100, n_generations=100, eval_fun=<function default_eval_function>, threshold=0.5, verbose=True, max_n_of_rules=6, max_n_of_ands=6, base_pb=0.1)[source]#

Bases: object

fit(x: numpy.ndarray, y: numpy.ndarray)[source]#

Fit the GPR model according to the given training data.

Parameters
  • x – training vectors

  • y – target values

Returns

fitted model

predict(x: numpy.ndarray) numpy.ndarray[source]#

Method to predict the labels.

Parameters

x – unlabeled vectors to classify

Returns

class labels for samples in x

property ranking#

Counts the occurrences of each of the attributes and generates a ranking of these attributes.

Returns

a dictionary of the most important attributes sorted descending

property rules: List[str]#

Generates linguistic “if-then” metarules automatically.

Returns

list of metarules

class gpr_algorithm.algorithm.GPRAttributeSuffix(value)[source]#

Bases: str, enum.Enum

Linguistic terms of the antecedents of the generated metarules.

IS_HIGH = '_is_high'#
IS_LOW = '_is_low'#
IS_MEDIUM = '_is_medium'#
IS_VERY_HIGH = '_is_very_high'#
IS_VERY_LOW = '_is_very_low'#
class gpr_algorithm.algorithm.GPRChromosome(gene_gen, n_genes, linker=None)[source]#

Bases: geppy.core.entity.Chromosome

class gpr_algorithm.algorithm.GPRClass(value)[source]#

Bases: int, enum.Enum

An enumeration.

ELSE = 0#
THEN = 1#
class gpr_algorithm.algorithm.GPRFitness(values=())[source]#

Bases: deap.base.Fitness

weights = (1,)#

The weights are used in the fitness comparison. They are shared among all fitnesses of the same type. When subclassing Fitness, the weights must be defined as a tuple where each element is associated to an objective. A negative weight element corresponds to the minimization of the associated objective and positive weight to the maximization.

Note

If weights is not defined during subclassing, the following error will occur at instantiation of a subclass fitness object:

TypeError: Can't instantiate abstract <class Fitness[...]> with abstract attribute weights.

gpr_algorithm.algorithm.default_eval_function(y_true, y_pred)[source]#
gpr_algorithm.algorithm.wrap_crossover(fun)[source]#