Chap 10.   DecisionMaker Translation Layer
10.1   What is the Attrasoft DecisionMaker ?
10.2   Abm2 Class Library
10.3   Link to Abm2 Class Library
10.4   File Properties and Commands
10.5   Encoding and Decoding Functions
10.6   Parameters
10.7   Chapter Project 1: File IO
10.8   Chapter Project 2: Neural Computing
10.9   Chapter Project 3: Encoding and Decoding
10.10   Wisconsin Breast Cancer Database
10.11   Chapter Project 4: Run


Chap 10.   DecisionMaker Translation Layer

Chapters 8 – 11 will introduce the Presentation Layer components, Abm2. If you do not want know the internal structure, please skip chapters 8, 9, 10, and 11. We will assume you are familiar with the Attrasoft DecisionMaker software.

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. The information processed by a neural network has to be prepared by Abm2. This is called Data Encoding. Similarly, after neural computations, Abm2 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.

10.1   What is the Attrasoft DecisionMaker ?

Attrasoft DecisionMaker uses the data in your database to help you make business decisions.

It does not matter what kind of database you have. What seems complicated to you is not complicated to the Attrasoft DecisionMaker. After putting your data into the DecisionMaker, then in 2 clicks, suddenly your complicated problem will seem very simple.

Attrasoft DecisionMaker can:


10.2   Abm2 Class Library

The Abm2 class library is an interface between the PolyApplet and the data used by the Predictor software. Abm2 class library is also responsible for the DecisionMaker, which is another Attrasoft software, which will be introduced later.

The Abm2 class library is an interface between the PolyApplet and the data used by the DecisionMaker software. There are two 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 relevant interface is:
interface I_abm2
 {
   bool openAbmTrainFile(  );
   bool openAbmRetrainFile(  );
   bool openAbmRecognitionFile(  );

   bool openOutputFile(  );

   bool openDecisionMakerTrainFile(  );
   bool openDecisionMakerRecoFile(  );

  //*******************************************
  //*******************************************
  //Encoder
   bool decisionMakerEncodeBinaryLinearPlus ();
   bool decisionMakerEncodeBinaryLinearMinus ();
   bool decisionMakerEncodeBinaryLinearZero ();
  //*******************************************
  //Decoder
   bool decisionMakerDecodeBinaryLinearPlusReal ();
   bool decisionMakerDecodeBinaryLinearPlusInt ();
   bool decisionMakerDecodeBinaryLinearMinusReal ();
   bool decisionMakerDecodeBinaryLinearMinusInt ();
   bool decisionMakerDecodeBinaryLinearZeroReal ();
   bool decisionMakerDecodeBinaryLinearZeroInt ();
  …
 }

The Abm2 also has the following properties:
 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 double Emptyfield;

10.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.
 

10.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; abm2 class library 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 DecisionMakerTrainName ;
 public string DecisionMakerRecoName ;
Output files:
 public string AbmTrainName ;
 public string AbmRetrainName ;
 public string AbmRecognitionName ;
 public string AbmOutputName ;
To open these files, use the following functions:
bool open DecisionMakerTrainName (  );
bool open DecisionMakerRecoName (  );

bool openAbmTrainFile(  );
bool openAbmRetrainFile(  );
bool openAbmRecognitionFile(  );
bool openAbmOutputFile(  );

The Decoding part use 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(  );
  10.5   Encoding and Decoding Functions

These commands are divided into two groups:

The Linear mode deals with two situations: The Exponential mode deals with: The DecisionMaker does not support the Exponential coding.

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.


The Decoding part is further divided into:

The Encoding functions are:
 bool decisionMakerEncodeBinaryLinearPlus ();
 bool decisionMakerEncodeBinaryLinearMinus ();
 bool decisionMakerEncodeBinaryLinearZero ();
