This module defines a class that represents a two layer self_organizing_map for clustering
Class to represent a two level self_organized_map
| procedure, public :: create => create_2lsom | |
| procedure, public :: destroy => destroy_2lsom | |
| procedure, public :: train => train_2lsom | |
| procedure, public :: predict => predict_2lsom | |
| procedure, public :: train_grid_layer | |
| procedure, public :: train_cluster_layer | |
| procedure, public :: print => print_2lsom | |
| procedure, public :: query => query_2lsom | |
| procedure, public :: set_cluster_layer | |
| procedure, public :: set_parameters | |
| procedure, public :: read_som_layer | |
| procedure, public :: calculate_sum2_clusters_samples => evaluate_2lsom | |
| procedure, public :: get_cluster_samples | |
| procedure, public :: calculate_sum2_clusters_grid | |
| procedure, public, nopass :: external_train_map | 
Function to calculate the index inside a rectangular grid from position ix,iy,iz
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | ix | 
 Integer variables ix,iy,iz,nx,ny  | 
        ||
| integer, | intent(in) | :: | iy | 
 Integer variables ix,iy,iz,nx,ny  | 
        ||
| integer, | intent(in) | :: | iz | 
 Integer variables ix,iy,iz,nx,ny  | 
        ||
| integer, | intent(in) | :: | nx | 
 Integer variables ix,iy,iz,nx,ny  | 
        ||
| integer, | intent(in) | :: | ny | 
 Integer variables ix,iy,iz,nx,ny  | 
        
Integer variable with the index
Constructor of a two_level self_organized_map class
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| type(kohonen_layer_parameters), | dimension(:) | :: | training_parameters | 
 A   | 
        
Destructor of a two_level self_organized_map
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        
Subroutine to generate random values that serve as inputs to the SOM
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| real(kind=wp), | intent(out), | dimension(:,:) | :: | input | 
 A real array with the initial values of the prototypes  | 
        
Subroutine to train a two_level self_organized_map
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| type(kohonen_pattern), | intent(inout), | dimension(:) | :: | input_data | 
 A   | 
        
Subroutine to make a prediction from a trained two_level self_organized_map
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| type(kohonen_pattern), | intent(inout), | dimension(:) | :: | input_data | 
 A   | 
        |
| integer, | intent(out), | dimension(:,:) | :: | map_output | 
 An integer array  | 
        
Subroutine to train the grid layer of a two_level self_organized_map
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| type(kohonen_pattern), | intent(inout), | dimension(:) | :: | input_data | 
 A   | 
        
Subroutine to train the cluster layer of a two_level self_organized_map
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        
Subroutine to print the layers of a two_level self_organized_map
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| integer, | optional | :: | unit_ | 
 An integer variable with the unit  | 
        
Subroutine to initialize the cluster layer of a Two Level Self-Organizing Map
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| integer | :: | seed | 
 An integer variable with the random seed  | 
        
Subroutine to set parameters
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| type(kohonen_layer_parameters), | dimension(2) | :: | training_parameters | 
Subroutine to calculate some clustering statistics of a two-level self_organized_map
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| type(kohonen_pattern), | intent(inout), | dimension(:) | :: | input_data | 
 A   | 
        |
| real(kind=wp), | optional, | dimension(:) | :: | results | 
 A real array  | 
        
Subroutine to calculate some clustering statistics of a two-level self_organized_map
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| real(kind=wp), | optional, | dimension(:) | :: | results | 
 A real array  | 
        
Subroutine to calculate some clustering statistics of a two-level self_organized_map
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| real(kind=wp), | dimension(:,:,:) | :: | results | 
 A real array  | 
        
Subroutine to read the prototypes of the first/seconf layer of a two level self_organized_map
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| character(len=*) | :: | som_fl | 
 A character variable  | 
        |||
| character(len=*) | :: | layer_type | 
 A character variable  | 
        
Function to find the input samples associated with specific vector
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| real(kind=wp), | intent(inout), | dimension(:,:) | :: | input_pattern | 
 A real array  | 
        |
| integer, | allocatable | :: | sample_index(:) | 
 An integer array  | 
        
Accessor to cluster results obtained using a two-level self_organized_map
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| integer, | intent(inout), | dimension(:) | :: | clusters | 
 An integer array  | 
        
Subroutine to calculate the position ix,iy,iz inside a rectangular grid from index
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | index_ | 
 Integer variables, index_,nx,ny,nz  | 
        ||
| integer, | intent(in) | :: | nx | 
 Integer variables, index_,nx,ny,nz  | 
        ||
| integer, | intent(in) | :: | ny | 
 Integer variables, index_,nx,ny,nz  | 
        ||
| integer, | intent(in) | :: | nz | 
 Integer variables, index_,nx,ny,nz  | 
        ||
| integer, | intent(inout) | :: | cx | 
 Integer variables cx,cy,cz  | 
        ||
| integer, | intent(inout) | :: | cy | 
 Integer variables cx,cy,cz  | 
        ||
| integer, | intent(inout) | :: | cz | 
 Integer variables cx,cy,cz  | 
        
