8.   Predictor Translation Layer
8.1   What is the Attrasoft Predictor ?
8.2   Abm2 Class Library
8.3   Link to Abm2 Class Library
8.4   File Properties and Commands
8.5   Encoding and Decoding Methods
8.6   Parameters
8.7   Chapter Project 1: File IO
8.8   Chapter Project 2: Neural Computing
8.9   Chapter Project 3: Encoding and Decoding
8.10   Chapter Project 4: Run




8.   Predictor Translation Layer

Chapters 3 � 7 introduce Attrasoft.PolyApplet63.PolyApplet63.
Chapters 8 � 11 will introduce another component, abm2. If you do not want know the internal structure, please skip chapters 8 - 11.

The neural network attempts to simulate the human brain. The human brain has front-end subsystems and can only handle preprocessed information. The front-end subsystems for humans are eyes, ears, ...  The same is also true for neural networks.

There are two types of data used by neural network systems: user data (or application data), and neural data. Neural networks use neural data. User data depends on the application. Neural nets speak neural language; users speak user language.

The information processed by a neural network has to be prepared by a front-end subsystem. This is called Data Encoding. A neural network usually cannot handle the user-application data directly. Similarly, after neural computation, the result usually does not make sense to humans directly; the front-end system is responsible for converting the neural output data back into user-application data.  This is called Data Decoding.

Attrasoft has two libraries for the Encoding and Decoding:

The TransApplet library is for image recognition and is used in the software, ImageFinder.
The Abm2 library is used for processing data and is used in software, DecisionMaker and Predictor.

8.1   What is the Attrasoft Predictor ?

Attrasoft Predictor is software that predicts a sequence. Making decisions based on your projection of the future events is a way of life. Attrasoft Predictor is a fast terabyte data processing tool for your database. It uses a sequence of numbers to predict the next row of numbers in line. It uses historical data to predict future possibilities. It does not matter what you want to predict.

90% of the work in using the Predictor is preparing your database containing your historical data. (Many corporations already have their database in place, which contains years of historical data. It is often overwhelming because of the sheer volume to mine the data for the purpose of strategic thinking.) The remaining 10% of the work is to operate the Predictor (a few clicks). The Predictor is especially good if you have a terabyte or gigabyte database because of its accuracy and speed.

Once your data is prepared correctly, the Predictor is able to provide you with rated predictions on any subject or any problem. The Attrasoft Predictor can:

8.2   Abm2 Class Library

The Abm2 class library is an interface between the PolyApplet63 introduced in the last 5 chapters and the data used by the Predictor software. Abm2 class library is also responsible for the DecisionMaker, which is another Attrasoft software.

There are two image-matching algorithms in the PolyApplet: Abm and PolyNet. The Abm2 class library will translate data for both algorithms. The Abm2 class library will play four roles:

Data Source               Data Consumer              Description
Predictor Data           Abm                               Chap 8
Predictor Data           PolyNet                          Chap 9
DecisionMaker         Data  Abm                       Chap 10
DecisionMaker         Data  PolyNet                  Chap 11


The interface for Abm2 is:

interface I_abm2
 {
   bool openAbmTrainFile(  );
   bool openAbmRetrainFile(  );
   bool openAbmRecognitionFile(  );

   bool openOutputFile(  );

   bool openPredictorTrainFile(  );
   bool openDecisionMakerTrainFile(  );
   bool openDecisionMakerRecoFile(  );

  //*******************************************
  //*******************************************
  //Encoder
   bool decisionMakerEncodeBinaryLinearPlus ();
   bool decisionMakerEncodeBinaryLinearMinus ();
   bool decisionMakerEncodeBinaryLinearZero ();

   bool decisionMakerEncodePolyLinear ();
  //*******************************************
   bool predictorEncodeBinaryLinearPlus ();
   bool predictorEncodeBinaryLinearMinus ();
   bool predictorEncodeBinaryLinearZero ();

   bool predictorEncodePolyLinear ();
  //*******************************************
   bool predictorEncodeBinaryExpPlus ();
   bool predictorEncodeBinaryExpMinus ();
   bool predictorEncodeBinaryExpZero ();
  //*******************************************
  //*******************************************
  //Decoder
   bool decisionMakerDecodeBinaryLinearPlusReal ();
   bool decisionMakerDecodeBinaryLinearPlusInt ();
   bool decisionMakerDecodeBinaryLinearMinusReal ();
   bool decisionMakerDecodeBinaryLinearMinusInt ();
   bool decisionMakerDecodeBinaryLinearZeroReal ();
   bool decisionMakerDecodeBinaryLinearZeroInt ();

   bool decisionMakerDecodePolyLinearReal ();
   bool decisionMakerDecodePolyLinearInt ();
  //*******************************************
   bool predictorDecodeBinaryLinearPlusReal ();
   bool predictorDecodeBinaryLinearPlusInt ();
   bool predictorDecodeBinaryLinearMinusReal ();
   bool predictorDecodeBinaryLinearMinusInt ();
   bool predictorDecodeBinaryLinearZeroInt ();
   bool predictorDecodeBinaryLinearZeroReal ();

   bool predictorDecodePolyLinearReal ();
   bool predictorDecodePolyLinearInt ();
  //*******************************************
   bool predictorDecodeBinaryExpPlus ();
   bool predictorDecodeBinaryExpMinus ();
   bool predictorDecodeBinaryExpZero ();
 }


