fsml_nlp Module

Module for nonlinbear procedures.


Uses

  • module~~fsml_nlp~~UsesGraph module~fsml_nlp fsml_nlp module~fsml_con fsml_con module~fsml_nlp->module~fsml_con module~fsml_err fsml_err module~fsml_nlp->module~fsml_err module~fsml_ini fsml_ini module~fsml_nlp->module~fsml_ini module~fsml_lin fsml_lin module~fsml_nlp->module~fsml_lin module~fsml_sts fsml_sts module~fsml_nlp->module~fsml_sts module~fsml_utl fsml_utl module~fsml_nlp->module~fsml_utl module~fsml_con->module~fsml_ini module~fsml_err->module~fsml_con module~fsml_err->module~fsml_ini module~fsml_err->module~fsml_utl iso_fortran_env iso_fortran_env module~fsml_ini->iso_fortran_env stdlib_ansi stdlib_ansi module~fsml_ini->stdlib_ansi stdlib_linalg stdlib_linalg module~fsml_ini->stdlib_linalg module~fsml_lin->module~fsml_con module~fsml_lin->module~fsml_err module~fsml_lin->module~fsml_ini module~fsml_lin->module~fsml_sts module~fsml_lin->module~fsml_utl module~fsml_sts->module~fsml_con module~fsml_sts->module~fsml_err module~fsml_sts->module~fsml_ini module~fsml_sts->module~fsml_utl module~fsml_utl->module~fsml_con module~fsml_utl->module~fsml_ini

Used by

  • module~~fsml_nlp~~UsedByGraph module~fsml_nlp fsml_nlp module~fsml fsml module~fsml->module~fsml_nlp

Subroutines

public impure subroutine s_nlp_hclust(x, nd, nv, nc, gm, cm, cl, cc, cov, sigma)

Impure wrapper procedure for s_nlp_hclust_core.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x(nd,nv)

input data matrix (samples, variables)

integer(kind=i4), intent(in) :: nd

number of data points

integer(kind=i4), intent(in) :: nv

number of variables

integer(kind=i4), intent(in) :: nc

number of clusters (target)

real(kind=wp), intent(out) :: gm(nv)

global means for each variable

real(kind=wp), intent(out) :: cm(nv,nc)

cluster centroids

integer(kind=i4), intent(out) :: cl(nd)

cluster assignments for each data point

integer(kind=i4), intent(out) :: cc(nc)

cluster sizes

real(kind=wp), intent(out) :: cov(nv,nv)

covariance matrix

real(kind=wp), intent(out) :: sigma(nv)

standard deviation per variable

public pure subroutine s_nlp_hclust_core(x, nd, nv, nc, gm, cm, cl, cc, cov, sigma)

Perform agglomerative hierarchical clustering using centroid linkage and the Mahalanobis distance. NOTE: The procedure is exact, but slow for large nd. For most pracitcal purposes, using Lance–Williams algorithm and other distances is advised. TODO: Implement distance switch and L-W algorithm + approx. distance updates.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x(nd,nv)

input data matrix (samples, variables)

integer(kind=i4), intent(in) :: nd

number of data points

integer(kind=i4), intent(in) :: nv

number of variables

integer(kind=i4), intent(in) :: nc

number of clusters (target)

real(kind=wp), intent(out) :: gm(nv)

global means for each variable

real(kind=wp), intent(out) :: cm(nv,nc)

cluster centroids

integer(kind=i4), intent(out) :: cl(nd)

cluster assignments for each data point

integer(kind=i4), intent(out) :: cc(nc)

cluster sizes

real(kind=wp), intent(out) :: cov(nv,nv)

covariance matrix

real(kind=wp), intent(out) :: sigma(nv)

standard deviation per variable

public impure subroutine s_nlp_hkmeans(x, nd, nv, nc, gm, cm, cl, cc, cov, sigma)

Impure wrapper procedure for s_nlp_hkmeans_core.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x(nd,nv)

input data matrix (samples, variables)

integer(kind=i4), intent(in) :: nd