Based on the above discussion: The Decoding functions are:
  bool decisionMakerDecodeBinaryLinearPlusReal ();
  bool decisionMakerDecodeBinaryLinearPlusInt ();
  bool decisionMakerDecodeBinaryLinearMinusReal ();
  bool decisionMakerDecodeBinaryLinearMinusInt ();
  bool decisionMakerDecodeBinaryLinearZeroReal ();
  bool decisionMakerDecodeBinaryLinearZeroInt ();
Based on the above discussion:
 the function, decisionMakerDecodeBinaryLinearPlusReal (), means linear, ‘+’, Real decoding.
10.6   Parameters

The Parameters are:

 public int Precision ;
 public double Empty-Field;
The Precision-level determines the error level of 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 10.1   Chapter 8 Project.

10.7   Chapter Project 1: File IO

This chapter project is in C:\polyapplet63\chap10\. There are 6 files used:

Application Training
Application Recognition
Neural Net Training
Neural Net Recognition
Neural Net Output
Application Output
The default file names are:
DecisionMaker Train:   example2a.txt
DecisionMaker Recognition:  example2b.txt
Neural Train:    example1a.txt
Neural Retrain:   example1b.txt
Neural Recognition:   example1c.txt
Neural Output:   example1d.txt
Output:    example2c.txt
In earlier chapters, we implemented the last four of the six files. Now, we will add two more files. Note that the Abm2 object is called y.

DecisionMaker Train:

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.DecisionMakerTrainName   = textBox4.Text;
richTextBox1.AppendText ("DecisionMaker Training: " + y.DecisionMakerTrainName + "\n");
 }


Open Button:

private void button21_Click(object sender, System.EventArgs e)
  {
  y.openDecisionMakerTrainFile();
  }


DecisionMaker Recognition:

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


Open Button

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

10.8   Chapter Project 2: Neural Computing

We added the PolyNet command earlier:

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


10.9   Chapter Project 3: Encoding and Decoding

We have chosen 3 pairs of Encoding and Decoding:

+ Linear Integer Prediction:

 private void button16_Click_1(object sender, System.EventArgs e)
  {
   y.decisionMakerEncodeBinaryLinearPlus ();
   richTextBox1.AppendText ( "Encoding End!\n") ;
  }

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


- Linear Integer Prediction:

 private void button7_Click_1(object sender, System.EventArgs e)
  {
   y.decisionMakerEncodeBinaryLinearMinus   ();
   richTextBox1.AppendText ( "Encoding End!\n") ;
  }

 private void button11_Click_1(object sender, System.EventArgs e)
  {
   if ( y.decisionMakerDecodeBinaryLinearMinusInt   ())
       y.openOutputFile ();
   else
    richTextBox1.Text = "Decoding fail!\n";

  }


+ Linear Real Prediction:
 

private void button14_Click_2(object sender, System.EventArgs e)
  {
   y.decisionMakerEncodeBinaryLinearPlus ();
   richTextBox1.AppendText ( "Encoding End!\n") ;
  }
 private void button13_Click_1(object sender, System.EventArgs e)
  {
   y.predictorDecodeBinaryLinearPlusReal   ();
   y.openOutputFile ();
  }
10.10   Wisconsin Breast Cancer Database

Cancer is usually evaluated and diagnosed by the following test variables, which is called a data set:

   Attribute                                    Domain
   -----------------------------------------------------------------
   1. Sample code number               Not used
__________________________________________
   2. Clump Thickness                  1 - 10
   3. Uniformity of Cell Size          1 - 10
   4. Uniformity of Cell Shape       1 - 10
   5. Marginal Adhesion                1 - 10
   6. Single Epithelial Cell Size       1 - 10
   7. Bare Nuclei                          1 - 10
   8. Bland Chromatin                   1 - 10
   9. Normal Nucleoli                   1 - 10
  10. Mitoses                               1 - 10
___________________________________________
  11. Class:                          (2 for benign,  4 for malignant)

The Cancer Database looks like below:

