Module for nonlinbear procedures.
Impure wrapper procedure for s_nlp_hclust_core
.
Type | Intent | Optional | 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 |
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.
Type | Intent | Optional | 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 |
Impure wrapper procedure for s_nlp_hkmeans_core
.
Type | Intent | Optional | 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 |
Perform agglomerative hierarchical clustering using centroid linkage and the Mahalanobis distance, then passes cluster centroids and covariance matrix to kmeans cluster procedure for refinement.
Type | Intent | Optional | 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 |
Impure wrapper procedure for s_nlp_kmeans_core
.
Type | Intent | Optional | 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 |
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.
Type | Intent | Optional | 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 |