12.   Predictor63
12.1   Predictor63 Interface
12.2   Input and Output
12.3   Parameters
12.4   Link to Class Library
12.5   Prediction Buttons
12.6   Test Run

12.   Predictor63 Class Library

This chapter introduces the class library, Attrasoft.PolyApplet63.Predictor63, which is the library for the software, Attrasoft Predictor. Predictor operation includes two steps:

We have seen the expanded version of the Predictor in chapter 8 at the Presentation Layer.
The Predictor63 class library is an Application Layer library, which makes the programming much easier.
 

Figure 12.1   The Predictor Form.


12.1   Predictor63 Interface

The Predictor63 class library implements the following interface:

public interface I_Predictor63
 {
  bool openPredictorTrainFile ();
  bool openOutputFile ();

   bool predictorBinaryLinearPlusReal ();
   bool predictorBinaryLinearPlusInt ();
   bool predictorBinaryLinearMinusReal ();
   bool predictorBinaryLinearMinusInt ();
   bool predictorBinaryLinearZeroInt ();
   bool predictorBinaryLinearZeroReal ();

   bool predictorBinaryExpPlus ();
   bool predictorBinaryExpMinus ();
   bool predictorBinaryExpZero ();

 }
In addition, the class library has the following properties:
 I/O Files:
  public string PredictorTrainName
  public string OutputName
 Presentation Layer parameters:
  public int Precision
  public int Trend
  public double Emptyfield
 Neural Layer parameters:
  public int Sensitivity
  public int Blurring
  public int InternalWeightCut
The following will briefly describe the neural parameters. Please refer to the ImageFinder User’s Guide for more details:
Blurring
Use Blurring to control the amount of output. "0%"-Blurring means the exact match. When the "Blurring" is increased, you will get more and more matches. The Blurring settings range from 0 – 50.
Sensitivity
Use Sensitivity Text Box to adjust search segment size. The Sensitivity parameter ranges from 0 (least sensitive) to 100 (most sensitive).
  • To search small segment(s), use a high sensitivity search.
  • To search large segment(s), use low sensitivity search.
  • The higher the parameter is set, the more results you will get.
Internal Weight Cut
The Internal Cut plays the similar role as the Threshold. The Internal Cut ranges from 0 to 100.


12.2   Input and Output

We have implemented the Input Files several times before. We will just list the Input File codes below:
 

 File selection:

 private void button1_Click(object sender, System.EventArgs e)

  {
   if ( openFileDialog1.ShowDialog () != DialogResult.OK )
    return;
   textBox1.Text =  openFileDialog1.FileName  ;

  }

 Text Box:

  private void textBox1_TextChanged(object sender, System.EventArgs e)

  {
   z.PredictorTrainName  = textBox1.Text;
   richTextBox1.AppendText
("Predictor Input: " + z.PredictorTrainName + "\n");
  }
 Open button:

  private void button2_Click(object sender, System.EventArgs e)

  {
   z.openPredictorTrainFile ();
  }
Similarly, the Output File codes are:

private void button3_Click(object sender, System.EventArgs e)

  {
   if ( openFileDialog1.ShowDialog () != DialogResult.OK )
    return;
   textBox2.Text =  openFileDialog1.FileName  ;
  }
private void textBox2_TextChanged(object sender, System.EventArgs e)
  {

   z.OutputName   = textBox2.Text;
   richTextBox1.AppendText
 ("Predictor Output: " + z.OutputName + "\n");
  }

 private void button4_Click(object sender, System.EventArgs e)
  {
   z.openOutputFile ();
  }
12.3   Parameters

Figure 12.2  The Predictor Parameter Form.

The Predictor has several parameters:

Presentation Layer parameters:

 public int Precision
 public int Trend
 public double Emptyfield
Neural Layer parameters:
 public int Sensitivity
 public int Blurring
 public int InternalWeightCut
