Self learning probabilistic neural network (PNN) - page 2

 
MadCow wrote >>

Thanks for the excellent work. Perhaps you should write an article on this subject.

The PNN seems to be a special case of a nearest neighbor network in which the distance is measured using a Gaussian metric. This involves two math steps that are time consuming. (MathExp and MathPow). One can show that in the limit such nets converge to the Bayes classifier for the problem specified. However, one can also show that using a simple square distance measure (Multiply only), a nearest neighbor net will also converge. Convergence here is in the sense that the net will converge to the Bayes classifier as the number of examples approaches infinity. I do not know which net will converge most quickly, but perhaps the literature contains the answer. A net that converges more quickly than the simple Nearest neighbor uses the K nearest neighbors. (Here K must be chosen beforehand, and plays a part analogous to SIGMA in the PNN). My point is that by using a simpler metric, one may be able to speed calculations, and perhaps use fewer examples for training .(However, the other steps involved, moving pointers, accessing memory, etc. may swamp the metric calculations).

A second comment is that the success of these nets depends on the relative weights of the different dimensions of the input vector. In the example this is not a problem, but if the input consisted, e.g., of the RSI, Stoch and an EA or two, weighting each component becomes more problematical. Does anyone have a good solution to this problem, or is it adequate to simply normalize to mean 0, sigma 1...and just how do you do this on the fly? Maybe one could somehow use another learning algorithm to learn the appropriate weights?

I tried to build EA using k nearest neighbour (kNN) algorithms. I used the longest time series I could find to generate as many potential candidates for k nearest neighbours as possible. There are several problems with this approach, which lead to enormous number of computations if you try to resolve them, which, in turn, make kNN method unattractive. The problems are:

1. The first problem is choosing the input data. kNN is a pattern recognition tool. So, it should be used to recognize patterns in the price movement such as head & shoulders, triangles, pendants, W bottoms and M tops, breakouts, etc. If that is the case, then the input data should be the price series.

2. The second problem is how to choose the length of a pattern. For example, the current (reference) head-and-shoulders pattern may span over 100 bars, while the past H&S patterns may occupy 200 bars. If you choose 100 bars as the default pattern length, then kNN algorithm will try to match the most recent full head with two shoulders to the past half head with one shoulder patterns. The result will be poor. I tried to adaptively choose the pattern length on the fly. The result was slightly better, but still not good enough. In my example, imagine increasing the pattern length to 200 bars to fully include the head and shoulders of the past patterns. But, then the most recent H&S pattern will include other peaks and valleys, which do not belong to H&S.

After I realized these limitations of kNN, I came to the conclusion that the price series can not be used directly. The most obvious solution is to use a ZigZag to pre-process the price data to identify important turning points. I tried that too. I set the pattern length to be the number of turning points, say 7. The result was poor, with 50% accuracy. One of the problems with ZigZag is that, depending on its inputs, it may miss a pivot or generate an extra one in visually similar patterns. Mathematical comparison of these patterns will lead to errors because of their different lengths in pivots.

One can also choose different indicators of different periods to describe a pattern: RSI, Stochastics etc. The problem will still be the same: using preset periods for these indicators will make it difficulat to match visually similar patterns of different lengths. As an example, consider the problem of identification of a breakout of a resistance level. The obvious choice here is to use the iHighest to identify the last bar as the highest bar over the past N bars. These past N bars should include at least two peaks of the same height to establish the resistance line. The distance of these peaks to the last bar can vary for different breakout patterns. So, presetting N to some number may lead to either too early or too late entries.

Overall, I got dissapointed with kNN and temporarily abandoned it until a new idea comes along. It seems that the only way to use it properly is to fit a continous curve to the price series, take the most recent chuck of this curve and match it to the past chunks, while adaptivly squeezing and stretching them in x and y i.e. warping the xy coordinates in a linear or nonlinear fashion. This is way too complex. At the end of the day, you ask yourself a question: what if patterns are just our imagination? If the eye wants to see a trading channel, it surely will. May be it is our brain that constantly seeks an explanation to a price movement. If the price moves out of the trading range, we immediately find a reason for that: aha! 50-bar SMA moved above 200-bar, or the descending trangle was broken, or two stochastics crossed, or something else. But, all these are just signs of something that already happened. One can not guarantee that the same set of circumstances in the future will leads to the same price movement as in the past.

 
Some neural network patern recognition solutions can be found here www.nnea.net (NNEA - Neural Network Expert Advisors)
 
gpwr:

I tried to build EA using k nearest neighbour (kNN) algorithms. I used the longest time series I could find to generate as many potential candidates for k nearest neighbours as possible. There are several problems with this approach, which lead to enormous number of computations if you try to resolve them, which, in turn, make kNN method unattractive. The problems are:

1. The first problem is choosing the input data. kNN is a pattern recognition tool. So, it should be used to recognize patterns in the price movement such as head & shoulders, triangles, pendants, W bottoms and M tops, breakouts, etc. If that is the case, then the input data should be the price series.

2. The second problem is how to choose the length of a pattern. For example, the current (reference) head-and-shoulders pattern may span over 100 bars, while the past H&S patterns may occupy 200 bars. If you choose 100 bars as the default pattern length, then kNN algorithm will try to match the most recent full head with two shoulders to the past half head with one shoulder patterns. The result will be poor. I tried to adaptively choose the pattern length on the fly. The result was slightly better, but still not good enough. In my example, imagine increasing the pattern length to 200 bars to fully include the head and shoulders of the past patterns. But, then the most recent H&S pattern will include other peaks and valleys, which do not belong to H&S.

