public class Rbfn
extends java.lang.Object
This class codified a Radial Basis Function Network
Constructor and Description |
---|
Rbfn()
Creates a instance of rbnf of fixed structure just for test.
|
Rbfn(double[][] X,
int ndata,
int nInpt,
int nOutp,
int nNeuro)
Creates a new instance of rbfn from a matrix of instances.
|
Rbfn(int nNeuro,
double[][] X,
int ndata,
int nInpt,
int nOutpl)
Creates a new instance of rbfn from a matrix of instances.
|
Rbfn(int numInpt,
int numOutp)
Creates a new instance of rbfn
|
Modifier and Type | Method and Description |
---|---|
void |
decremental(double[][] X,
double[][] Y,
int ndata,
double percent,
double alfa)
Uses a decremental algorithm to buid a net.
|
double[] |
errorRbfn(double[] realOutput,
double[] netOutput)
Computes the difference between the ouput of the net and desired outpunt
|
protected double |
euclideanDist(double[] v1,
double[] v2)
Computes the euclidean distance between 2 vectors
|
double[] |
evaluationRbfn(double[] _input)
Passes an input to the net obtaining its output
|
java.lang.String[] |
getIndex()
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
|
void |
modifyRbf(Rbf rbf,
java.lang.String idRbf)
Changes a neuron in the net
|
void |
printRbfn()
Prints net on a stdout
|
void |
printRbfn(java.lang.String _fileName)
Prints net on a file.
|
void |
RAN(double[][] X,
double[][] Y,
int ndata,
double delta,
double epsilon,
double alfa)
Uses RAN algorithm to build a net
|
java.lang.String |
rbfNearest(double[] v)
Returns the nearest rbf/neuron to a vector v (patron)
|
void |
removeRbf(java.lang.String idRbf)
Deletes a neuron of the net
|
int |
size()
Returns the number of neurons in the net
|
void |
testClasification(double[][] X,
int ndata,
int[] obtained,
int max,
int min)
Evaluates the net for clasification problem
|
void |
testModeling(double[][] X,
int ndata,
double[] obtained)
Evaluates the net for modeling problem
|
void |
trainLMS(double[][] X,
double[][] Y,
int ndata,
int iter,
double alfa)
Uses LMS to train the net.
|
public Rbfn()
Creates a instance of rbnf of fixed structure just for test.
public Rbfn(int numInpt, int numOutp)
Creates a new instance of rbfn
numInpt
- Input dimensionnumOutp
- Ouput dimension (thus, number of ouput neurons)public Rbfn(double[][] X, int ndata, int nInpt, int nOutp, 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 instancesndata
- Number of instaces in XnInpt
- Number of imputs of the netnOutp
- Number of outputs of the netnNeuro
- Number of hidden neurons the net will have.public Rbfn(int nNeuro, double[][] X, int ndata, int nInpt, int nOutpl)
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 instancesndata
- Number of instaces in XnInpt
- Number of imputs of the netnOutpl
- Number of outputs of the netprotected double euclideanDist(double[] v1, double[] v2)
Computes the euclidean distance between 2 vectors
v1
- A vectorv2
- A vectorpublic void removeRbf(java.lang.String idRbf)
Deletes a neuron of the net
idRbf
- Identifier of neuron to deletepublic void insertRbf(Rbf rbf)
Adds a neuron to the net
rbf
- The neuron to insertpublic void modifyRbf(Rbf rbf, java.lang.String idRbf)
Changes a neuron in the net
idRbf
- Identifier of neuron to deleterbf
- Neuron to insertpublic int size()
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[] getIndex()
Returns the list on index of the net neurons.
public double[] evaluationRbfn(double[] _input)
Passes an input to the net obtaining its output
_input
- The samplepublic double[] errorRbfn(double[] realOutput, double[] netOutput)
Computes the difference between the ouput of the net and desired outpunt
realOutput
- Desired outputnetOutput
- Outpunt of the netpublic java.lang.String rbfNearest(double[] v)
Returns the nearest rbf/neuron to a vector v (patron)
v
- vectorpublic void RAN(double[][] X, double[][] Y, int ndata, double delta, double epsilon, double alfa)
Uses RAN algorithm to build a net
X
- matrix of inputs instancesY
- matrix of outputs instancesndata
- 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 ndata, 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 instancesndata
- Number of instancespercent
- Percent under the average of the weights to delete a neuronalfa
- Learnig factor of LMS algorithmpublic void trainLMS(double[][] X, double[][] Y, int ndata, int iter, double alfa)
Uses LMS to train the net.
X
- matrix of inputs instancesY
- matrix of outputs instancesndata
- Number of instancesiter
- Number of times the set of samples will be used.alfa
- Learning factor.public void testModeling(double[][] X, int ndata, double[] obtained)
Evaluates the net for modeling problem
X
- matrix of inputs instancesndata
- Number of instancesobtained
- Vector of results of the evaluationpublic void testClasification(double[][] X, int ndata, int[] obtained, int max, int min)
Evaluates the net for clasification problem
X
- matrix of inputs instancesndata
- Number of instancesobtained
- Vector of results of the evaluationmax
- Class maximun identifiermin
- Class minimun identifierpublic void printRbfn()
Prints net on a stdout
public void printRbfn(java.lang.String _fileName)
Prints net on a file.
_fileName
- Name of the file.