function iris_decision_tree ( )

%*****************************************************************************80
%
%% iris_decision_tree plots a decision tree for iris classification.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    20 September 2018
%
%  Author:
%
%    John Burkardt
%
  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'iris_decision_tree:\n' );
  fprintf ( 1, '  MATLAB/Octave version %s:\n', version ( ) );
  fprintf ( 1, '  Plot a decision tree for the iris classification task.\n' );
%
%  Each entry in "nodes" is the "parent" of the given node.
%
  nodes = [ 0, 1, 1, 3, 3, 4, 4, 6, 6 ];
%
%  Display the basic tree.
%
  treeplot ( nodes, 'k^', 'r-'  );
%
%  Assign labels for each node.
%
  labels_left = { ...
    'x3<2.45',
    '',
    'x4<1.75',
    'x3<4.95',
    '',
    'x4<1.65',
    '',
    '',
    ''};
  labels_right = { ...
    '2.45<=x3',
    '',
    '1.75<=x4',
    '4.95<=x3',
    '',
    '1.65<=x4',
    '',
    '',
    ''};
  labels_center = { ...
    '',
    'setosa',
    '',
    '',
    'virginica',
    '',
    'virginica',
    'versicolor',
    'virginica'};
%
%  Get the coordinates of each node.
%
  [ x, y ] = treelayout ( nodes );
%
%  Plot the label below the node.
%
  for i = 1 : length ( x )
    if ( 0 < length ( labels_center{i} ) )
      text ( x(i)-0.05, y(i)-0.05, labels_center{i} );
    end
  end
%
%  Plot the label slightly to the left of the node.
%
  for i = 1 : length ( x )
    if ( 0 < length ( labels_left{i} ) )
      text ( x(i) - 0.12, y(i) - 0.05, labels_left{i} );
    end
  end
%
%  Plot the label slightly to the right of the node.
%
  for i = 1 : length ( x )
    if ( 0 < length ( labels_right{i} ) )
      text ( x(i) + 0.025, y(i) - 0.05, labels_right{i} );
    end
  end

  title ( 'Iris classification decision tree', 'Fontsize', 16 )
  set ( gca, 'Xtick', [] );
  set ( gca, 'Ytick', [] );

  filename = 'iris_decision_tree.png';
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'iris_decision_tree:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  timestamp ( );

  return
end

