7.6 The File Menu


[Picture]
Figure 7.36: The Tree View File drop down menu.

This is what the 5 submenus of the File menu do:


Menu Choice Does This
Print tree Print paper copy of a tree using this menu choice.
Save Tree Image Creates a BMP format image file in black and white or color.
View Predictions (In-Sample) Brings up a spreadsheet showing actual and predicted values for each row.
Output C File Writes a C program that models the prediction behavior of the tree.
Close Closes the tree view.

7.6.1 File->Print tree


[Picture]
Figure 7.37: A typical Windows print dialog to pick your printer.

The print options are Black and White and Color on White (if you have a color printer).

7.6.2 File->Save Tree Image


[Picture]
Figure 7.38: The menu for saving tree images.

You can save an image as Black and White, Color on White or the Same as Screen.


[Picture]
Figure 7.39: The window to save a Tree image.

You can use the menus File->Save Tree Image->(pick a color type) to open a Save As dialog that ask where you want to save the file. It is saved as a bit mapped image (BMP). BMP files are fairly large so you may want to use an image editing program to convert them to a PNG or JPEG format file to reduce the size (especially if you use them on the internet).

7.6.3 File->View Predictions (In-Sample)

This menu choice will create a new spreadsheet viewer with the predicted values for all of the observations in the tree. The predicted value is the mean of the node where the observation falls.

7.6.4 File->Output C Code


[Picture]
Figure 7.40: The Output C file dialog window.

It might be desirable to create a prediction model of a certain data set for the purpose of predicting the results of a similar data set in a customizable fashion. For this purpose, the File->Output C File feature has been integrated into the product. This feature will output the tree prediction structure to a standard C/C++ language program. The program includes functions that model the prediction behavior of the tree or trees, a structure to contain data in a format the prediction functions can use and a main() function with an example of how to call the prediction functions and handle the results.

There are five fields you can customize plus the output file name:


Value Labeled Explanation
Header info: This section is placed at the start of the C program, you can add your specific include statements or defines in this section but it is not advised to remove the default content, but rather to add to it.
Prediction Function Name This base name for the functions that will contain the prediction model of the tree or trees generated. For multiple trees, the functions will be appended with numbers. For example, predictTree1() and predictTree2()
Data Instance Name This is the name of the instance of the data structure used in the main function(). This instance has a default initialization where every variable is set to 0 or “”. The instance is set up as an array to exemplify the handling multiple observations within the program.
Results variable name This is the name of the results variable of type double* used in the main function. It is also set up as an array to handle multivariate responses, but can be used in univariate tree modeling as well.


[Picture]
Figure 7.41: The tree to be outputted to C code in the following example.

As an example of this functionality, you can see the translation of the above tree to C code. Notice that the precision level of the results printed in the C code is higher than that on the individual nodes.

typedef struct{
  int col50;
  int col1169;
} data_t;

void predictTree1(data_t *data, double *results)
{
  if(data->col50 <= 3)
  {
   /* Node N1 */
   *results = 0.4277423099 ;
   return;
  }
  if(3 < data->col50)
  {
   if(data->col1169 <= 1)
   {
    /* Node N21 */
    *results = 1 ;
    return;
   }
   if((1 < data->col1169) && (data->col1169 <= 4))
   {
    /* Node N22 */
    *results = 0 ;
    return;
   }
   if(4 < data->col1169)
   {
    /* Node N23 */
    *results = 0.89453125 ;
    return;
   }
  }
}

int main ()
{   data_t data;
  double results[1];
  /* Enter valid values */
  data.col50 = 0;
  data.col1169 = 0;
  double totalResults=0;   predictTree1( &data, results);
  totalResults += *results;
  printf("\nPredicted: %f\n", totalResults);   return 0;
}

7.6.5 File->Close

This closes the tree view.