1000025,5,1,1,1,2,1,3,1,1,2
1002945,5,4,4,5,7,10,3,2,1,2
1015425,3,1,1,1,2,2,3,1,1,2
1016277,6,8,8,1,3,4,3,7,1,2
1017023,4,1,1,3,2,1,3,1,1,2
1017122,8,10,10,8,7,10,9,7,1,4
1018099,1,1,1,1,2,10,3,1,1,2
1018561,2,1,2,1,2,1,3,1,1,2
1033078,2,1,1,1,2,1,1,1,5,2
1033078,4,2,1,1,2,1,2,1,1,2
1035283,1,1,1,1,1,1,3,1,1,2
1036172,2,1,1,1,2,1,2,1,1,2
1041801,5,3,3,3,2,3,4,4,1,4
1043999,1,1,1,1,2,3,3,1,1,2
1044572,8,7,5,10,7,9,5,5,4,4
1047630,7,4,6,4,6,1,4,3,1,4
1048672,4,1,1,1,2,1,2,1,1,2
1049815,4,1,1,1,2,1,3,1,1,2
...


The question is: from this data, do the following patients have cancer (2 for benign, 4 for malignant)?

1050670,10,7,7,6,4,10,4,1,2,?
1050718,6,1,1,1,2,1,3,1,1,?


More information on the Wisconsin Breast Cancer database:

The 683 rows of data will be divided into two parts:


 Below are the last 20 rows:

    Question File                          Answer
ID
1368882 2 1 1 1 2 1 1 1 1                    2
1369821 10 10 10 10 5 10 10 10 7        4
1371026 5 10 10 10 4 10 5 6 3             4
1371920 5 1 1 1 2 1 3 2 1                    2
466906 1 1 1 1 2 1 1 1 1                      2
466906 1 1 1 1 2 1 1 1 1                      2
534555 1 1 1 1 2 1 1 1 1                      2
536708 1 1 1 1 2 1 1 1 1                      2
566346 3 1 1 1 2 1 2 3 1                      2
603148 4 1 1 1 2 1 1 1 1                      2
654546 1 1 1 1 2 1 1 1 8                      2
654546 1 1 1 3 2 1 1 1 1                      2
695091 5 10 10 5 4 5 4 4 1                  4
714039 3 1 1 1 2 1 1 1 1                      2
763235 3 1 1 1 2 1 2 1 2                      2
776715 3 1 1 1 3 2 1 1 1                      2
841769 2 1 1 1 2 1 1 1 1                      2
888820 5 10 10 3 7 3 8 10 2                 4
897471 4 8 6 4 3 4 10 6 1                    4
897471 4 8 8 5 4 5 10 4 1                    4

These 20 rows are further divided into 2 groups:


The DecisionMaker is expected to produce the Answer file, which reflects the correct answer located in the last column.

10.11   Chapter Project 4: Run

There are two data files in the chapter project; both data files are from the DecisionMaker.

Step 1. Files.

The following are done automatically:

DecisionMaker Train:   cancer1a.txt:
DecisionMaker Recognition: cancer1b.txt:
Train:     example1a.txt
Recognition:    example1c.txt
Neural Output:   example1d.txt
Output:    example2c.txt


Step 2. Encoding.

Click the “DM Int +” encoding button.
 

Step 3. Neural Computing.

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

Step 4. Decoding.

Click the “DM Int +” decoding button.

Repeat Steps 2- 4 for:

-  Linear Integer Prediction
+ Linear Real Prediction


Out of the 20 predictions, the DecisionMaker made 17 predictions. The 17 out of 17 predictions are 100% correct.

The DecisionMaker cannot handle the last three cases, based on the training received from the 663 instances. More training is required for these 3 instances. As you will see in the next chapter, when the Abm algorithm is replaced by the PolyNet algorithm, all 20 cases are predicted correctly.

In summary, Abm2 translate the DecisionMaker data to and from neural data.
 

Return