This section implements the form in Figure 12.2, which will set the Predictor parameters. To set the parameters, double click the “Parameter” button in Figure 12.1 and enter:
private void button5_Click(object sender, System.EventArgs e)
  {
   Form2 paraForm = new Form2 (z );
   paraForm.ShowDialog ();

   richTextBox1.Text =
       "Blurring = " + z.Blurring + "\n" +
       "Sensitivity = " + z.Sensitivity + "\n" +
       "Threshold = " + z.InternalWeightCut + "\n" +
       "Precision = " + z.Precision + "\n" +
       "Trend = " + z.Trend + "\n" +
       "Empty Field = " + z.Emptyfield + "\n" ;
  }

This will bring up the form in Figure 12.2.

The Parameter form will first display the current parameters. Go to the form, Form2, double click the background and enter:

private void Form2_Load(object sender, System.EventArgs e)
  {
   textBox1.Text = "" + a.Blurring ;
   textBox2.Text = "" + a.Sensitivity ;
   textBox3.Text = "" + a.InternalWeightCut ;
   textBox4.Text = "" + a.Precision ;
   textBox5.Text = "" + a.Trend ;
   textBox6.Text = "" + a.Emptyfield ;
  }
The OK button will set a new set of Predictor parameters. Double click the OK button and enter:
private void button1_Click(object sender, System.EventArgs e)
  {
   try
   {
    a.Blurring = int.Parse (textBox1.Text);
    a.Sensitivity = int.Parse (textBox2.Text );
    a.InternalWeightCut = int.Parse (textBox3.Text );
    a.Precision = int.Parse (textBox4.Text ) ;
    a.Trend = int.Parse (textBox5.Text ) ;
    a.Emptyfield = int.Parse (textBox6.Text ) ;
   }
   catch
   {
    MessageBox.Show ("Please enter valid integers", "Entry Error");
   }
   this.Close();
  }
This should set the Predictor parameters.

12.4   Link to Class Library

The class library is:

 Attrasoft.PolyApplet63.Predictor63.
The class in this library will be:
 Attrasoft.PolyApplet63.Predictor63. Predictor63.
To include the class library in the project, To use the class library, add:
using Attrasoft.PolyApplet63.Predictor63;
To declare an object, add:
public Attrasoft.PolyApplet63.Predictor63. Predictor63 z
= new Attrasoft.PolyApplet63.Predictor63. Predictor63 (richTextBox1);
Now Predictor63 object, z, is ready to use.


12.5   Prediction Buttons

There are 9 Predictor commands in Figure 12.1; each button will simply use one of the 9 commands:
 

private void button7_Click(object sender, System.EventArgs e)
  {
   z.predictorBinaryLinearPlusInt ();
  }
 private void button8_Click(object sender, System.EventArgs e)
  {
   z.predictorBinaryLinearPlusReal ();
  }
 private void button9_Click(object sender, System.EventArgs e)
  {
   z.predictorBinaryLinearMinusInt ();
  }
 private void button10_Click(object sender, System.EventArgs e)
  {
   z.predictorBinaryLinearMinusReal ();
  }
 private void button11_Click(object sender, System.EventArgs e)
  {
   z.predictorBinaryLinearZeroInt ();
  }
 private void button12_Click(object sender, System.EventArgs e)
  {
   z.predictorBinaryLinearZeroReal ();
  }
 private void button13_Click(object sender, System.EventArgs e)
  {
   z.predictorBinaryExpPlus ();
  }
 private void button14_Click(object sender, System.EventArgs e)
  {
   z.predictorBinaryExpMinus ();
  }
 private void button15_Click(object sender, System.EventArgs e)
  {
   z.predictorBinaryExpZero ();
  }

12.6   Test Run

The data file, D_math1a.txt, looks like this:

*
*
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


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

Step 1. Files. (done automatically in the chapter project).

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. Neural Prediction.

Click the “+ Int Linear” button to complete the prediction.

Step 3. Repeat Step 2 for several other buttons.

We should see the same results as in chapter 8.
 
 

Return