12. Predictor6312.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
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.
- Specify Input File
- Click a button
The Predictor63 class library is an Application Layer library, which makes the programming much easier.
Figure 12.1 The Predictor Form.
The Predictor63 class library implements the following interface:
public interface I_Predictor63In addition, the class library has the following properties:
{bool openPredictorTrainFile ();}
bool openOutputFile ();bool predictorBinaryLinearPlusReal ();
bool predictorBinaryLinearPlusInt ();
bool predictorBinaryLinearMinusReal ();
bool predictorBinaryLinearMinusInt ();
bool predictorBinaryLinearZeroInt ();
bool predictorBinaryLinearZeroReal ();bool predictorBinaryExpPlus ();
bool predictorBinaryExpMinus ();
bool predictorBinaryExpZero ();I/O Files:The following will briefly describe the neural parameters. Please refer to the ImageFinder User�s Guide for more details:public string PredictorTrainNamePresentation Layer parameters:
public string OutputNamepublic int PrecisionNeural Layer parameters:
public int Trend
public double Emptyfieldpublic int Sensitivity
public int Blurring
public int InternalWeightCutBlurringUse 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.SensitivityUse Sensitivity Text Box to adjust search segment size. The Sensitivity parameter ranges from 0 (least sensitive) to 100 (most sensitive).Internal Weight Cut
- 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.
The Internal Cut plays the similar role as the Threshold. The Internal Cut ranges from 0 to 100.We have implemented the Input Files several times before. We will just list the Input File codes below:
File selection:12.3 Parametersprivate void button1_Click(object sender, System.EventArgs e)
{Text Box:
if ( openFileDialog1.ShowDialog () != DialogResult.OK )
return;
textBox1.Text = openFileDialog1.FileName ;}
private void textBox1_TextChanged(object sender, System.EventArgs e)
{Open button:
z.PredictorTrainName = textBox1.Text;
richTextBox1.AppendText
("Predictor Input: " + z.PredictorTrainName + "\n");
}private void button2_Click(object sender, System.EventArgs e)
{Similarly, the Output File codes are:
z.openPredictorTrainFile ();
}private void button3_Click(object sender, System.EventArgs e)
{private void textBox2_TextChanged(object sender, System.EventArgs e)
if ( openFileDialog1.ShowDialog () != DialogResult.OK )
return;
textBox2.Text = openFileDialog1.FileName ;
}{private void button4_Click(object sender, System.EventArgs e)z.OutputName = textBox2.Text;
richTextBox1.AppendText
("Predictor Output: " + z.OutputName + "\n");
}{
z.openOutputFile ();
}
Figure 12.2 The Predictor Parameter Form.
The Predictor has several parameters:
Presentation Layer parameters:
public int PrecisionNeural Layer parameters:
public int Trend
public double Emptyfieldpublic int SensitivityThis 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:
public int Blurring
public int InternalWeightCutprivate void button5_Click(object sender, System.EventArgs e)This will bring up the form in Figure 12.2.{
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" ;
}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)The OK button will set a new set of Predictor parameters. Double click the OK button and enter:
{textBox1.Text = "" + a.Blurring ;}
textBox2.Text = "" + a.Sensitivity ;
textBox3.Text = "" + a.InternalWeightCut ;
textBox4.Text = "" + a.Precision ;
textBox5.Text = "" + a.Trend ;
textBox6.Text = "" + a.Emptyfield ;private void button1_Click(object sender, System.EventArgs e)This should set the Predictor parameters.
{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();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:
- In the Solution Explorer, right click References and select Add Reference;
- Browse to find �Predictor63.dll� in c:\polyapplet63\;
- Highlight it and click the �OK� button.
using Attrasoft.PolyApplet63.Predictor63;To declare an object, add:public Attrasoft.PolyApplet63.Predictor63. Predictor63 zNow Predictor63 object, z, is ready to use.
= new Attrasoft.PolyApplet63.Predictor63. Predictor63 (richTextBox1);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){private void button8_Click(object sender, System.EventArgs e)
z.predictorBinaryLinearPlusInt ();
}{private void button9_Click(object sender, System.EventArgs e)
z.predictorBinaryLinearPlusReal ();
}{private void button10_Click(object sender, System.EventArgs e)
z.predictorBinaryLinearMinusInt ();
}{private void button11_Click(object sender, System.EventArgs e)
z.predictorBinaryLinearMinusReal ();
}{private void button12_Click(object sender, System.EventArgs e)
z.predictorBinaryLinearZeroInt ();
}{private void button13_Click(object sender, System.EventArgs e)
z.predictorBinaryLinearZeroReal ();
}{private void button14_Click(object sender, System.EventArgs e)
z.predictorBinaryExpPlus ();
}{private void button15_Click(object sender, System.EventArgs e)
z.predictorBinaryExpMinus ();
}{
z.predictorBinaryExpZero ();
}
12.6 Test RunThe 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:Step 2. Neural Prediction.
Train: example1a.txt
Recognition: example1c.txt
Neural Output: example1d.txt
Output: example2c.txtClick 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