Subroutine to calculate the distance between the units inside a kohonen layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(inout), | dimension(:,:) | :: | coordinates | 
 A real array  | 
        |
| real(kind=wp), | intent(inout), | dimension(:,:) | :: | distance_matrix | 
 A real array  | 
        |
| character(len=*) | :: | grid_type | 
 A character varaible  | 
        |||
| logical | :: | toroidal | 
 A logical variableS  | 
        
Subroutine to calculate the coordinates of the units inside a kohonen layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | current_index | 
 Integer variables  | 
        ||
| integer, | intent(in) | :: | ix | 
 Integer variables  | 
        ||
| integer, | intent(in) | :: | iy | 
 Integer variables  | 
        ||
| integer, | intent(in) | :: | iz | 
 Integer variables  | 
        ||
| integer, | intent(in) | :: | nx | 
 Integer variables  | 
        ||
| integer, | intent(in) | :: | ny | 
 Integer variables  | 
        ||
| integer, | intent(in) | :: | nz | 
 Integer variables  | 
        ||
| real(kind=wp), | intent(out), | dimension(:,:) | :: | coordinates | 
 Real array  | 
        |
| character(len=*), | intent(in) | :: | node_type | 
 Character variable  | 
        
Subroutine to calculate the best match unit
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| type(kohonen_prototype), | intent(inout) | :: | current_prototype | 
 A   | 
        ||
| integer, | intent(out) | :: | ihit | 
 Integer variables  | 
        ||
| integer, | intent(out) | :: | jhit | 
 Integer variables  | 
        ||
| integer, | intent(out) | :: | khit | 
 Integer variables  | 
        ||
| real(kind=wp), | intent(out) | :: | dist_hit | 
 A real variable  | 
        
Subroutine to update the weights
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| real(kind=wp), | intent(inout), | dimension(:,:) | :: | current_values | 
 A real array  | 
        |
| integer, | intent(inout) | :: | ihit | 
 Integer variables  | 
        ||
| integer, | intent(inout) | :: | jhit | 
 Integer variables  | 
        ||
| integer, | intent(inout) | :: | khit | 
 Integer variables  | 
        ||
| real(kind=wp), | intent(inout) | :: | maximum_radius | 
 A real variable with the maximum radius  | 
        ||
| integer, | intent(inout) | :: | iteration | 
 Integer variables  | 
        
Subroutine to calculate distance between prototypes
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        
Subroutine to calculate the u_matrix
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        
Subroutine to assign input to clusters
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(two_level_self_organizing_map) | :: | kohonen_map | 
 A   | 
        |||
| type(kohonen_pattern), | intent(inout), | dimension(:) | :: | input_patterns | 
 A   | 
        
Subroutine to connect the two_level_self_organizing_map module to R o C Use iso_c_binding module
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=c_double), | intent(in) | :: | x(npat,nvar) | 
 Real variables  | 
        ||
| integer(kind=c_int), | intent(in) | :: | nvar | 
 Integere variables  | 
        ||
| integer(kind=c_int), | intent(in) | :: | npat | 
 Integere variables  | 
        ||
| integer(kind=c_int), | intent(in) | :: | som_type | 
 Integere variables  | 
        ||
| integer(kind=c_int), | intent(in) | :: | nx1 | 
 Integere variables  | 
        ||
| integer(kind=c_int), | intent(in) | :: | ny1 | 
 Integere variables  | 
        ||
| integer(kind=c_int), | intent(in) | :: | nepoch1 | 
 Integere variables  | 
        ||
| real(kind=c_double), | intent(in) | :: | alpha1 | 
 Real variables  | 
        ||
| integer(kind=c_int), | intent(in) | :: | grid_type1 | 
 Integer variables  | 
        ||
| integer(kind=c_int), | intent(in) | :: | distance_type1 | 
 Integer variables  | 
        ||
| integer(kind=c_int), | intent(in) | :: | neigh_type1 | 
 Integer variables  | 
        ||
| integer(kind=c_int), | intent(in) | :: | toroidal1 | 
 Integere variables  | 
        ||
| integer(kind=c_int), | intent(in) | :: | nx2 | 
 Integer variables  | 
        ||
| integer(kind=c_int), | intent(in) | :: | nepoch2 | 
 Integer variables  | 
        ||
| real(kind=c_double), | intent(in) | :: | alpha2 | 
 Real variables  | 
        ||
| integer(kind=c_int), | intent(in) | :: | grid_type2 | 
 Integer variables  | 
        ||
| real(kind=c_double), | intent(out) | :: | prot(nx1*ny1,nvar) | 
 Real variables  | 
        ||
| real(kind=c_double), | intent(out) | :: | distortion(nepoch1) | 
 Real variables  | 
        ||
| real(kind=c_double), | intent(out) | :: | u_matrix(2*nx1-1,2*ny1-1) | 
 Real variables  | 
        ||
| real(kind=c_double), | intent(out) | :: | coords(nx1*ny1,3) | 
 Real variables  | 
        ||
| integer(kind=c_int), | intent(out) | :: | number_patterns(nx1,ny1) | 
 Integer variables  | 
        ||
| integer(kind=c_int), | intent(out) | :: | node_index(npat,3) | 
 Integer variables  |