number of data points

integer(kind=i4), intent(in) :: nv

number of variables

integer(kind=i4), intent(in) :: nc

number of clusters (target)

real(kind=wp), intent(out) :: gm(nv)

global means for each variable

real(kind=wp), intent(out) :: cm(nv,nc)

cluster centroids

integer(kind=i4), intent(out) :: cl(nd)

cluster assignments for each data point

integer(kind=i4), intent(out) :: cc(nc)

cluster sizes

real(kind=wp), intent(out) :: cov(nv,nv)

covariance matrix

real(kind=wp), intent(out) :: sigma(nv)

standard deviation per variable

public pure subroutine s_nlp_hkmeans_core(x, nd, nv, nc, gm, cm, cl, cc, cov, sigma)

Perform agglomerative hierarchical clustering using centroid linkage and the Mahalanobis distance, then passes cluster centroids and covariance matrix to kmeans cluster procedure for refinement.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x(nd,nv)

input data matrix (samples, variables)

integer(kind=i4), intent(in) :: nd

number of data points

integer(kind=i4), intent(in) :: nv

number of variables

integer(kind=i4), intent(in) :: nc

number of clusters (target)

real(kind=wp), intent(out) :: gm(nv)

global means for each variable

real(kind=wp), intent(out) :: cm(nv,nc)

cluster centroids

integer(kind=i4), intent(out) :: cl(nd)

cluster assignments for each data point

integer(kind=i4), intent(out) :: cc(nc)

cluster sizes

real(kind=wp), intent(out) :: cov(nv,nv)

covariance matrix

real(kind=wp), intent(out) :: sigma(nv)

standard deviation per variable

public impure subroutine s_nlp_kmeans(x, nd, nv, nc, cm_in, gm, cm, cl, cc, cov, sigma, cov_in)

Impure wrapper procedure for s_nlp_kmeans_core.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x(nd,nv)

raw data (samples, variables)

integer(kind=i4), intent(in) :: nd

number of data points

integer(kind=i4), intent(in) :: nv

number of variables

integer(kind=i4), intent(in) :: nc

number of clusters

real(kind=wp), intent(in) :: cm_in(nv,nc)

initial centroids (raw, not standardised)

real(kind=wp), intent(out) :: gm(nv)

global means

real(kind=wp), intent(out) :: cm(nv,nc)

centroids (refined, standardised)

integer(kind=i4), intent(out) :: cl(nd)

cluster assignments

integer(kind=i4), intent(out) :: cc(nc)

cluster sizes

real(kind=wp), intent(out) :: cov(nv,nv)

covariance matrix

real(kind=wp), intent(out) :: sigma(nv)

standard deviations per variable

real(kind=wp), intent(in), optional :: cov_in(nv,nv)

optional covariance matrix

public pure subroutine s_nlp_kmeans_core(x, nd, nv, nc, cm_in, gm, cm, cl, cc, cov, sigma, cov_in)

K-means clustering using Mahalanobis distance. NOTE: think about only accepting standardised data to avoid redundant computation in successive calls of procedure. This and repeated Cholesky fractionisation are potential performance bottlenecks.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x(nd,nv)

raw data (samples, variables)

integer(kind=i4), intent(in) :: nd

number of data points

integer(kind=i4), intent(in) :: nv

number of variables

integer(kind=i4), intent(in) :: nc

number of clusters

real(kind=wp), intent(in) :: cm_in(nv,nc)

initial centroids (raw, not standardised)

real(kind=wp), intent(out) :: gm(nv)

global means

real(kind=wp), intent(out) :: cm(nv,nc)

centroids (refined, standardised)

integer(kind=i4), intent(out) :: cl(nd)

cluster assignments

integer(kind=i4), intent(out) :: cc(nc)

cluster sizes

real(kind=wp), intent(out) :: cov(nv,nv)

covariance matrix

real(kind=wp), intent(out) :: sigma(nv)

standard deviations per variable

real(kind=wp), intent(in), optional :: cov_in(nv,nv)

optional covariance matrix