Click here to Skip to main content
15,886,963 members
Articles / Programming Languages / VC++
Tip/Trick

GMDH Algorithm Implementation

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
15 Jun 2015CPOL1 min read 12.4K   156   2   4
Implementation of GMDH algorithm, using a sigmoid function. C++, VS, AlgLib-based

Introduction

Pretty straight: this is GMDH implementation in C++ (VS), based on AlgLib. Usage example (test) has been included. The only fully implemented and tested polynom is a sigmoid function. Not the "sensational" Kolmogorov-Gabor polynomial.

This is not my code, but code-writers are OK if I publish it, so here it is. Enjoy!

Background

The whole thing is about Stock Exchange and High Frequency Trading (HFT) (see wiki). GMDH is an algorithm useful for short, fast forecasts. As when "model" gets trained, you have formulae, and get immediate results feeding the input samples! But training itself goes for a long time, so model can't be rebuilt too often.

In my diploma work, I have ~55-60% of succeeded forecasts. Input data is pre-processed (somehow), and GMDH model trained on it. Then forecast goes. Output data should also be filtered, as there are ejections (values too much far from trend).

Maybe, I will publish my diploma work later, but yet I don't want, as it can't pretend to be a "real" scientific work, but it can potentially be proof of concept.

Using the Code

You can see usage example in TestAlgLib project in TestAlgLib.cpp file.

1. Push Training Data

C++
CDataContainer dc; // Container to store sets of input/output values
AIDoubleVector vVals; // Buffer variable to store input values (before they go into container)

vVals.push_back(1.0);
vVals.push_back(1.0);
vVals.push_back(2.0);
dc.Init(vVals.size());
dc.AddSet(vVals, 13.0); // ("inputs", "output")
// ... and more data ...

2. Train Model

C++
CAIGMDHAlgorithm Algorithm;
CModel model; // Resulting model
Algorithm.Init(2); // Every second set will be for learning

// dc - Container of input/output values
// 20 - MinDeviation
// ePolynomSFunction - Polynomial function. 
//     Must be always S function - others are untested and unimplemented.
// model - [out] Resulting model
Algorithm.Train(dc, model, 20, ePolynomSFunction); // We'll have model on output

3. Test (use) Model

C++
vVals.clear();
vVals.push_back(7);
vVals.push_back(5);
vVals.push_back(2);
PrintResult(vVals, model.GetResult(vVals)); // model.GetResult(*) gives a single value

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Ukraine Ukraine
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionWhere is the source code? Pin
Jamming117-Jun-15 2:58
Jamming117-Jun-15 2:58 
AnswerRe: Where is the source code? Pin
Sa Sha18-Jun-15 22:08
Sa Sha18-Jun-15 22:08 
GeneralRe: Where is the source code? Pin
Jamming119-Jun-15 1:03
Jamming119-Jun-15 1:03 
GeneralRe: Where is the source code? Pin
Sa Sha22-Jun-15 22:11
Sa Sha22-Jun-15 22:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.