After I realized these limitations of kNN, I came to the conclusion that the price series can not be used directly. The most obvious solution is to use a ZigZag to pre-process the price data to identify important turning points. I tried that too. I set the pattern length to be the number of turning points, say 7. The result was poor, with 50% accuracy. One of the problems with ZigZag is that, depending on its inputs, it may miss a pivot or generate an extra one in visually similar patterns. Mathematical comparison of these patterns will lead to errors because of their different lengths in pivots.

One can also choose different indicators of different periods to describe a pattern: RSI, Stochastics etc. The problem will still be the same: using preset periods for these indicators will make it difficulat to match visually similar patterns of different lengths. As an example, consider the problem of identification of a breakout of a resistance level. The obvious choice here is to use the iHighest to identify the last bar as the highest bar over the past N bars. These past N bars should include at least two peaks of the same height to establish the resistance line. The distance of these peaks to the last bar can vary for different breakout patterns. So, presetting N to some number may lead to either too early or too late entries.

Overall, I got dissapointed with kNN and temporarily abandoned it until a new idea comes along. It seems that the only way to use it properly is to fit a continous curve to the price series, take the most recent chuck of this curve and match it to the past chunks, while adaptivly squeezing and stretching them in x and y i.e. warping the xy coordinates in a linear or nonlinear fashion. This is way too complex. At the end of the day, you ask yourself a question: what if patterns are just our imagination? If the eye wants to see a trading channel, it surely will. May be it is our brain that constantly seeks an explanation to a price movement. If the price moves out of the trading range, we immediately find a reason for that: aha! 50-bar SMA moved above 200-bar, or the descending trangle was broken, or two stochastics crossed, or something else. But, all these are just signs of something that already happened. One can not guarantee that the same set of circumstances in the future will leads to the same price movement as in the past.

kNN is definitely resource intensive if all the patterns are to be recognizable. However, I have my reservations on patterns like 'head & shoulders, double top, wedges etc". These patterns are recognized differently even by human beings and they are hard to be described objectively. As such, expecting neural networks to detect them may not be a good idea as the neural network may come up with detections that no human being may agree or agree differently. Furthermore, these patterns have poor predictability in forex other than with hindsight. Objective parameters should be used or else the network is not going to be any better than perceptron based networks.

I usually rely on MA crosses if pattern recognition is required. For example, let's say we have 4 consecutive MA crosses, I'll take the highest high between cross 1 and cross 2, the lowest low between cross 2 and cross 3 and again the highest high between cross 3 and cross 4. These may constitute double tops with the MAs making clear definitions and would be gentler on the neural processor.

 

Hi,


I am a very beginner in the programming field. It happens that i have a trading strategy that might work well if i have a hybrid EA including NN. However,i couldnot afford time or effort to start learning everything about advanced programming, genetic algorithms or Neural networks. I surfed to find out if there is a software can enable me to build an EA without the need of advanced programming knowledge.Actually, if this will work, i could design, my what i call it, prototype EA. If this prototype EA shows promising results, i might go further to professionally produce it. For example, by hiring a professional programmer or contacting a reputable programming company.


Now, i found Neuroshell software could satisfy me with my need in this area of designing and building an EA without much programming knowlege.

My wondering, if you know guys any of their compititors that i could look at and make a fair comparison based on my needs and what they offer so i could decide which one i will go for??


Thanks for you patience and time


Hope to hear from you soon.

Email: McGene2010@yahoo.com


 

Hi,


I am a very beginner in the programming field. It happens that i have a trading strategy that might work well if i have a hybrid EA including NN. However,i couldnot afford time or effort to start learning everything about advanced programming, genetic algorithms or Neural networks. I surfed to find out if there is a software can enable me to build an EA without the need of advanced programming knowledge.Actually, if this will work, i could design, my what i call it, prototype EA. If this prototype EA shows promising results, i might go further to professionally produce it. For example, by hiring a professional programmer or contacting a reputable programming company.


Now, i found Neuroshell software could satisfy me with my need in this area of designing and building an EA without much programming knowlege.

My wondering, if you know guys any of their compititors that i could look at and make a fair comparison based on my needs and what they offer so i could decide which one i will go for??


Thanks for you patience and time


Hope to hear from you soon.

Email: McGene2010@yahoo.com


 
Dhananjay:

kNN is definitely resource intensive if all the patterns are to be recognizable. However, I have my reservations on patterns like 'head & shoulders, double top, wedges etc". These patterns are recognized differently even by human beings and they are hard to be described objectively. As such, expecting neural networks to detect them may not be a good idea as the neural network may come up with detections that no human being may agree or agree differently. Furthermore, these patterns have poor predictability in forex other than with hindsight. Objective parameters should be used or else the network is not going to be any better than perceptron based networks.

I usually rely on MA crosses if pattern recognition is required. For example, let's say we have 4 consecutive MA crosses, I'll take the highest high between cross 1 and cross 2, the lowest low between cross 2 and cross 3 and again the highest high between cross 3 and cross 4. These may constitute double tops with the MAs making clear definitions and would be gentler on the neural processor.

Dhananjay,

Is there any other technique i can use to net in order to detect patterns of tech analysis?

 

Look at this:

http://www.forexfactory.com/showthread.php?t=217486

There is a prototype and some ideas to experiment with. Some patterns seemed to give interesting results, might be worth more investigation. Project officially halted due to lack of time, feel free to fork it. The principle is quite simple.

Reason: