Home > Mateda2.0 > knowledge_extraction > visualization > ViewDenDroStruct.m

# ViewDenDroStruct

## PURPOSE

function[res_ordering] = ViewDenDroStruct(run_structures,viewparams)

## SYNOPSIS

function[res_ordering] = ViewDenDroStruct(run_structures,viewparams)

## DESCRIPTION

       function[res_ordering] = ViewDenDroStruct(run_structures,viewparams)
       ViewDenDroStruct:  Shows the dendrograms of the edges according to
                           their co-occurrence in the structures learned by
                           the EDAs. Allows to detect complex hierarchical
                           relationships between the variables of the problem

     INPUT
     run_structures: Contain the data structures with all the structures
     learned by the probability models in every run and generation (see
     program ReadStructures.m for details.
     viewparams{1} = fs; % fs: Font size for the images
     viewparams{2} : Matrices with edges that will be shown. One row for each
     edge. If viewparams{2}== [], the algorithm finds a subset of edges
     according viewparams{3}
     viewparams{3} = const_edg :  Minimal number of times that an edge has to appear in (all) the structures learned
                                 to be selected for visualization. Since the  clarity of the parallel coordinate
                                 visualization depend on the number of variables, this is an important parameter.
     viewparams{4} = min_edg :  Minimal number of edges in the substructures selected (min_edg>0)
     viewparams{5} = distance. Distance used to cluster edges from their
     appearance in the structures (distances used by matlab command pdist (ex. 'correlation', 'euclidean',etc.) can
     be used (see help pdist).
     OUTPUT:
     res_ordering{1} = T;
     res_ordering{2} = PERM; % Ordering of the variables in the dendrogram
     res_ordering{3} = List of the originals edges in the order they are shown
                       in the dendrogram

     Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)

## CROSS-REFERENCE INFORMATION

This function calls:

- ExtractSubstructures [AllRepVectors] = ExtractSubstructures(run_structures,RepEdges,NumbRep)
- SelectEdgesToShow [sel_edges] = SelectEdgesToShow(run_structures,const_edg)

This function is called by:

## SOURCE CODE

    0001 function[res_ordering] = ViewDenDroStruct(run_structures,viewparams)
    0002 %   function[res_ordering] = ViewDenDroStruct(run_structures,viewparams)
    0003 %   ViewDenDroStruct:  Shows the dendrograms of the edges according to
    0004 %                       their co-occurrence in the structures learned by
    0005 %                       the EDAs. Allows to detect complex hierarchical
    0006 %                       relationships between the variables of the problem
    0007 %
    0008 % INPUT
    0009 % run_structures: Contain the data structures with all the structures
    0010 % learned by the probability models in every run and generation (see
    0011 % program ReadStructures.m for details.
    0012 % viewparams{1} = fs; % fs: Font size for the images
    0013 % viewparams{2} : Matrices with edges that will be shown. One row for each
    0014 % edge. If viewparams{2}== [], the algorithm finds a subset of edges
    0015 % according viewparams{3}
    0016 % viewparams{3} = const_edg :  Minimal number of times that an edge has to appear in (all) the structures learned
    0017 %                             to be selected for visualization. Since the  clarity of the parallel coordinate
    0018 %                             visualization depend on the number of variables, this is an important parameter.
    0019 % viewparams{4} = min_edg :  Minimal number of edges in the substructures selected (min_edg>0)
    0020 % viewparams{5} = distance. Distance used to cluster edges from their
    0021 % appearance in the structures (distances used by matlab command pdist (ex. 'correlation', 'euclidean',etc.) can
    0022 % be used (see help pdist).
    0023 % OUTPUT:
    0024 % res_ordering{1} = T;
    0025 % res_ordering{2} = PERM; % Ordering of the variables in the dendrogram
    0026 % res_ordering{3} = List of the originals edges in the order they are shown
    0027 %                   in the dendrogram
    0028 %
    0029 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
    0030
    0031
    0032 indexmatrix = run_structures{1};
    0033 fs = viewparams{1};
    0034 substruct = viewparams{2};
    0035 const_edg = viewparams{3};
    0036 min_edg = viewparams{4};
    0037 distance = viewparams{5};
    0038
    0039 results = [];
    0040
    0041
    0042  if isempty(substruct)
    0043    [RepEdges] = SelectEdgesToShow(run_structures,const_edg); % Edges are selected according to const_edg value
    0044    if(isempty(RepEdges))
    0045       disp('No edges were selected. Reduce the number of times required to an edge to appear.') %No edges were found
    0046       return
    0047    end
    0048    for i=1:size(RepEdges,2)
    0049      [row,col] = find(indexmatrix==RepEdges(i));
    0050       dlabels{i} = [int2str(row(1)),'-',int2str(col(1))];
    0051    end
    0052  else
    0053   for i=1:size(substruct,1)
    0054    RepEdges(1,i) = indexmatrix(substruct(i,1),substruct(i,2));    % Indices of the edges in indexmatrix
    0055    dlabels{i} = [int2str(substruct(i,1)),'-',int2str(substruct(i,2))];
    0056   end
    0057  end
    0058
    0059
    0060  [AllRepVectors] = ExtractSubstructures(run_structures,RepEdges,min_edg); % The substructures to be shown are extracted
    0061
    0062  nedges = size(RepEdges,2)
    0063
    0064
    0065  y = pdist(AllRepVectors', distance);
    0066  z = linkage(y,'single')
    0067
    0068  figure     % Dendrogram figure
    0069  axes('Fontsize',fs);
    0070  [H,T,PERM] = dendrogram(z,nedges,'orientation','left','labels',dlabels);
    0071
    0072
    0073  res_ordering{1} = T;
    0074  res_ordering{2} = PERM; % Ordering of the variables in the dendrogram
    0075
    0076  for i=1:nedges
    0077   [row,col] = find(indexmatrix==RepEdges(PERM(i)));
    0078    res_ordering{3}(i,:) = [row(1),col(1)];
    0079  end
    0080
    0081  return
    0082
    0083
    0084
    0085
    0086
    0087
    0088
    0089
    0090
    0091