public class Rbfn
extends java.lang.Object
implements java.lang.Cloneable
Class representing a Radial Basis Function Neural Network for the EvRBF_CL algorithm
Constructor and Description |
---|
Rbfn()
Creates a instance of rbnf of fixed structure just for test.
|
Rbfn(double[][] X,
int ndatos,
int nEnt,
int nSal,
int nNeuro)
Creates a new instance of rbfn from a matrix of instances.
|
Rbfn(int nNeuro,
double[][] X,
int ndatos,
int nEnt,
int nSal)
Creates a new instance of rbfn from a matrix of instances.
|
Rbfn(int nInputs,
int nOutputs)
Creates a new instance of rbfn
|
Modifier and Type | Method and Description |
---|---|
void |
classificationTest(double[][] X,
int ndatos,
int[] yieldedResults,
int max,
int min)
Evaluates the net for clasification problem
|
java.lang.Object |
clone()
Clones a RBFN neural network
|
java.lang.String |
closestRbf(double[] v)
Returns the nearest rbf/neuron to a vector v (pattern)
|
void |
decremental(double[][] X,
double[][] Y,
int ndatos,
double percent,
double alfa)
Uses a decremental algorithm to buid a net.
|
double[] |
errorRbfn(double[] desiredOutput,
double[] netOutput)
Computes the difference between the ouput of the net and desired output
|
double[] |
evalRbfn(double[] _input)
Passes an input to the net obtaining its output
|
double |
getFitness()
Gets the fitness of a RBF.
|
java.lang.String[] |
getIndexes()
Returns the list on index of the net neurons.
|
Rbf |
getRbf(java.lang.String id)
Gets an RBF from the net given its identifier
|
void |
insertRbf(Rbf rbf)
Adds a neuron to the net, assigning an automatic name
|
void |
insertRbf(Rbf rbf,
java.lang.String _key)
Adds a neuron to the net with a given name
|
void |
LMSTrain(double[][] X,
double[][] Y,
int ndatos,
int iter,
double alfa)
Uses LMS to train the net.
|
void |
modellingTest(double[][] X,
int ndatos,
double[] yieldedResults)
Evaluates the net for modeling problem
|
void |
modifyRbf(Rbf rbf,
java.lang.String idRbf)
Changes a neuron in the net
|
int |
numInputs()
To get the number of inputs
|
int |
numOutputs()
To get the number of outputs
|
void |
paint()
Prints net on a stdout
|
void |
paint(java.lang.String _fileName)
Prints net on a file.
|
void |
RAN(double[][] X,
double[][] Y,
int ndatos,
double delta,
double epsilon,
double alfa)
Uses RAN algorithm to build a net
|
int |
rbfSize()
Returns the number of neurons in the net
|
void |
removeRbf(java.lang.String idRbf)
Deletes a neuron from the net
|
void |
setFitness_Cl(double[][] _X,
double[][] _Y,
int _nDatos,
int _nClases)
Sets the fitness of a RBFN for classification problems
|
double |
setFitness(double _fitness)
Sets the fitness of a RBF.
|
public Rbfn()
Creates a instance of rbnf of fixed structure just for test.
public Rbfn(int nInputs, int nOutputs)
Creates a new instance of rbfn
nInputs
- Input dimensionnOutputs
- Ouput dimension (thus, number of ouput neurons)public Rbfn(double[][] X, int ndatos, int nEnt, int nSal, int nNeuro)
Creates a new instance of rbfn from a matrix of instances. Sets randomly the centres of the neurons and sets its radius taking intro account the maximun distance between centres.
X
- Matrix of instancesndatos
- Number of instaces in XnEnt
- Number of imputs of the netnSal
- Number of outputs of the netnNeuro
- Number of hidden neurons the net will have.public Rbfn(int nNeuro, double[][] X, int ndatos, int nEnt, int nSal)
Creates a new instance of rbfn from a matrix of instances. Sets randomly the centres of the neurons and sets its radius taking intro account the average distance between centres.
nNeuro
- Number of hidden neurons the net will have.X
- Matrix of instancesndatos
- Number of instaces in XnEnt
- Number of imputs of the netnSal
- Number of outputs of the netpublic java.lang.Object clone()
Clones a RBFN neural network
clone
in class java.lang.Object
public void removeRbf(java.lang.String idRbf)
Deletes a neuron from the net
idRbf
- Identifier of neuron to deletepublic void insertRbf(Rbf rbf)
Adds a neuron to the net, assigning an automatic name
rbf
- The neuron to insertpublic void insertRbf(Rbf rbf, java.lang.String _key)
Adds a neuron to the net with a given name
rbf
- The neuron to insert_key
- Its namepublic void modifyRbf(Rbf rbf, java.lang.String idRbf)
Changes a neuron in the net
idRbf
- Identifier of neuron to deleterbf
- Neuron to insertpublic int numInputs()
To get the number of inputs
public int numOutputs()
To get the number of outputs
public int rbfSize()
Returns the number of neurons in the net
public Rbf getRbf(java.lang.String id)
Gets an RBF from the net given its identifier
id
- RBF's identifierpublic java.lang.String[] getIndexes()
Returns the list on index of the net neurons.
public void setFitness_Cl(double[][] _X, double[][] _Y, int _nDatos, int _nClases)
Sets the fitness of a RBFN for classification problems
_X
- input dataset._Y
- output dataset._nDatos
- number of examples (_X length)._nClases
- number of classes (_Y length).public double setFitness(double _fitness)
Sets the fitness of a RBF.
_fitness
- The value to be used for the fitnesspublic double getFitness()
Gets the fitness of a RBF.
public double[] evalRbfn(double[] _input)
Passes an input to the net obtaining its output
_input
- The samplepublic double[] errorRbfn(double[] desiredOutput, double[] netOutput)
Computes the difference between the ouput of the net and desired output
desiredOutput
- Desired outputnetOutput
- Outpunt of the netpublic java.lang.String closestRbf(double[] v)
Returns the nearest rbf/neuron to a vector v (pattern)
v
- vectorpublic void RAN(double[][] X, double[][] Y, int ndatos, double delta, double epsilon, double alfa)
Uses RAN algorithm to build a net
X
- matrix of inputs instancesY
- matrix of outputs instancesndatos
- Number of instancesepsilon
- minimun error to introduce a new RBFdelta
- minimun distance to introduce a new RBFalfa
- learning factor when a new unit is not allocatedpublic void decremental(double[][] X, double[][] Y, int ndatos, double percent, double alfa)
Uses a decremental algorithm to buid a net. After initializing and training (with LMS) a net with several neurons, the algorithm in the major loop deletes the neurons with the lowest weight and train the net.
X
- matrix of inputs instancesY
- matrix of outputs instancesndatos
- Number of instancespercent
- Percent under the average of the weights to delete a neuronalfa
- Learnig factor of LMS algorithmpublic void LMSTrain(double[][] X, double[][] Y, int ndatos, int iter, double alfa)
Uses LMS to train the net.
X
- matrix of inputs instancesY
- matrix of outputs instancesndatos
- Number of instancesiter
- Number of times the set of samples will be used.alfa
- Learning factor.public void modellingTest(double[][] X, int ndatos, double[] yieldedResults)
Evaluates the net for modeling problem
X
- matrix of inputs instancesndatos
- Number of instancesyieldedResults
- Vector of results of the evaluationpublic void classificationTest(double[][] X, int ndatos, int[] yieldedResults, int max, int min)
Evaluates the net for clasification problem
X
- matrix of inputs instancesndatos
- Number of instancesyieldedResults
- Vector of results of the evaluationmax
- Class maximun identifiermin
- Class minimun identifierpublic void paint()
Prints net on a stdout
public void paint(java.lang.String _fileName)
Prints net on a file.
_fileName
- Name of the file.