The Abm2 also has the following properties:

 public string PredictorTrainName ;
 public string DecisionMakerTrainName ;
 public string DecisionMakerRecoName ;

 public string AbmTrainName ;
 public string AbmRetrainName ;
 public string AbmRecognitionName ;
 public string AbmOutputName ;

 public string OutputName;

 public int Precision ;
 public int Trend;
 public double Emptyfield;

8.3   Link to Abm2 Class Library

To include the class library in the project,

To use the class library, add:
using Attrasoft.PolyApplet63.abm2;
To declare an object, add:
 public Attrasoft.PolyApplet63.abm2.abm2Main  y;
To create the object, add the following in the constructor:
public Form1()
  {
   //
   // Required for Windows Form Designer support
   //
   InitializeComponent();
   x = new PolyApplet63 (richTextBox1 );
   y = new abm2Main (richTextBox1 );
  }
Now Abm2 object, y, is ready to use.

8.4   File Properties and Commands

A neural network usually cannot handle the user-application data directly. Similarly, after neural computation, the result usually does not make sense to humans directly; the front-end system is responsible for converting application data to neural data (Encoding) and the neural output data back into user-application data (Decoding).

Files are used at two different levels:

The Encoding part uses the following files:

Input files:

public string PredictorTrainName ;
Output files:
 public string AbmTrainName ;
 public string AbmRetrainName ;
 public string AbmRecognitionName ;
 public string AbmOutputName ;
To open these files, use the following functions:
bool openPredictorTrainFile(  );
bool openAbmTrainFile(  );
bool openAbmRetrainFile(  );
bool openAbmRecognitionFile(  );
bool openAbmOutputFile(  );
The Decoding part uses the following files:

Input files:

 public string AbmOutputName ;
Output files:
 public string OutputName;
To open these files, use the following functions:
bool openAbmOutputFile(  );
bool openOutputFile(  );
  8.5   Encoding and Decoding Methods

These commands are divided into two groups:

The Linear mode deals with two situations: The Exponential mode deals with: Each group has three commands: Here, "+" and "--" means the upper bound and the lower bound, respectively. Assume a prediction is
x = 5.6 + 0.3 - 0.2 ,
i.e. the result is likely to be 5.6, but could be in the range [5.4, 5.9]; then

            '0' prediction ==> 5.6
            '+' prediction ==> 5.9
            '--' prediction ==> 5.4 .

'+' and '--' predictions yield results more often than the '0' prediction, therefore, consider these two commands first.
'0' prediction, on other hand, is more accurate than the other two, if it produces a prediction.

The Decoding part is further divided into:

The Encoding functions are:
 bool predictorEncodeBinaryLinearPlus ();
 bool predictorEncodeBinaryLinearMinus ();
 bool predictorEncodeBinaryLinearZero ();

 bool predictorEncodeBinaryExpPlus ();
 bool predictorEncodeBinaryExpMinus ();
 bool predictorEncodeBinaryExpZero ();

Based on the above discussion: The Decoding functions are:
  bool predictorDecodeBinaryLinearPlusReal ();
  bool predictorDecodeBinaryLinearPlusInt ();
  bool predictorDecodeBinaryLinearMinusReal ();
  bool predictorDecodeBinaryLinearMinusInt ();
  bool predictorDecodeBinaryLinearZeroInt ();
  bool predictorDecodeBinaryLinearZeroReal ();

  bool predictorDecodeBinaryExpPlus ();
  bool predictorDecodeBinaryExpMinus ();
  bool predictorDecodeBinaryExpZero ();

Based on the above discussion: 8.6   Parameters

The Parameters are:

 public int Precision ;
 public int Trend;
 public double Empty-Field.
Let the Trend be N, the Predictor will look at all N-row patterns, then it looks at the last N - 1 rows and makes a prediction. The number of rows in the Trend is a user-selected variable: you decide the number of rows in the Trend. If you do not make a choice, the default value uses a 5-trend. To change the Trend, use this property.

The Precision-level determines the error level in each variable.

The Empty-Field means whenever the Predictor meets this number, it will ignore the number. The reason for this parameter is to handle cases where there are missing entries in the historical data.

Figure 8.1   Chapter 8 Project.

8.7   Chapter Project 1: File IO

This chapter project is in C:\polyapplet63\chap8\.

There are 5 files used:

 Application Input
 Neural Net Training
 Neural Net Recognition
 Neural Net Output
Application Output
The default file names are:
Predictor Input:         example2a.txt
Train:                       example1a.txt
Retrain:                    example1b.txt
Recognition:              example1c.txt
Neural Output:          example1d.txt
Output:                     example2c.txt
We implemented three of the five files earlier. The neural output text box will need to be modified as follows:
 private void textBox3_TextChanged(object sender, System.EventArgs e)
  {
  x.setOutputFile  (textBox3.Text);
  y.AbmOutputName = textBox3.Text;
  }
 Now we will add two more files. Note that the abm2 object is called y.

