Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / VisualC++

GMDH Algorithm Implementation

0.00/5 (No votes)
15 Jun 2015CPOL1 min read 12.9K   156  
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)