ANNGA: Optimize an ANN by GA

Description Usage Arguments Note Author(s) Examples

Description

This function uses a feedforward Artificial Neural Network optimized by Genetic Algorithm to minimize the mean squared error.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
ANNGA	(	x,
		y,
		design = c(1, 3, 1),
		population = 500,
		mutation = 0.3,
		crossover = 0.7,
		maxW = 25,
		minW = -25,
		maxGen = 1000,
		error = 0.001,
		threads=1,
		printBestChromosone=TRUE,
		...)

Arguments

x

A matrix of inputs, where each column is a different input. Value must be in the range [0,1].

y

A matrix of outputs, where each column is a different output. Value must be in the range [0,1].

design

A vector for the configuration of the network: the first number will be the number of inputs, the last number will be the number of outputs and the numbers in between are the numbers of neurons on each hidden layer.

Example 1:design = c(1, 3, 1) one input, one hidden layer with three neurons and one neuron in the output layer.

Example 2: design = c(5, 3, 2, 1) five inputs, two hidden layers, the first one with three neurons, the second one with two neurons and one neuron in the output layer.

population

The number of chromosomes in the population of each generation.

mutation

The mutation rate: should be between 0 and 1.

crossover

The crossover rate: must be between 0 and 1.

maxW

The maximum weight allowed by the random generator on the initialisation of the weight. During the mutation, weight can excede this boundry.

minW

The minimum weight allowed by the random generator on the initialisation of the weight. During the mutation, weight can excede this boundry.

maxGen

The maximum generation allowed if the error criterion is not reached.

error

Error criterion to be reached. Desired mean squared error.

printBestChromosone

For a better understanding, this option prints the weight of the best chromosome for each generation.

threads

Number of threads to be used, if the number is greater than your CPU number of threads, then your number will be set to your CPU number of threads.

...

Note

Once an object of class "ANN" has been created, you can print() and plot() to visualise information about that object.

Author(s)

Francis Roy-Desrosiesrs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#use the command demo(ANN) to see how dataANN was created 
data("dataANN")

#Example
                ANNGA(x    =input,
                y       =output,
                design  =c(1, 3, 1),
                population  =100,
                mutation = 0.3,
                crossover = 0.7,
                maxGen  =1000,
                error   =0.001,
                threads=2)


#More examples 
demo(ANN)

ANN documentation built on May 2, 2019, 4:51 p.m.