View Single Post
  #119 (permalink)  
Old 03-18-2008, 02:58 PM
barnix barnix is offline
Senior Member
 
Join Date: Mar 2006
Posts: 1,069
barnix is on a distinguished road
Source code:
311: Neural Networks
MT4:
Quote:
//+------------------------------------------------------------------+
//| PNN.mq4 |
//| Copyright © 2007, Klot. |
//| Ðåàëüíûé Ôîðåêñ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Klot."
#property link "http://www.fxreal.ru/"
#property library

//+------------------------------------------------------------------+
//| C - is the number of classes, N - is the number of examples, |
//| Nk - are from class k |
//| d - is the dimensionality of the training examples, |
//| sigma - is the smoothing factor |
//| test_example[d] - is the example to be classified |
//| Examples[N][d] - are the training examples |
//+------------------------------------------------------------------+
int PNN(int C, int N, int Nk, int d, double sigma, double test_example[d], double Examples[N][d])
{
int classify = -1;
double largest = 0;
double sum[];
ArrayResize(sum,C);
// The OUTPUT layer which computes the probability density function for each class C
for ( int k=0; k<C; k++ )
{
sum[ k ] = 0;
// The SUMMATION layer which accumulates the probability density function
// for each example from the particular class k
for ( int i=0; i<Nk; i++ )
{
double product = 0;
// The PATTERN layer that multiplies the test example by the weights
for ( int j=0; j<d; j++ ) product += test_example[j] * Examples[i][j];
//-----
product = (product-1)/(sigma*sigma);
product = MathExp(product);
sum[k] += product;
}
sum[k]/=Nk;
}
//----
for ( k=0; k<C; k++ )
if ( sum[ k ] > largest )
{
largest = sum[ k ];
classify = k;
}
//----
return (classify);
}
//+------------------------------------------------------------------+
Quote:
Originally Posted by Dimicr View Post
barnix, what is all this? Image recognition?
Please, if is possible add to posts source code.
Reply With Quote