Application Input:

File Selection button:
private void button20_Click(object sender, System.EventArgs e)
 {
 if ( openFileDialog1.ShowDialog () != DialogResult.OK )
  return;
 textBox4.Text =  openFileDialog1.FileName  ;
 }
Text Box:
private void textBox4_TextChanged(object sender, System.EventArgs e)
 {
 y.PredictorTrainName  = textBox4.Text;
 richTextBox1.AppendText ("Predictor Input: " + y.PredictorTrainName + "\n");
 }

Open Button:
private void button21_Click(object sender, System.EventArgs e)
  {
   y.openPredictorTrainFile ();
  }


Application Output:

File Selection button:
private void button22_Click(object sender, System.EventArgs e)
  {
  if ( openFileDialog1.ShowDialog () != DialogResult.OK )
   return;
  textBox5.Text =  openFileDialog1.FileName  ;
  }
Text Box:
 private void textBox5_TextChanged(object sender, System.EventArgs e)
  {
  y.OutputName   = textBox5.Text;
  richTextBox1.AppendText ("Predictor Output: " + y.OutputName + "\n");
  }

Open Button
 private void button23_Click(object sender, System.EventArgs e)
  {
  y.openOutputFile ();
  }

8.8   Chapter Project 2: Neural Computing

Both the Predictor and the DecisionMaker use the same binary command in the Abm. We will add multi-valued commands for later chapters. So there are two commands:

Binary:

private void button24_Click(object sender, System.EventArgs e)
  {
   if ( ! x.distribution () )
   {
    richTextBox1.AppendText ( "Classification fails!\n");
    return;
   }
   x.openOutputFile ();
  }


Polytomous:

private void button8_Click(object sender, System.EventArgs e)
  {

   if ( ! x.polyDistribution () )
   {
    richTextBox1.AppendText ( "Classification fails!\n");
    return;
   }
   x.openOutputFile ();
  }


8.9   Chapter Project 3: Encoding and Decoding

We have chosen 4 pairs of Encoding and Decoding:

+ Linear Integer Prediction:

 private void button18_Click(object sender, System.EventArgs e)
  {
   y.predictorEncodeBinaryLinearPlus   ();
   richTextBox1.Text = "Encoding End!\n" ;
  }

  private void button19_Click(object sender, System.EventArgs e)
  {
   y.predictorDecodeBinaryLinearPlusInt   ();
   y.openOutputFile ();
  }

- Linear Integer Prediction:
 private void button7_Click_1(object sender, System.EventArgs e)
  {
   y.predictorEncodeBinaryLinearMinus   ();
   richTextBox1.Text = "Encoding End!\n" ;
  }

 private void button11_Click_1(object sender, System.EventArgs e)
  {
   y.predictorDecodeBinaryLinearMinusInt   ();
   y.openOutputFile ();
  }

+ Linear Real Prediction:
private void button12_Click_1(object sender, System.EventArgs e)
  {
   y.predictorEncodeBinaryLinearPlus   ();
   richTextBox1.Text = "Encoding End!\n" ;
  }

 private void button13_Click_1(object sender, System.EventArgs e)
  {
   y.predictorDecodeBinaryLinearPlusReal   ();
   y.openOutputFile ();
  }

+ Exponential (Real) Prediction:
 private void button14_Click_1(object sender, System.EventArgs e)
  {
   y.predictorEncodeBinaryExpPlus   ();
   richTextBox1.Text = "Encoding End!\n" ;
  }

 private void button15_Click_1(object sender, System.EventArgs e)
  {
   y.predictorDecodeBinaryExpPlus   ();
   y.openOutputFile ();
  }

8.10   Chapter Project 4: Run

There are two data files in this chapter project; both data files are from the Predictor. These two files are:

D_math1a.txt:

*
*
3
1  0  0
1  1  0
2  1  1
4  2  1
0  4  2
6  0  4
3  6  0
2  3  1
6  2  3
4  6  2

 

D_math2a.txt:

*
*
5
1  0  0   0   0
1  1  0   1   0
2  1  2   3   1
5  2  1   0   0
1  5  3   2   0
2  1  0   4   2
3  2  2   1   1

The question is: �what is the next row in each case�?

Step 1. Files.

Enter the five data files in the following:

Input:   D_math1a.txt:
Train:   example1a.txt
Recognition:  example1c.txt
Neural Output: example1d.txt
Output:  example2c.txt

Step 2. Encoding

Click the �+ Linear Int� encoding button.

Step 3. Neural Computing.

Click the �B Distribute� button (B = Binary) to complete the neural computing.

Step 4. Decoding.

Click the �+ Linear Int� decoding button.

Repeat Steps 2- 4 for:

-  Linear Integer Prediction
+ Linear Real Prediction
+ Exponential (Real) Prediction:
In summary, we introduced the Abm2 class library in this chapter. Abm2 translates the Predictor data to and from neural data.
 
Return