Chap 10. DecisionMaker Translation Layer10.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 LayerChapters 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.
- TransApplet
- Abm2
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:
- Decide whether to grant a loan to a customer, student *
- Decide whether a patient has cancer *, heart disease *, thyroid disease *, ...., or not
- Decide whether to hire a person or not
- Decide how likely a patient is going to get cancer, heart disease *, ....,
- Decide the classification of a virus/bacteria within a group of virus/bacteria *.
- Decide how much a house *, a car *, a boat, ... , is worth
- Decide whether your supervisors evaluate your employees fairly
- Decide whether your system (electronics systems, computer network, retail store, sexual harassment situation) is healthy
- Decide supermarket price predictability based on accumulated database
- Decide which career a child should choose
- Decide the outcome of a random event, like a horse race, ...
- Identify an item in Forensic Science *, ...
- Sport Predictions: Soccer game, Horse race, ...
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 DescriptionThe relevant interface is:
Predictor Data Abm Chap 8
Predictor Data PolyNet Chap 9
DecisionMaker Data Abm Chap 10
DecisionMaker Data PolyNet Chap 11interface I_abm2The Abm2 also has the following properties:
{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 ();
…
}public string DecisionMakerTrainName ;10.3 Link to Abm2 Class Library
public string DecisionMakerRecoName ;public string AbmTrainName ;
public string AbmRetrainName ;
public string AbmRecognitionName ;
public string AbmOutputName ;public string OutputName;
public int Precision ;
public double Emptyfield;To include the class library in the project,
To use the class library, add:
- In the Solution Explorer, right click References and select Add Reference;
- Browse to find “abm2.dll” in c:\polyaplet64\;
- Highlight it and click the “OK” button.
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()Now abm2 object, y, is ready to use.
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
x = new PolyApplet63 (richTextBox1 );
y = new abm2Main (richTextBox1 );}
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:
- Application data
- Neural Net data
Input files:
public string DecisionMakerTrainName ;Output files:
public string DecisionMakerRecoName ;public string AbmTrainName ;To open these files, use the following functions:
public string AbmRetrainName ;
public string AbmRecognitionName ;
public string AbmOutputName ;bool open DecisionMakerTrainName ( );The Decoding part use the following files:
bool open DecisionMakerRecoName ( );bool openAbmTrainFile( );
bool openAbmRetrainFile( );
bool openAbmRecognitionFile( );
bool openAbmOutputFile( );Input files:
public string AbmOutputName ;Output files:public string OutputName;To open these files, use the following functions:bool openAbmOutputFile( );10.5 Encoding and Decoding Functions
bool openOutputFile( );These commands are divided into two groups:
The Linear mode deals with two situations:
- Linear
- Exponential
The Exponential mode deals with:
- Data is in fixed intervals [a, b];
- Data grows linearly, 1, 2, 3, 4, … .
The DecisionMaker does not support the Exponential coding.
- Data grows exponentially, 1, 2, 4, 8, … .
Each group has three commands:
Here, "+" and "--" means the upper bound and the lower bound, respectively. Assume a prediction is
- +
- --
- 0.
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:
- Real numbers
- Integers
bool decisionMakerEncodeBinaryLinearPlus ();Based on the above discussion:
bool decisionMakerEncodeBinaryLinearMinus ();
bool decisionMakerEncodeBinaryLinearZero ();The Decoding functions are:
- the function, decisionMakerEncodeBinaryLinearPlus (), means linear and ‘+’ encoding; and the function.
bool decisionMakerDecodeBinaryLinearPlusReal ();Based on the above discussion:
bool decisionMakerDecodeBinaryLinearPlusInt ();
bool decisionMakerDecodeBinaryLinearMinusReal ();
bool decisionMakerDecodeBinaryLinearMinusInt ();
bool decisionMakerDecodeBinaryLinearZeroReal ();
bool decisionMakerDecodeBinaryLinearZeroInt ();the function, decisionMakerDecodeBinaryLinearPlusReal (), means linear, ‘+’, Real decoding.10.6 ParametersThe Parameters are:
public int Precision ;The Precision-level determines the error level of each variable.
public double Empty-Field;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 TrainingThe default file names are:
Application Recognition
Neural Net Training
Neural Net Recognition
Neural Net Output
Application OutputDecisionMaker Train: example2a.txtIn 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 Recognition: example2b.txt
Neural Train: example1a.txt
Neural Retrain: example1b.txt
Neural Recognition: example1c.txt
Neural Output: example1d.txt
Output: example2c.txtDecisionMaker Train:
File Selection button:private void button20_Click(object sender, System.EventArgs e)
{
if ( openFileDialog1.ShowDialog () != DialogResult.OK )
return;
textBox4.Text = openFileDialog1.FileName ;
}
Text Boxprivate 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)Text Box:
{
if ( openFileDialog1.ShowDialog () != DialogResult.OK )
return;
textBox6.Text = openFileDialog1.FileName ;
}private void textBox5_TextChanged(object sender, System.EventArgs e)
{
y.DecisionMakerRecoName = textBox6.Text;
richTextBox1.AppendText ("DecisionMaker Recognition: " + y.DecisionMakerRecoName + "\n");
}
Open Buttonprivate void button23_Click(object sender, System.EventArgs e)
{
y.openDecisionMakerRecoFile ();
}
10.8 Chapter Project 2: Neural ComputingWe 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 DecodingWe 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)10.10 Wisconsin Breast Cancer Database
{
y.decisionMakerEncodeBinaryLinearPlus ();
richTextBox1.AppendText ( "Encoding End!\n") ;
}
private void button13_Click_1(object sender, System.EventArgs e)
{
y.predictorDecodeBinaryLinearPlusReal ();
y.openOutputFile ();
}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:
- Number of Instances: 683.
- Number of Attributes: 10 plus the class attribute. Attributes 2 through 10 will be used to represent instances.
- Each instance has one of 2 possible classes:
- benign = 2 or malignant = 4.
- The first 663 rows will comprise the Cancer-Database; and
- The last 20 rows will be used to test the accuracy of the DecisionMaker.
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 4These 20 rows are further divided into 2 groups:
- The first group consists of column 2 - 10. It forms the Question file for the DecisionMaker.
- The last row provides the correct diagnoses concerning whether a patient has cancer or not.
The DecisionMaker is expected to produce the Answer file, which reflects the correct answer located in the last column.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