Log in

Support Vector Machine Prediction model of CCI in Rapid Miner

Here I would like to add an image of an Support Vector Machine Prediction model of CCI in Rapid Miner. This is a basic model without testing what ever. I exported the CCI data with the expert. In fact this is a common CCI with 14 period.
Then I used an operator fit trend in order to fit the general trend of the CCI. This was just an experiment, normally this is used for fitting the trend of the price series. However in this case I did it for an oscillator. The fit trend operator was using a Support Vector Machine with radial kernel. Then I transfer the data to the next operator which is Predict Series. Here I use the same Support Vector Machine model however I am trying to predict the trend of the CCI.  The result was quite funny indeed.

 

image
От 22 септември 2011

Comments

  • JohnLast 2852 days ago
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.1.004">
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="5.1.004" expanded="true" name="Process">
    <process expanded="true" height="341" width="815">
    <operator activated="true" class="read_csv" compatibility="5.1.004" expanded="true" height="60" name="Read CSV" width="90" x="45" y="30">
    <parameter key="csv_file" value="C:\Users\theodor\Desktop\EURUSD60.csv"/>
    <parameter key="first_row_as_names" value="false"/>
    <list key="annotations">
    <parameter key="0" value="Name"/>
    </list>
    <list key="data_set_meta_data_information">
    <parameter key="0" value="Date.true.integer.attribute"/>
    <parameter key="1" value="Time.true.integer.attribute"/>
    <parameter key="2" value="Open.true.real.attribute"/>
    <parameter key="3" value="High.true.real.attribute"/>
    <parameter key="4" value="Low.true.real.attribute"/>
    <parameter key="5" value="Close.true.real.attribute"/>
    <parameter key="6" value="Volume.true.integer.attribute"/>
    <parameter key="7" value="AllAverages.true.real.attribute"/>
    <parameter key="8" value="CCI.true.real.attribute"/>
    <parameter key="9" value="IVAR.true.real.attribute"/>
    </list>
    </operator>
    <operator activated="true" class="set_role" compatibility="5.1.004" expanded="true" height="76" name="Set Role (2)" width="90" x="179" y="30">
    <parameter key="name" value="CCI"/>
    <parameter key="target_role" value="label"/>
    <list key="set_additional_roles"/>
    </operator>
    <operator activated="true" class="series:fit_trend" compatibility="5.0.002" expanded="true" height="60" name="Fit Trend" width="90" x="313" y="30">
    <parameter key="attribute" value="CCI"/>
    <process expanded="true" height="414" width="627">
    <operator activated="true" class="support_vector_machine" compatibility="5.1.004" expanded="true" height="112" name="SVM" width="90" x="257" y="81">
    <parameter key="kernel_type" value="radial"/>
    </operator>
    <connect from_port="example set" to_op="SVM" to_port="training set"/>
    <connect from_op="SVM" from_port="model" to_port="model"/>
    <portSpacing port="source_example set" spacing="36"/>
    <portSpacing port="sink_model" spacing="0"/>
    </process>
    </operator>
    <operator activated="true" class="set_role" compatibility="5.1.004" expanded="true" height="76" name="Set Role" width="90" x="447" y="30">
    <parameter key="name" value="CCI"/>
    <parameter key="target_role" value="label"/>
    <list key="set_additional_roles"/>
    </operator>
    <operator activated="true" class="series:predict_series" compatibility="5.0.002" expanded="true" height="60" name="Predict Series" width="90" x="581" y="30">
    <process expanded="true" height="414" width="627">
    <operator activated="true" class="support_vector_machine" compatibility="5.1.004" expanded="true" height="112" name="SVM (2)" width="90" x="246" y="120">
    <parameter key="kernel_type" value="radial"/>
    </operator>
    <connect from_port="window example set" to_op="SVM (2)" to_port="training set"/>
    <connect from_op="SVM (2)" from_port="model" to_port="prediction model"/>
    <portSpacing port="source_window example set" spacing="0"/>
    <portSpacing port="sink_prediction model" spacing="0"/>
    </process>
    </operator>
    <connect from_op="Read CSV" from_port="output" to_op="Set Role (2)" to_port="example set input"/>
    <connect from_op="Set Role (2)" from_port="example set output" to_op="Fit Trend" to_port="example set"/>
    <connect from_op="Fit Trend" from_port="example set with trend" to_op="Set Role" to_port="example set input"/>
    <connect from_op="Set Role" from_port="example set output" to_op="Predict Series" to_port="example set"/>
    <connect from_op="Predict Series" from_port="example set" to_port="result 1"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>
    </process>
    </operator>
    </process>
  • JohnLast 2852 days ago

    You can just copy paste this code in the cetral process window of Rapid Miner and you will have the model. You need to go to the XML Tab and paste the code there. After it is neede to press the green check box, this is to apply the code. This is at the upper left corner of the XML window.

  • Krzysztof 2851 days ago

    I understand that you used SVM for regression. How did you set/found kernel parameter values because this is a key in case of SVM.

    Anyway I dont think you will get something usefull from this

     

  • JohnLast 2851 days ago

    This was just an example. I wanted to fit trend not to moving average but to a momentum. This is crazy I know I did by mistake however I found the results interesting so I posted. Then I wanted to predict the fitted momentum trend.

    Yes, I know it is important to optimize the parameters. Here I did nothing of the kind. It is just a naked model. I used a radial basis SVM with default parameters. I did not even included a cross validation operator in order to know how good is it. So I do not know how good the fit is LOL.

    Now I will give you a  link.  of a Rapid Miner Tutorial. 

    Here there is a video here you can find how to use a special operator for optimization of parameters. You can choose what exactly you want to optimize. However maybe you would need to watch the other video Tutorials because this software is completely counter intuitive.  

    Sometimes there are bugs of some versions. The current version of Rapidminer gave some bugs but here it should be OK.

  • goldensun7 2851 days ago

    Got the idea / Thanks for the post

  • Krzysztof 2851 days ago

    Yes I know about RapidMiner. It is kind of visual GUI for Weka which I think is leading tool in this area.

    If you can somehow export trained model of the net to MT4 and use it in real time than it is great, I'm doing this using Weka and Matlab

    I believe you have to be very carefull with those tools, they are not designed for time series analysis but for data mining so e.g. cross validation makes randomisation of data what is useless for time series.

    Special tool for time series analysis is called MOA and it is plugin to Weka

     

     

  • JohnLast 2851 days ago

    I will pay close attention to MOA. Meanwhile I want to do something very simple. This is more complex.

    However I know an indicator Neuro trend that was created to be trained for Stuttgart Neural Network Software. I was able to extract training set from Metatrader (there is a script available),then to train this with the java  variant of SNNS (a lot of neural net types are available and training algorythms too ). And then to use the mode directly in Metatrader. We were ablo to unlock it because it was limitted only to 15 m. time frame. It is also possible to change the architecture and or change the icustom files and use whatever you want. I do not know why I just forgot about that project. I had some results but the files were never published.

     

    I forgot the SNNS because the first thing was that according what I learned Support Vector Machines models are more robusts than Neural Nets.

    It may look like a joke but I made an experiment with Neuroshell (normally peopleare trying to experiement with many different architectures there and inputs and rules etc.) I used the exact same model trained exaclty the same way, on exactly the same data. I put 4 models on the same screen, some of them are slightly profitable some of them are not, some are disasters. So basically the results were based on luck because you never know where you are going to go in a local optimum.

     

    So as it was written in the litterature it is important to use something to simplify the data. SSA, ICA, PCA, Wavelets, Filters etc. And then to use a robust learner. Now I am thinking about the Elliotware approach and to try to use the learner on specific data: for example established trend from beginning of september (and to exlude in the model the range of late august). The next thing was to input in the model also the change in the orders levels (under some tests it increased the profitablilty because the market orders exerce an attraction force they are the true chaotic attractors).   

     

  • Krzysztof 2850 days ago

    if you are interested in using of NN for forex boys are playing with it since long time and claiming some positive results

    http://www.trade2win.com/boards/metatrader/85780-build-neural-network-indicator-mt4-using-neuroshell-77.html

    I initially concentrated on SVM and 3rg generation nets simply because traidng system was ready made by Columbia university

    http://www.trade2win.com/boards/metatrader/105880-3rd-generation-nn-deep-learning-deep-belief-nets-restricted-boltzmann-machines-13.html

    Anyway conclusion from my investigations is that all approaches described on different forums are very oversimplified, problem is much more complicated than majority of forum people can even imagine and sometimes they are fooled either by luck or bugs or not proper testing of their strategie...And story continues and continues....

     

     

     

  • JohnLast 2849 days ago

    Thank you for sharing.

    Unfortunately the link explaining TradeFX does not work.

    I am thinking that time series matters. And the model is sensitive on where you would start training and testing and how much the same market conditions would continue. Those tools are wonderfull but they would work only if they are trained to find the right solution for the right problem. And the problem in the FX market changes.

    For example the market action of late august on Eur/Usd and the beginning of September. If you train on the range of late august and you expect it to work after the major break - out and down trend of september my hypothesis is that the deepest network in the world will not help much.

     

     

     

  • Krzysztof 2849 days ago

    Here I reposted original code of TradeFX

    http://www.trade2win.com/boards/metatrader/85780-build-neural-network-indicator-mt4-using-neuroshell-82.html

    Yes, you are right that it will only work when the current pattern is included in the training set. Solution is e.g to increase training set and make for example resampling. It helps

  • JohnLast 2849 days ago

    Thanks, I will check that.