Clustering

Binder Notebook

Summary: this tutorial demonstrates several clustering methods in FSharp.Stats and how to visualize the results with Plotly.NET.

Table of contents

Clustering methods can be used to group elements of a huge data set based on their similarity. Elements sharing similar properties cluster together and can be reported as coherent group.

Column wise standardization

Please note that in many cases a column-wise (also called feature-wise) standardization is required. If the average amplitude and variance of the features differ, perform a z-transform or scaling between 0 and 1.

Row wise standardization

Additionally, for e.g. gene expression or protein accumulation data where change rather than amplitude is of interest, a row wise standardization is often applied:

  1. Adaptive quality-based clustering of gene expression profiles, Smet et al., 2001

    It is common practice to normalize gene expression vectors before cluster analysis. In this paper, we normalize the expression profiles so that their mean is zero and their variance is one before proceeding with the actual cluster algorithm.

  2. CLICK: A Clustering Algorithm with Applications to Gene Expression Analysis, Sharan et al., 200

    Common procedures for normalizing fingerprint data include transforming each fingerprint to have mean zero and variance one

  3. Systematic determination of genetic network architecture, Tavazoie et al., 1999

    The data matrix was then transformed such that the variance of each gene was normalized across the 15 conditions. This was done by subtracting its mean across the time points from the expression level of each gene, and dividing by the standard deviation across the time points.

For demonstration of several clustering methods, the classic iris data set is used, which consists of 150 records, each of which contains four measurements and a species identifier. Since the species identifier occur several times (Iris-virginica, Iris-versicolor, and Iris-setosa), the first step is to generate unique labels:

  • The data is shuffled and an index is appended to the data label, such that each label is unique.
open Plotly.NET
open FSharp.Stats

let fromFileWithSep (separator:char) (filePath) =     
    // The function is implemented using a sequence expression
    seq {   let sr = System.IO.File.OpenText(filePath)
            while not sr.EndOfStream do 
                let line = sr.ReadLine() 
                let words = line.Split separator//[|',';' ';'\t'|] 
                yield words }

                
let lables,data =
    fromFileWithSep ',' (__SOURCE_DIRECTORY__ + "/data/irisData.csv")
    |> Seq.skip 1
    |> Seq.map (fun arr -> arr.[4], [| float arr.[0]; float arr.[1]; float arr.[2]; float arr.[3]; |])
    |> Seq.toArray
    |> Array.shuffleFisherYates
    |> Array.mapi (fun i (lable,data) -> sprintf "%s_%i" lable i, data)
    |> Array.unzip
   

let's first take a look at the dataset with Plotly.NET:

open Plotly.NET

let colnames = ["Sepal length";"Sepal width";"Petal length";"Petal width"]

let colorscaleValue = 
    StyleParam.Colorscale.Electric //Custom [(0.0,"#3D9970");(1.0,"#001f3f")]
    
let dataChart = 
    Chart.Heatmap(data,colNames=colnames,rowNames=(lables |> Seq.mapi (fun i s -> sprintf "%s%i" s i )),ColorScale=colorscaleValue,ShowScale=true)
    |> Chart.withMarginSize(Left=250.)
    |> Chart.withTitle "raw iris data"

Iterative Clustering

k-means clustering

In k-means clustering a cluster number has to be specified prior to clustering the data. K centroids are randomly chosen. After all data points are assigned to their nearest centroid, the algorithm iteratively approaches a centroid position configuration, that minimizes the dispersion of every of the k clusters. For cluster number determination see below (Determining the optimal number of clusters).

Further information can be found here.

open FSharp.Stats.ML.Unsupervised
open FSharp.Stats.ML.Unsupervised.HierarchicalClustering

// Kmeans clustering

// For random cluster inititalization use randomInitFactory:
let rnd = new System.Random()
let randomInitFactory : IterativeClustering.CentroidsFactory<float []> = 
    IterativeClustering.randomCentroids<float []> rnd

//let cvmaxFactory : IterativeClustering.CentroidsFactory<float []> = 
//    IterativeClustering.initCVMAX
  
let kmeansResult = 
    IterativeClustering.kmeans <| DistanceMetrics.euclidean <| randomInitFactory 
    <| data <| 4

let clusteredIrisData =
    Array.zip lables data
    |> Array.sortBy (fun (l,dataPoint) -> fst (kmeansResult.Classifier dataPoint)) 
    |> Array.unzip
    |> fun (labels,d) -> 
        Chart.Heatmap(d,colNames=colnames,rowNames=labels,ColorScale=colorscaleValue,ShowScale=true)
        |> Chart.withMarginSize(Left=250.)
        |> Chart.withTitle "clustered iris data (k-means clustering)"
// To get the best kMeans clustering result in terms of the average squared distance of each point
// to its centroid, perform the clustering b times and minimize the dispersion.
let getBestkMeansClustering data k bootstraps =
    [1..bootstraps]
    |> List.mapi (fun i x -> 
        IterativeClustering.kmeans <| DistanceMetrics.euclidean <| randomInitFactory <| data <| k
        )
    |> List.minBy (fun clusteringResult -> IterativeClustering.DispersionOfClusterResult clusteringResult)

Density based clustering

DBSCAN

Further information can be found here.

//four dimensional clustering with sepal length, petal length, sepal width and petal width
let t = DbScan.compute DistanceMetrics.Array.euclideanNaN 5 1.0 data

//extract petal length and petal width
let petLpetW      = data |> Array.map (fun x -> [|x.[2];x.[3]|])

//extract petal width, petal length and sepal length  
let petWpetLsepL = data |> Array.map (fun x -> [|x.[3];x.[2];x.[0]|])

//to create a chart with two dimensional data use the following function
let dbscanPlot =  

    if (petLpetW |> Seq.head |> Seq.length) <> 2 then failwithf "create2dChart only can handle 2 coordinates"
    
    let result = DbScan.compute DistanceMetrics.Array.euclidean 20 0.5 petLpetW
    
    let chartCluster = 
        if result.Clusterlist |> Seq.length > 0 then      
            result.Clusterlist
            |> Array.ofSeq
            |> Array.mapi (fun i l ->
                l
                |> Array.ofSeq
                |> Array.map (fun x -> 
                    x.[0],x.[1])
                |> Array.distinct //more efficient visualization; no difference in plot but in point numbers
                |> Chart.Point 
                |> Chart.withTraceInfo (sprintf "Cluster %i" i)
                )
            |> Chart.combine
        else Chart.Point []

    let chartNoise = 
        if result.Noisepoints |> Seq.length > 0 then 
            result.Noisepoints
            |> Seq.map (fun x -> x.[0],x.[1])  
            |> Seq.distinct //more efficient visualization; no difference in plot but in point numbers
            |> Chart.Point
            |> Chart.withTraceInfo "Noise"
        else Chart.Point []

    let chartname = 
        let noiseCount    = result.Noisepoints |> Seq.length
        let clusterCount  = result.Clusterlist |> Seq.length
        let clPtsCount    = result.Clusterlist |> Seq.sumBy Seq.length
        sprintf "eps:%.1f minPts:%i pts:%i cluster:%i noisePts:%i" 
            0.5 20 (noiseCount + clPtsCount) clusterCount noiseCount 

    [chartNoise;chartCluster]
    |> Chart.combine
    |> Chart.withTitle chartname
    |> Chart.withTemplate ChartTemplates.lightMirrored
    |> Chart.withXAxisStyle "Petal width"
    |> Chart.withYAxisStyle "Petal length"
    
//to create a chart with three dimensional data use the following function
let create3dChart (dfu:array<'a> -> array<'a> -> float) (minPts:int) (eps:float) (input:seq<#seq<'a>>) =   

    if (input |> Seq.head |> Seq.length) <> 3 then failwithf "create3dChart only can handle 3 coordinates"
    
    let result = DbScan.compute dfu minPts eps input
    
    let chartCluster = 
        if result.Clusterlist |> Seq.length > 0 then 
            result.Clusterlist
            |> Seq.mapi (fun i l ->
                l
                |> Seq.map (fun x -> x.[0],x.[1],x.[2])
                |> Seq.distinct //faster visualization; no difference in plot but in point number
                |> fun x -> Chart.Scatter3D (x,StyleParam.Mode.Markers)
                |> Chart.withTraceInfo (sprintf "Cluster_%i" i))
            |> Chart.combine
        else  Chart.Scatter3D ([],StyleParam.Mode.Markers)

    let chartNoise =
        if result.Noisepoints |> Seq.length > 0 then 
            result.Noisepoints
            |> Seq.map (fun x -> x.[0],x.[1],x.[2])  
            |> Seq.distinct //faster visualization; no difference in plot but in point number
            |> fun x -> Chart.Scatter3D (x,StyleParam.Mode.Markers)
            |> Chart.withTraceInfo "Noise"
        else Chart.Scatter3D ([],StyleParam.Mode.Markers)

    let chartname = 
        let noiseCount    = result.Noisepoints |> Seq.length
        let clusterCount  = result.Clusterlist |> Seq.length
        let clPtsCount    = result.Clusterlist |> Seq.sumBy Seq.length
        sprintf "eps:%.1f minPts:%i n:%i Cluster:%i NoisePts:%i" 
            eps minPts (noiseCount + clPtsCount) clusterCount noiseCount 

    [chartNoise;chartCluster]
    |> Chart.combine
    |> Chart.withTitle chartname
    |> Chart.withTemplate ChartTemplates.lightMirrored
    |> Chart.withXAxisStyle ("Petal width", Id = StyleParam.SubPlotId.Scene 1)
    |> Chart.withYAxisStyle ("Petal length", Id = StyleParam.SubPlotId.Scene 1)
    |> Chart.withYAxisStyle "Sepal length"
        
//for faster computation you can use the squaredEuclidean distance and set your eps to its square
let clusteredChart3D = create3dChart DistanceMetrics.Array.euclideanNaNSquared 20 (0.7**2.) petWpetLsepL 

Hierarchical Clustering

Clustering is grouping based on similarity to form coherent groups. The similarity is determined by measurements, for example gene expression kinetics in time series. The similarity between single entitites is then determined and they are grouped by that properties.

Hierarchical Clustering (hClust) can be performed in two ways:

  • Divisive hClust: top down approach, starts with every entity in one cluster and successively splits it into smaller groups based on their similiarity.
  • Agglomerative hClust: bottom up approach, every entity is a single cluster in the beginning, and the closest entities are merged.

Here, we implemented the agglomerative hClust approach. The result of hierarchical Clustering is one big cluster with a tree structure, that is connected by the root. From the root, it splits recursively into clusters that are more similar to each other than to elements of other clusters. The advantage of hClust in comparison to other clustering algorithm is that you don't need to specify a number of clusters beforehand. When clustering, the whole dataset is clustered once and can be split into groups either by defining a number of clusters (similar to k-means) or by specifying a similarity cutoff.

Further information can be found here.

Distance measures

To determine the similarity between entities it is necessary to have a distance measure. For those distance measures we need to know the two types of points we're dealing with: Singletons and Clusters. To calculate the distance between Singletons (single entities), we use the euclidean distance. This can be switched to different distance functions (see DistanceMetrics). For example, we look at the points with their respective features X and Y. Their distance is calculated with this formula (euclidean distance):

\[ x : [x1, x2, .., xn] \]

\[ y : [y1, y2, .., yn] \]

\[ d(x, y) = \sqrt{((x1 - y1)^2 + (x2 - y2)^2 + ... + (xn - yn)^2)} \]

Linkages

When calculating the similarity between two entities, where at least one is an already formed cluster, there is the need for a linker instead of the basic distance function. A few options are listed here:

  • complete linkage: maximal pairwise distance between the clusters (prone to break large clusters)

  • single linkage: minimal pairwise distance between the clusters (sensitive to outliers)

  • centroid linkage: distance between the two cluster centroids

  • average linkage: average pairwise distance between the clusters (sensitive to cluster shape and size)

  • median linkage: median pairwise distance between the clusters

open FSharp.Stats.ML.Unsupervised.HierarchicalClustering
open Priority_Queue
// calculates the clustering and reports a single root cluster (node), 
// that may recursively contains further nodes
let distance = DistanceMetrics.euclidean
let linker = Linker.wardLwLinker

// calculates the clustering and reports a single root cluster (node)
let result = generate<float[]> distance linker data |> Seq.item 0 |> (fun x -> x.Key)

// If a desired cluster number is specified, the following function cuts the cluster according
// to the depth, that results in the respective number of clusters (here 3). Only leaves are reported.
let threeClustersH = cutHClust 3 result

Every cluster leaf contains its raw values and an index that indicates the position of the respective data point in the raw data. The index can be retrieved from leaves by HierarchicalClustering.getClusterId.

let inspectThreeClusters =
    threeClustersH
    |> List.map (fun cluster -> 
        cluster
        |> List.map (fun leaf -> 
            lables.[getClusterId leaf]
            )
        )
    |> fun clusteredLabels -> 
        sprintf "Detailed information for %i clusters is given:" clusteredLabels.Length,clusteredLabels
("Detailed information for 3 clusters is given:",
 [["Iris-versicolor_31"; "Iris-versicolor_71"; "Iris-versicolor_83";
   "Iris-versicolor_122"; "Iris-versicolor_64"; "Iris-versicolor_56";
   "Iris-versicolor_50"; "Iris-versicolor_82"; "Iris-versicolor_52";
   "Iris-versicolor_55"; "Iris-versicolor_102"; "Iris-versicolor_10";
   "Iris-versicolor_37"; "Iris-versicolor_124"; "Iris-versicolor_73";
   "Iris-versicolor_131"; "Iris-virginica_39"; "Iris-versicolor_75";
   "Iris-versicolor_96"; "Iris-versicolor_6"; "Iris-versicolor_141";
   "Iris-versicolor_22"; "Iris-versicolor_89"; "Iris-versicolor_127";
   "Iris-versicolor_98"; "Iris-versicolor_146"; "Iris-versicolor_46";
   "Iris-versicolor_87"; "Iris-versicolor_114"; "Iris-versicolor_17";
   "Iris-versicolor_53"; "Iris-versicolor_2"; "Iris-versicolor_95";
   "Iris-versicolor_77"; "Iris-versicolor_85"; "Iris-versicolor_123";
   "Iris-versicolor_137"; "Iris-versicolor_63"; "Iris-versicolor_33";
   "Iris-versicolor_115"; "Iris-versicolor_23"; "Iris-versicolor_128";
   "Iris-versicolor_19"; "Iris-versicolor_24"; "Iris-versicolor_61";
   "Iris-versicolor_138"; "Iris-virginica_11"; "Iris-virginica_3";
   "Iris-virginica_27"; "Iris-virginica_9"; "Iris-versicolor_100";
   "Iris-virginica_68"; "Iris-versicolor_113"; "Iris-versicolor_134";
   "Iris-versicolor_143"; "Iris-virginica_72"; "Iris-virginica_12";
   "Iris-virginica_105"; "Iris-virginica_97"; "Iris-virginica_148";
   "Iris-virginica_35"; "Iris-versicolor_88"; "Iris-virginica_107";
   "Iris-virginica_147"];
  ["Iris-virginica_13"; "Iris-virginica_51"; "Iris-virginica_15";
   "Iris-virginica_78"; "Iris-virginica_42"; "Iris-virginica_36";
   "Iris-virginica_130"; "Iris-virginica_74"; "Iris-virginica_92";
   "Iris-virginica_108"; "Iris-virginica_29"; "Iris-virginica_132";
   "Iris-virginica_67"; "Iris-virginica_110"; "Iris-virginica_133";
   "Iris-virginica_0"; "Iris-virginica_4"; "Iris-virginica_28";
   "Iris-virginica_86"; "Iris-virginica_44"; "Iris-virginica_126";
   "Iris-virginica_43"; "Iris-virginica_48"; "Iris-virginica_7";
   "Iris-virginica_93"; "Iris-virginica_45"; "Iris-virginica_120";
   "Iris-virginica_84"; "Iris-virginica_38"; "Iris-virginica_47";
   "Iris-virginica_118"; "Iris-virginica_116"; "Iris-virginica_59";
   "Iris-virginica_117"; "Iris-virginica_104"; "Iris-virginica_139"];
  ["Iris-setosa_90"; "Iris-setosa_14"; "Iris-setosa_25"; "Iris-setosa_129";
   "Iris-setosa_135"; "Iris-setosa_5"; "Iris-setosa_30"; "Iris-setosa_34";
   "Iris-setosa_145"; "Iris-setosa_70"; "Iris-setosa_60"; "Iris-setosa_101";
   "Iris-setosa_94"; "Iris-setosa_112"; "Iris-setosa_49"; "Iris-setosa_58";
   "Iris-setosa_106"; "Iris-setosa_21"; "Iris-setosa_103"; "Iris-setosa_144";
   "Iris-setosa_16"; "Iris-setosa_57"; "Iris-setosa_32"; "Iris-setosa_76";
   "Iris-setosa_69"; "Iris-setosa_20"; "Iris-setosa_79"; "Iris-setosa_18";
   "Iris-setosa_91"; "Iris-setosa_26"; "Iris-setosa_40"; "Iris-setosa_41";
   "Iris-setosa_80"; "Iris-setosa_121"; "Iris-setosa_66"; "Iris-setosa_99";
   "Iris-setosa_8"; "Iris-setosa_65"; "Iris-setosa_140"; "Iris-setosa_111";
   "Iris-setosa_136"; "Iris-setosa_62"; "Iris-setosa_109"; "Iris-setosa_81";
   "Iris-setosa_125"; "Iris-setosa_142"; "Iris-setosa_119"; "Iris-setosa_54";
   "Iris-setosa_1"; "Iris-setosa_149"]])
    
// To recursevely flatten the cluster tree into leaves only, use flattenHClust.
// A leaf list is reported, that does not contain any cluster membership, 
// but is sorted by the clustering result.
let hLeaves = 
    result
    |> HierarchicalClustering.flattenHClust
    
// takes the sorted cluster result and reports a tuple of lable and data value.
let dataSortedByClustering =    
    hLeaves
    |> List.choose (fun c -> 
        let lable  = lables.[HierarchicalClustering.getClusterId c]
        let values = HierarchicalClustering.tryGetLeafValue c
        match values with
        | None -> None
        | Some x -> Some (lable,x)
        )

let hierClusteredDataHeatmap = 
    let (hlable,hdata) =
        dataSortedByClustering
        |> List.unzip
    Chart.Heatmap(hdata,colNames=colnames,rowNames=hlable,ShowScale=true)
    |> Chart.withMarginSize(Left=250.)
    |> Chart.withTitle "Clustered iris data (hierarchical clustering)"
    

Determining the optimal number of clusters

Rule of thumb

The rule of thumb is a very crude cluster number estimation only based on the number of data points.

Reference: 'Review on Determining of Cluster in K-means Clustering'; Kodinariya et al; January 2013

//optimal k for iris data set by using rule-of-thumb
let ruleOfThumb = ClusterNumber.kRuleOfThumb data
8.660254038

Elbow criterion

The elbow criterion is a visual method to determine the optimal cluster number. The cluster dispersion is measured as the sum of all average (squared) euclidean distance of each point to its associated centroid. The point at which the dispersion drops drastically and further increase in k does not lead to a strong decrease in dispersion is the optimal k.

Reference: 'Review on Determining of Cluster in K-means Clustering'; Kodinariya et al; January 2013

open IterativeClustering
open DistanceMetrics

let kElbow = 10

let iterations = 10 

let dispersionOfK = 
    [|1..kElbow|]
    |> Array.map (fun k -> 
        let (dispersion,std) = 
            [|1..iterations|]
            |> Array.map (fun i -> 
                kmeans euclideanNaNSquared (randomCentroids rnd) data k
                |> DispersionOfClusterResult)
            |> fun dispersions -> 
                Seq.mean dispersions, Seq.stDev dispersions
        k,dispersion,std
        )

let elbowChart = 

    Chart.Line (dispersionOfK |> Array.map (fun (k,dispersion,std) -> k,dispersion))
    |> Chart.withYErrorStyle (Array=(dispersionOfK |> Array.map (fun (k,dispersion,std) -> std)))
    |> Chart.withTemplate ChartTemplates.lightMirrored
    |> Chart.withXAxisStyle "k"
    |> Chart.withYAxisStyle "dispersion"
    |> Chart.withTitle "Iris data set dispersion"

AIC

Reference

The Akaike information criterion (AIC) balances the information gain (with raising k) against parameter necessity (number of k). The k that minimizes the AIC is assumed to be the optimal one.

let aicBootstraps = 10

//optimal k for iris data set by using aic
let (aicK,aicMeans,aicStd) =
    //perform 10 iterations and take the mean and standard deviation of the aic
    let aic = 
        [|1..aicBootstraps|]
        |> Array.map (fun b -> ClusterNumber.calcAIC 10 (kmeans euclideanNaNSquared (randomCentroids rnd) data) 15)
    aic
    |> Array.map (fun iteration -> Array.map snd iteration)
    |> JaggedArray.transpose
    |> Array.mapi (fun i aics -> 
        i+1,Seq.mean aics,Seq.stDev aics)
    |> Array.unzip3

let aicChart = 
    Chart.Line (aicK,aicMeans)
    |> Chart.withTemplate ChartTemplates.lightMirrored
    |> Chart.withXAxisStyle "k"
    |> Chart.withYAxisStyle "AIC"
    |> Chart.withYErrorStyle (Array=aicStd)

Silhouette coefficient

The silhouette index ranges from -1 to 1, where -1 indicates a misclassified point, and 1 indicates a perfect fit. It can be calculated for every point by comparing the mean intra cluster distance with the nearest mean inter cluster distance. The mean of all indices can be visualized, where a maximal value indicates the optimal k.

Reference: 'Review on Determining of Cluster in K-means Clustering'; Kodinariya et al; January 2013

// The following example expects the raw data to be clustered by k means clustering.
// If you already have clustered data use the 'silhouetteIndex' function instead.

let silhouetteData = 
    System.IO.File.ReadAllLines(__SOURCE_DIRECTORY__ + "/data/silhouetteIndexData.txt")
    |> Array.map (fun x -> 
        let tmp = x.Split '\t'
        [|float tmp.[0]; float tmp.[1]|])

let sI = 
    ML.Unsupervised.ClusterNumber.silhouetteIndexKMeans 
        50              // number of bootstraps 
        (kmeans euclideanNaNSquared (randomCentroids rnd) silhouetteData) 
        silhouetteData  // input data
        15              // maximal number of allowed k

let rawDataChart =
    silhouetteData 
    |> Array.map (fun x -> x.[0],x.[1])
    |> Chart.Point

let silhouetteIndicesChart =
    Chart.Line (sI |> Array.map (fun x -> x.ClusterNumber,x.SilhouetteIndex))
    |> Chart.withYErrorStyle (Array=(sI |> Array.map (fun x -> x.SilhouetteIndexStDev)))

let combinedSilhouette =

    [
    rawDataChart |> Chart.withTemplate ChartTemplates.lightMirrored |> Chart.withTraceInfo "raw data"
    silhouetteIndicesChart 
    |> Chart.withTemplate ChartTemplates.lightMirrored
    |> Chart.withXAxisStyle "k"
    |> Chart.withYAxisStyle "silhouette index" |> Chart.withTraceInfo "silhouette"
    ]
    |> Chart.Grid(1,2)

GapStatistics

Reference: 'Estimating the number of clusters in a data set via the gap statistic'; J. R. Statist. Soc. B (2001); Tibshirani, Walther, and Hastie

Gap statistics allows to determine the optimal cluster number by comparing the cluster dispersion (intra-cluster variation) of a reference dataset to the original data cluster dispersion. For each k both dispersions are calculated, while for the reference dataset multiple iterations are performed for each k. The difference of the log(dispersionOriginal) and the log(dispersionReference) is called 'gap'. The maximal gap points to the optimal cluster number.

Two ways to generate a reference data set are implemented.

  • a uniform coverage within the range of the original data set
  • a PCA based point coverage, that considers the density/shape of the original data
let gapStatisticsData = 
    System.IO.File.ReadAllLines(__SOURCE_DIRECTORY__ + "/data/gapStatisticsData.txt")
    |> Array.map (fun x ->
        let tmp = x.Split '\t'
        tmp |> Array.map float)

let gapDataChart = 

    [
    gapStatisticsData|> Array.map (fun x -> x.[0],x.[1]) |> Chart.Point |> Chart.withTraceInfo "original" |> Chart.withXAxisStyle (MinMax=(-4.,10.)) |> Chart.withYAxisStyle (MinMax=(-2.5,9.))
    (GapStatistics.PointGenerators.generateUniformPoints rnd gapStatisticsData) |> Array.map (fun x -> x.[0],x.[1]) |> Chart.Point |> Chart.withTraceInfo "uniform" |> Chart.withXAxisStyle (MinMax=(-4.,10.)) |> Chart.withYAxisStyle (MinMax=(-2.5,9.))
    (GapStatistics.PointGenerators.generateUniformPointsPCA rnd gapStatisticsData) |> Array.map (fun x -> x.[0],x.[1]) |> Chart.Point |> Chart.withTraceInfo "uniform PCA" |> Chart.withXAxisStyle (MinMax=(-4.,10.)) |> Chart.withYAxisStyle (MinMax=(-2.5,9.))
    ]
    |> Chart.Grid(1,3)
    |> Chart.withSize(800.,400.)
    

The log(dispersionReference) should decrease with rising k, but - if clusters are present in the data - should be greater than the log(dispersionOriginal).

open GapStatistics

//create gap statistics
let gaps =
    GapStatistics.calculate
        (PointGenerators.generateUniformPointsPCA rnd)      //uniform point distribution
        100// no gain above 500                                //number of bootstraps samples 
        ClusterDispersionMetric.logDispersionKMeansInitRandom //dispersion metric of clustering algorithm
        10                                                     //maximal number of allowed clusters
        gapStatisticsData                                      //float [] [] data of coordinates

//number of clusters        
let k        = gaps |> Array.map (fun x -> x.ClusterIndex)
//log(dispersion) of the original data (with rising k)
let disp     = gaps |> Array.map (fun x -> x.Dispersion)
//log(dispersion) of the reference data (with rising k)
let dispRef = gaps |> Array.map (fun x -> x.ReferenceDispersion)
//log(dispersionRef) - log(dispersionOriginal)
let gap      = gaps |> Array.map (fun x -> x.Gaps)
//standard deviation of reference data set dispersion
let std      = gaps |> Array.map (fun x -> x.RefDispersionStDev)

let gapStatisticsChart =

    let dispersions =
        [
        Chart.Line (k,disp)    |> Chart.withTraceInfo "disp"
        Chart.Line (k,dispRef)|> Chart.withTraceInfo "dispRef" |> Chart.withYErrorStyle(Array=std)
        ]
        |> Chart.combine     
        |> Chart.withTemplate ChartTemplates.lightMirrored
        |> Chart.withYAxisStyle "log(disp)"
    let gaps = 
        Chart.Line (k,gap)|> Chart.withTraceInfo "gaps"    
        |> Chart.withTemplate ChartTemplates.lightMirrored
        |> Chart.withXAxisStyle "k"
        |> Chart.withYAxisStyle "gaps"
    [dispersions; gaps]
    |> Chart.Grid(2,1)

The maximal gap points to the optimal cluster number with the following condition:

  • kopt = smallest k such that Gap(k)>= Gap(k+1)-sk+1
  • where sk = std * sqrt(1+1/bootstraps)
//calculate s(k) out of std(k) and the number of performed iterations for the refernce data set
let sK   = std |> Array.map (fun sd -> sd * sqrt(1. + 1./500.)) //bootstraps = 500 

let gapChart =

    Chart.Line (k,gap)
    |> Chart.withYErrorStyle(Array=sK)
    |> Chart.withTemplate ChartTemplates.lightMirrored
    |> Chart.withXAxisStyle "k"
    |> Chart.withYAxisStyle "gaps"
    
//choose kOpt = smallest k such that Gap(k)>= Gap(k+1)-sk+1, where sk = sdk * sqrt(1+1/bootstraps)
let kOpt = 
    Array.init (gap.Length - 2) (fun i -> gap.[i] >= gap.[i+1] - sK.[i+1])
    |> Array.findIndex id
    |> fun x -> sprintf "The optimal cluster number is: %i" (x + 1)
    
"The optimal cluster number is: 2"
namespace Plotly
namespace Plotly.NET
module Defaults from Plotly.NET
<summary> Contains mutable global default values. Changing these values will apply the default values to all consecutive Chart generations. </summary>
val mutable DefaultDisplayOptions: DisplayOptions
Multiple items
type DisplayOptions = inherit DynamicObj new: unit -> DisplayOptions static member addAdditionalHeadTags: additionalHeadTags: XmlNode list -> (DisplayOptions -> DisplayOptions) static member addDescription: description: XmlNode list -> (DisplayOptions -> DisplayOptions) static member combine: first: DisplayOptions -> second: DisplayOptions -> DisplayOptions static member getAdditionalHeadTags: displayOpts: DisplayOptions -> XmlNode list static member getDescription: displayOpts: DisplayOptions -> XmlNode list static member getPlotlyReference: displayOpts: DisplayOptions -> PlotlyJSReference static member init: ?AdditionalHeadTags: XmlNode list * ?Description: XmlNode list * ?PlotlyJSReference: PlotlyJSReference -> DisplayOptions static member initCDNOnly: unit -> DisplayOptions ...

--------------------
new: unit -> DisplayOptions
static member DisplayOptions.init: ?AdditionalHeadTags: Giraffe.ViewEngine.HtmlElements.XmlNode list * ?Description: Giraffe.ViewEngine.HtmlElements.XmlNode list * ?PlotlyJSReference: PlotlyJSReference -> DisplayOptions
type PlotlyJSReference = | CDN of string | Full | Require of string | NoReference
<summary> Sets how plotly is referenced in the head of html docs. </summary>
union case PlotlyJSReference.NoReference: PlotlyJSReference
Multiple items
namespace FSharp

--------------------
namespace Microsoft.FSharp
namespace FSharp.Stats
val fromFileWithSep: separator: char -> filePath: string -> seq<string[]>
val separator: char
Multiple items
val char: value: 'T -> char (requires member op_Explicit)
<summary>Converts the argument to character. Numeric inputs are converted according to the UTF-16 encoding for characters. String inputs must be exactly one character long. For other input types the operation requires an appropriate static conversion method on the input type.</summary>
<param name="value">The input value.</param>
<returns>The converted char.</returns>
<example id="char-example"><code lang="fsharp"></code></example>


--------------------
[<Struct>] type char = System.Char
<summary>An abbreviation for the CLI type <see cref="T:System.Char" />.</summary>
<category>Basic Types</category>
val filePath: string
Multiple items
val seq: sequence: seq<'T> -> seq<'T>
<summary>Builds a sequence using sequence expression syntax</summary>
<param name="sequence">The input sequence.</param>
<returns>The result sequence.</returns>
<example id="seq-cast-example"><code lang="fsharp"> seq { for i in 0..10 do yield (i, i*i) } </code></example>


--------------------
type seq<'T> = System.Collections.Generic.IEnumerable<'T>
<summary>An abbreviation for the CLI type <see cref="T:System.Collections.Generic.IEnumerable`1" /></summary>
<remarks> See the <see cref="T:Microsoft.FSharp.Collections.SeqModule" /> module for further operations related to sequences. See also <a href="https://docs.microsoft.com/dotnet/fsharp/language-reference/sequences">F# Language Guide - Sequences</a>. </remarks>
val sr: System.IO.StreamReader
namespace System
namespace System.IO
type File = static member AppendAllLines: path: string * contents: IEnumerable<string> -> unit + 1 overload static member AppendAllLinesAsync: path: string * contents: IEnumerable<string> * encoding: Encoding * ?cancellationToken: CancellationToken -> Task + 1 overload static member AppendAllText: path: string * contents: string -> unit + 1 overload static member AppendAllTextAsync: path: string * contents: string * encoding: Encoding * ?cancellationToken: CancellationToken -> Task + 1 overload static member AppendText: path: string -> StreamWriter static member Copy: sourceFileName: string * destFileName: string -> unit + 1 overload static member Create: path: string -> FileStream + 2 overloads static member CreateSymbolicLink: path: string * pathToTarget: string -> FileSystemInfo static member CreateText: path: string -> StreamWriter static member Decrypt: path: string -> unit ...
<summary>Provides static methods for the creation, copying, deletion, moving, and opening of a single file, and aids in the creation of <see cref="T:System.IO.FileStream" /> objects.</summary>
System.IO.File.OpenText(path: string) : System.IO.StreamReader
property System.IO.StreamReader.EndOfStream: bool with get
<summary>Gets a value that indicates whether the current stream position is at the end of the stream.</summary>
<exception cref="T:System.ObjectDisposedException">The underlying stream has been disposed.</exception>
<returns><see langword="true" /> if the current stream position is at the end of the stream; otherwise <see langword="false" />.</returns>
val line: string
System.IO.StreamReader.ReadLine() : string
val words: string[]
System.String.Split([<System.ParamArray>] separator: char[]) : string[]
System.String.Split(separator: string[], options: System.StringSplitOptions) : string[]
System.String.Split(separator: string, ?options: System.StringSplitOptions) : string[]
System.String.Split(separator: char[], options: System.StringSplitOptions) : string[]
System.String.Split(separator: char[], count: int) : string[]
System.String.Split(separator: char, ?options: System.StringSplitOptions) : string[]
System.String.Split(separator: string[], count: int, options: System.StringSplitOptions) : string[]
System.String.Split(separator: string, count: int, ?options: System.StringSplitOptions) : string[]
System.String.Split(separator: char[], count: int, options: System.StringSplitOptions) : string[]
System.String.Split(separator: char, count: int, ?options: System.StringSplitOptions) : string[]
val lables: string[]
val data: float[][]
Multiple items
module Seq from FSharp.Stats
<summary> Module to compute common statistical measure </summary>

--------------------
module Seq from Microsoft.FSharp.Collections
<summary>Contains operations for working with values of type <see cref="T:Microsoft.FSharp.Collections.seq`1" />.</summary>

--------------------
type Seq = new: unit -> Seq static member geomspace: start: float * stop: float * num: int * ?IncludeEndpoint: bool -> seq<float> static member linspace: start: float * stop: float * num: int * ?IncludeEndpoint: bool -> seq<float>

--------------------
new: unit -> Seq
val skip: count: int -> source: seq<'T> -> seq<'T>
<summary>Returns a sequence that skips N elements of the underlying sequence and then yields the remaining elements of the sequence.</summary>
<param name="count">The number of items to skip.</param>
<param name="source">The input sequence.</param>
<returns>The result sequence.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input sequence is null.</exception>
<exception cref="T:System.InvalidOperationException">Thrown when count exceeds the number of elements in the sequence.</exception>
<example id="skip-1"><code lang="fsharp"> let inputs = ["a"; "b"; "c"; "d"] inputs |&gt; Seq.skip 2 </code> Evaluates a sequence yielding the same results as <c>seq { "c"; "d" }</c></example>
<example id="skip-2"><code lang="fsharp"> let inputs = ["a"; "b"; "c"; "d"] inputs |&gt; Seq.skip 5 </code> Throws <c>ArgumentException</c>. </example>
<example id="skip-3"><code lang="fsharp"> let inputs = ["a"; "b"; "c"; "d"] inputs |&gt; Seq.skip -1 </code> Evaluates a sequence yielding the same results as <c>seq { "a"; "b"; "c"; "d" }</c>. </example>
val map: mapping: ('T -> 'U) -> source: seq<'T> -> seq<'U>
<summary>Builds a new collection whose elements are the results of applying the given function to each of the elements of the collection. The given function will be applied as elements are demanded using the <c>MoveNext</c> method on enumerators retrieved from the object.</summary>
<remarks>The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed concurrently.</remarks>
<param name="mapping">A function to transform items from the input sequence.</param>
<param name="source">The input sequence.</param>
<returns>The result sequence.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input sequence is null.</exception>
<example id="item-1"><code lang="fsharp"> let inputs = ["a"; "bbb"; "cc"] inputs |&gt; Seq.map (fun x -&gt; x.Length) </code> Evaluates to a sequence yielding the same results as <c>seq { 1; 3; 2 }</c></example>
val arr: string[]
Multiple items
val float: value: 'T -> float (requires member op_Explicit)
<summary>Converts the argument to 64-bit float. This is a direct conversion for all primitive numeric types. For strings, the input is converted using <c>Double.Parse()</c> with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.</summary>
<param name="value">The input value.</param>
<returns>The converted float</returns>
<example id="float-example"><code lang="fsharp"></code></example>


--------------------
[<Struct>] type float = System.Double
<summary>An abbreviation for the CLI type <see cref="T:System.Double" />.</summary>
<category>Basic Types</category>


--------------------
type float<'Measure> = float
<summary>The type of double-precision floating point numbers, annotated with a unit of measure. The unit of measure is erased in compiled code and when values of this type are analyzed using reflection. The type is representationally equivalent to <see cref="T:System.Double" />.</summary>
<category index="6">Basic Types with Units of Measure</category>
val toArray: source: seq<'T> -> 'T[]
<summary>Builds an array from the given collection.</summary>
<param name="source">The input sequence.</param>
<returns>The result array.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input sequence is null.</exception>
<example id="toarray-1"><code lang="fsharp"> let inputs = seq { 1; 2; 5 } inputs |&gt; Seq.toArray </code> Evaluates to <c>[| 1; 2; 5 |]</c>. </example>
Multiple items
module Array from FSharp.Stats
<summary> Module to compute common statistical measure on array </summary>

--------------------
module Array from Microsoft.FSharp.Collections
<summary>Contains operations for working with arrays.</summary>
<remarks> See also <a href="https://docs.microsoft.com/dotnet/fsharp/language-reference/arrays">F# Language Guide - Arrays</a>. </remarks>


--------------------
type Array = new: unit -> Array static member geomspace: start: float * stop: float * num: int * ?IncludeEndpoint: bool -> float array static member linspace: start: float * stop: float * num: int * ?IncludeEndpoint: bool -> float[]

--------------------
new: unit -> Array
val shuffleFisherYates: arr: 'b[] -> 'b[]
<summary>Shuffels the input array (method: Fisher-Yates)</summary>
<remarks></remarks>
<param name="arr"></param>
<returns></returns>
<example><code></code></example>
val mapi: mapping: (int -> 'T -> 'U) -> array: 'T[] -> 'U[]
<summary>Builds a new array whose elements are the results of applying the given function to each of the elements of the array. The integer index passed to the function indicates the index of element being transformed, starting at zero.</summary>
<param name="mapping">The function to transform elements and their indices.</param>
<param name="array">The input array.</param>
<returns>The array of transformed elements.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input array is null.</exception>
<example id="mapi-1"><code lang="fsharp"> let inputs = [| 10; 10; 10 |] inputs |&gt; Array.mapi (fun i x -&gt; i + x) </code> Evaluates to <c>[| 10; 11; 12 |]</c></example>
val i: int
val lable: string
val data: float[]
val sprintf: format: Printf.StringFormat<'T> -> 'T
<summary>Print to a string using the given format.</summary>
<param name="format">The formatter.</param>
<returns>The formatted result.</returns>
<example>See <c>Printf.sprintf</c> (link: <see cref="M:Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThen``1" />) for examples.</example>
val unzip: array: ('T1 * 'T2)[] -> 'T1[] * 'T2[]
<summary>Splits an array of pairs into two arrays.</summary>
<param name="array">The input array.</param>
<returns>The two arrays.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input array is null.</exception>
<example id="unzip-1"><code lang="fsharp"> let inputs = [| (1, "one"); (2, "two") |] let numbers, names = inputs |&gt; Array.unzip </code> Evaluates <c>numbers</c> to <c>[|1; 2|]</c> and <c>names</c> to <c>[|"one"; "two"|]</c>. </example>
val colnames: string list
val colorscaleValue: StyleParam.Colorscale
module StyleParam from Plotly.NET
type Colorscale = | Custom of seq<float * Color> | RdBu | Earth | Blackbody | YIOrRd | YIGnBu | Bluered | Portland | Electric | Jet ... member Convert: unit -> obj static member convert: (Colorscale -> obj)
<summary> The colorscale must be a collection containing a mapping of a normalized value (between 0.0 and 1.0) to it's color. At minimum, a mapping for the lowest (0.0) and highest (1.0) values are required. </summary>
union case StyleParam.Colorscale.Electric: StyleParam.Colorscale
val dataChart: GenericChart.GenericChart
type Chart = static member AnnotatedHeatmap: zData: seq<#seq<'a1>> * annotationText: seq<#seq<string>> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?X: seq<'a3> * ?MultiX: seq<seq<'a3>> * ?XGap: int * ?Y: seq<'a4> * ?MultiY: seq<seq<'a4>> * ?YGap: int * ?Text: 'a5 * ?MultiText: seq<'a5> * ?ColorBar: ColorBar * ?ColorScale: Colorscale * ?ShowScale: bool * ?ReverseScale: bool * ?ZSmooth: SmoothAlg * ?Transpose: bool * ?UseWebGL: bool * ?ReverseYAxis: bool * ?UseDefaults: bool -> GenericChart (requires 'a1 :> IConvertible and 'a3 :> IConvertible and 'a4 :> IConvertible and 'a5 :> IConvertible) + 1 overload static member Area: x: seq<#IConvertible> * y: seq<#IConvertible> * ?ShowMarkers: bool * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'a2 * ?MultiText: seq<'a2> * ?TextPosition: TextPosition * ?MultiTextPosition: seq<TextPosition> * ?MarkerColor: Color * ?MarkerColorScale: Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: MarkerSymbol * ?MultiMarkerSymbol: seq<MarkerSymbol> * ?Marker: Marker * ?LineColor: Color * ?LineColorScale: Colorscale * ?LineWidth: float * ?LineDash: DrawingStyle * ?Line: Line * ?AlignmentGroup: string * ?OffsetGroup: string * ?StackGroup: string * ?Orientation: Orientation * ?GroupNorm: GroupNorm * ?FillColor: Color * ?FillPatternShape: PatternShape * ?FillPattern: Pattern * ?UseWebGL: bool * ?UseDefaults: bool -> GenericChart (requires 'a2 :> IConvertible) + 1 overload static member Bar: values: seq<#IConvertible> * ?Keys: seq<'a1> * ?MultiKeys: seq<seq<'a1>> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'a2 * ?MultiText: seq<'a2> * ?MarkerColor: Color * ?MarkerColorScale: Colorscale * ?MarkerOutline: Line * ?MarkerPatternShape: PatternShape * ?MultiMarkerPatternShape: seq<PatternShape> * ?MarkerPattern: Pattern * ?Marker: Marker * ?Base: #IConvertible * ?Width: 'a4 * ?MultiWidth: seq<'a4> * ?TextPosition: TextPosition * ?MultiTextPosition: seq<TextPosition> * ?UseDefaults: bool -> GenericChart (requires 'a1 :> IConvertible and 'a2 :> IConvertible and 'a4 :> IConvertible) + 1 overload static member BoxPlot: ?X: seq<'a0> * ?MultiX: seq<seq<'a0>> * ?Y: seq<'a1> * ?MultiY: seq<seq<'a1>> * ?Name: string * ?ShowLegend: bool * ?Text: 'a2 * ?MultiText: seq<'a2> * ?FillColor: Color * ?MarkerColor: Color * ?Marker: Marker * ?Opacity: float * ?WhiskerWidth: float * ?BoxPoints: BoxPoints * ?BoxMean: BoxMean * ?Jitter: float * ?PointPos: float * ?Orientation: Orientation * ?OutlineColor: Color * ?OutlineWidth: float * ?Outline: Line * ?AlignmentGroup: string * ?OffsetGroup: string * ?Notched: bool * ?NotchWidth: float * ?QuartileMethod: QuartileMethod * ?UseDefaults: bool -> GenericChart (requires 'a0 :> IConvertible and 'a1 :> IConvertible and 'a2 :> IConvertible) + 2 overloads static member Bubble: x: seq<#IConvertible> * y: seq<#IConvertible> * sizes: seq<int> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'a2 * ?MultiText: seq<'a2> * ?TextPosition: TextPosition * ?MultiTextPosition: seq<TextPosition> * ?MarkerColor: Color * ?MarkerColorScale: Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: MarkerSymbol * ?MultiMarkerSymbol: seq<MarkerSymbol> * ?Marker: Marker * ?LineColor: Color * ?LineColorScale: Colorscale * ?LineWidth: float * ?LineDash: DrawingStyle * ?Line: Line * ?AlignmentGroup: string * ?OffsetGroup: string * ?StackGroup: string * ?Orientation: Orientation * ?GroupNorm: GroupNorm * ?UseWebGL: bool * ?UseDefaults: bool -> GenericChart (requires 'a2 :> IConvertible) + 1 overload static member Candlestick: ``open`` : seq<#IConvertible> * high: seq<#IConvertible> * low: seq<#IConvertible> * close: seq<#IConvertible> * ?X: seq<'a4> * ?MultiX: seq<seq<'a4>> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?Text: 'a5 * ?MultiText: seq<'a5> * ?Line: Line * ?IncreasingColor: Color * ?Increasing: FinanceMarker * ?DecreasingColor: Color * ?Decreasing: FinanceMarker * ?WhiskerWidth: float * ?ShowXAxisRangeSlider: bool * ?UseDefaults: bool -> GenericChart (requires 'a4 :> IConvertible and 'a5 :> IConvertible) + 2 overloads static member Column: values: seq<#IConvertible> * ?Keys: seq<'a1> * ?MultiKeys: seq<seq<'a1>> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'a2 * ?MultiText: seq<'a2> * ?MarkerColor: Color * ?MarkerColorScale: Colorscale * ?MarkerOutline: Line * ?MarkerPatternShape: PatternShape * ?MultiMarkerPatternShape: seq<PatternShape> * ?MarkerPattern: Pattern * ?Marker: Marker * ?Base: #IConvertible * ?Width: 'a4 * ?MultiWidth: seq<'a4> * ?TextPosition: TextPosition * ?MultiTextPosition: seq<TextPosition> * ?UseDefaults: bool -> GenericChart (requires 'a1 :> IConvertible and 'a2 :> IConvertible and 'a4 :> IConvertible) + 1 overload static member Contour: zData: seq<#seq<'a1>> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?X: seq<'a2> * ?MultiX: seq<seq<'a2>> * ?Y: seq<'a3> * ?MultiY: seq<seq<'a3>> * ?Text: 'a4 * ?MultiText: seq<'a4> * ?ColorBar: ColorBar * ?ColorScale: Colorscale * ?ShowScale: bool * ?ReverseScale: bool * ?Transpose: bool * ?ContourLineColor: Color * ?ContourLineDash: DrawingStyle * ?ContourLineSmoothing: float * ?ContourLine: Line * ?ContoursColoring: ContourColoring * ?ContoursOperation: ConstraintOperation * ?ContoursType: ContourType * ?ShowContourLabels: bool * ?ContourLabelFont: Font * ?Contours: Contours * ?FillColor: Color * ?NContours: int * ?UseDefaults: bool -> GenericChart (requires 'a1 :> IConvertible and 'a2 :> IConvertible and 'a3 :> IConvertible and 'a4 :> IConvertible) static member Funnel: x: seq<#IConvertible> * y: seq<#IConvertible> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?Width: float * ?Offset: float * ?Text: 'a2 * ?MultiText: seq<'a2> * ?TextPosition: TextPosition * ?MultiTextPosition: seq<TextPosition> * ?Orientation: Orientation * ?AlignmentGroup: string * ?OffsetGroup: string * ?MarkerColor: Color * ?MarkerOutline: Line * ?Marker: Marker * ?TextInfo: TextInfo * ?ConnectorLineColor: Color * ?ConnectorLineStyle: DrawingStyle * ?ConnectorFillColor: Color * ?ConnectorLine: Line * ?Connector: FunnelConnector * ?InsideTextFont: Font * ?OutsideTextFont: Font * ?UseDefaults: bool -> GenericChart (requires 'a2 :> IConvertible) static member Heatmap: zData: seq<#seq<'a1>> * ?X: seq<'a2> * ?MultiX: seq<seq<'a2>> * ?Y: seq<'a3> * ?MultiY: seq<seq<'a3>> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?XGap: int * ?YGap: int * ?Text: 'a4 * ?MultiText: seq<'a4> * ?ColorBar: ColorBar * ?ColorScale: Colorscale * ?ShowScale: bool * ?ReverseScale: bool * ?ZSmooth: SmoothAlg * ?Transpose: bool * ?UseWebGL: bool * ?ReverseYAxis: bool * ?UseDefaults: bool -> GenericChart (requires 'a1 :> IConvertible and 'a2 :> IConvertible and 'a3 :> IConvertible and 'a4 :> IConvertible) + 1 overload ...
static member Chart.Heatmap: zData: seq<#seq<'b>> * colNames: seq<string> * rowNames: seq<string> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?XGap: int * ?YGap: int * ?Text: 'c * ?MultiText: seq<'c> * ?ColorBar: ColorBar * ?ColorScale: StyleParam.Colorscale * ?ShowScale: bool * ?ReverseScale: bool * ?ZSmooth: StyleParam.SmoothAlg * ?Transpose: bool * ?UseWebGL: bool * ?ReverseYAxis: bool * ?UseDefaults: bool -> GenericChart.GenericChart (requires 'b :> System.IConvertible and 'c :> System.IConvertible)
static member Chart.Heatmap: zData: seq<#seq<'a1>> * ?X: seq<'a2> * ?MultiX: seq<seq<'a2>> * ?Y: seq<'a3> * ?MultiY: seq<seq<'a3>> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?XGap: int * ?YGap: int * ?Text: 'a4 * ?MultiText: seq<'a4> * ?ColorBar: ColorBar * ?ColorScale: StyleParam.Colorscale * ?ShowScale: bool * ?ReverseScale: bool * ?ZSmooth: StyleParam.SmoothAlg * ?Transpose: bool * ?UseWebGL: bool * ?ReverseYAxis: bool * ?UseDefaults: bool -> GenericChart.GenericChart (requires 'a1 :> System.IConvertible and 'a2 :> System.IConvertible and 'a3 :> System.IConvertible and 'a4 :> System.IConvertible)
val mapi: mapping: (int -> 'T -> 'U) -> source: seq<'T> -> seq<'U>
<summary>Builds a new collection whose elements are the results of applying the given function to each of the elements of the collection. The integer index passed to the function indicates the index (from 0) of element being transformed.</summary>
<param name="mapping">A function to transform items from the input sequence that also supplies the current index.</param>
<param name="source">The input sequence.</param>
<returns>The result sequence.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input sequence is null.</exception>
<example id="item-1"><code lang="fsharp"> let inputs = [ 10; 10; 10 ] inputs |&gt; Seq.mapi (fun i x -&gt; i + x) </code> Evaluates to a sequence yielding the same results as <c>seq { 10; 11; 12 }</c></example>
val s: string
static member Chart.withMarginSize: ?Left: 'a * ?Right: 'b * ?Top: 'c * ?Bottom: 'd * ?Pad: 'e * ?Autoexpand: 'f -> (GenericChart.GenericChart -> GenericChart.GenericChart)
static member Chart.withTitle: title: Title -> (GenericChart.GenericChart -> GenericChart.GenericChart)
static member Chart.withTitle: title: string * ?TitleFont: Font -> (GenericChart.GenericChart -> GenericChart.GenericChart)
module GenericChart from Plotly.NET
<summary> Module to represent a GenericChart </summary>
val toChartHTML: gChart: GenericChart.GenericChart -> string
namespace FSharp.Stats.ML
namespace FSharp.Stats.ML.Unsupervised
module HierarchicalClustering from FSharp.Stats.ML.Unsupervised
val rnd: System.Random
Multiple items
type Random = new: unit -> unit + 1 overload member Next: unit -> int + 2 overloads member NextBytes: buffer: byte[] -> unit + 1 overload member NextDouble: unit -> float member NextInt64: unit -> int64 + 2 overloads member NextSingle: unit -> float32 static member Shared: Random
<summary>Represents a pseudo-random number generator, which is an algorithm that produces a sequence of numbers that meet certain statistical requirements for randomness.</summary>

--------------------
System.Random() : System.Random
System.Random(Seed: int) : System.Random
val randomInitFactory: IterativeClustering.CentroidsFactory<float[]>
module IterativeClustering from FSharp.Stats.ML.Unsupervised
type CentroidsFactory<'a> = 'a array -> int -> 'a array
val randomCentroids: rng: System.Random -> sample: 'a array -> k: int -> 'a[]
val kmeansResult: IterativeClustering.KClusteringResult<float[]>
val kmeans: dist: DistanceMetrics.Distance<float[]> -> factory: IterativeClustering.CentroidsFactory<float[]> -> dataset: float[] array -> k: int -> IterativeClustering.KClusteringResult<float[]>
module DistanceMetrics from FSharp.Stats
<summary> Functions for computing distances of elements or sets </summary>
val euclidean: s1: seq<'a> -> s2: seq<'a> -> 'f (requires member (-) and member get_Zero and member (+) and member Sqrt and member ( * ))
<summary>Euclidean distance of two coordinate sequences</summary>
<remarks></remarks>
<param name="s1"></param>
<param name="s2"></param>
<returns></returns>
<example><code></code></example>
val clusteredIrisData: GenericChart.GenericChart
val zip: array1: 'T1[] -> array2: 'T2[] -> ('T1 * 'T2)[]
<summary>Combines the two arrays into an array of pairs. The two arrays must have equal lengths, otherwise an <c>ArgumentException</c> is raised.</summary>
<param name="array1">The first input array.</param>
<param name="array2">The second input array.</param>
<exception cref="T:System.ArgumentNullException">Thrown when either of the input arrays is null.</exception>
<exception cref="T:System.ArgumentException">Thrown when the input arrays differ in length.</exception>
<returns>The array of tupled elements.</returns>
<example id="zip-1"><code lang="fsharp"> let numbers = [|1; 2|] let names = [|"one"; "two"|] Array.zip numbers names </code> Evaluates to <c>[| (1, "one"); (2, "two") |]</c>. </example>
val sortBy: projection: ('T -> 'Key) -> array: 'T[] -> 'T[] (requires comparison)
<summary>Sorts the elements of an array, using the given projection for the keys and returning a new array. Elements are compared using <see cref="M:Microsoft.FSharp.Core.Operators.compare" />.</summary>
<remarks>This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. For a stable sort, consider using <see cref="M:Microsoft.FSharp.Collections.SeqModule.Sort" />.</remarks>
<param name="projection">The function to transform array elements into the type that is compared.</param>
<param name="array">The input array.</param>
<returns>The sorted array.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input array is null.</exception>
<example id="sortby-1"><code lang="fsharp"> let input = [| "a"; "bbb"; "cccc"; "dd" |] input |&gt; Array.sortBy (fun s -&gt; s.Length) </code> Evaluates to <c>[|"a"; "dd"; "bbb"; "cccc"|]</c>. </example>
val l: string
val dataPoint: float[]
val fst: tuple: ('T1 * 'T2) -> 'T1
<summary>Return the first element of a tuple, <c>fst (a,b) = a</c>.</summary>
<param name="tuple">The input tuple.</param>
<returns>The first value.</returns>
<example id="fst-example"><code lang="fsharp"> fst ("first", 2) // Evaluates to "first" </code></example>
IterativeClustering.KClusteringResult.Classifier: float[] -> int * float[]
<summary> Classifier function returns cluster index and centroid </summary>
val labels: string[]
val d: float[][]
val getBestkMeansClustering: data: float[] array -> k: int -> bootstraps: int -> IterativeClustering.KClusteringResult<float[]>
val data: float[] array
val k: int
val bootstraps: int
Multiple items
module List from FSharp.Stats
<summary> Module to compute common statistical measure on list </summary>

--------------------
module List from Microsoft.FSharp.Collections
<summary>Contains operations for working with values of type <see cref="T:Microsoft.FSharp.Collections.list`1" />.</summary>
<namespacedoc><summary>Operations for collections such as lists, arrays, sets, maps and sequences. See also <a href="https://docs.microsoft.com/dotnet/fsharp/language-reference/fsharp-collection-types">F# Collection Types</a> in the F# Language Guide. </summary></namespacedoc>


--------------------
type List = new: unit -> List static member geomspace: start: float * stop: float * num: int * ?IncludeEndpoint: bool -> float list static member linspace: start: float * stop: float * num: int * ?IncludeEndpoint: bool -> float list

--------------------
type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ...
<summary>The type of immutable singly-linked lists.</summary>
<remarks>Use the constructors <c>[]</c> and <c>::</c> (infix) to create values of this type, or the notation <c>[1;2;3]</c>. Use the values in the <c>List</c> module to manipulate values of this type, or pattern match against the values directly. </remarks>
<exclude />


--------------------
new: unit -> List
val mapi: mapping: (int -> 'T -> 'U) -> list: 'T list -> 'U list
<summary>Builds a new collection whose elements are the results of applying the given function to each of the elements of the collection. The integer index passed to the function indicates the index (from 0) of element being transformed.</summary>
<param name="mapping">The function to transform elements and their indices.</param>
<param name="list">The input list.</param>
<returns>The list of transformed elements.</returns>
<example id="item-1"><code lang="fsharp"> let inputs = [ 10; 10; 10 ] inputs |&gt; List.mapi (fun i x -&gt; i + x) </code> Evaluates to <c>[ 10; 11; 12 ]</c></example>
val x: int
val minBy: projection: ('T -> 'U) -> list: 'T list -> 'T (requires comparison)
<summary>Returns the lowest of all elements of the list, compared via Operators.min on the function result</summary>
<remarks>Raises <see cref="T:System.ArgumentException" /> if <c>list</c> is empty.</remarks>
<param name="projection">The function to transform list elements into the type to be compared.</param>
<param name="list">The input list.</param>
<exception cref="T:System.ArgumentException">Thrown when the list is empty.</exception>
<returns>The minimum value.</returns>
<example id="minby-1"><code lang="fsharp"> let inputs = ["aaa"; "b"; "cccc"] inputs |&gt; List.minBy (fun s -&gt; s.Length) </code> Evaluates to <c>"b"</c></example>
<example id="minby-2"><code lang="fsharp"> let inputs = [] inputs |&gt; List.minBy (fun (s: string) -&gt; s.Length) </code> Throws <c>System.ArgumentException</c>. </example>
val clusteringResult: IterativeClustering.KClusteringResult<float[]>
val DispersionOfClusterResult: kmeansResult: IterativeClustering.KClusteringResult<'a> -> float
<summary>Calculates the average squared distance from the data points<br />to the cluster centroid (also refered to as error)</summary>
<remarks></remarks>
<param name="kmeansResult"></param>
<returns></returns>
<example><code></code></example>
val t: DbScan.DbscanResult<float array>
module DbScan from FSharp.Stats.ML.Unsupervised
val compute: dfu: ('a array -> 'a array -> float) -> minPts: int -> eps: float -> input: seq<#seq<'a>> -> DbScan.DbscanResult<'a array>
module Array from FSharp.Stats.DistanceMetrics
val euclideanNaN: a1: float array -> a2: float array -> float
<summary>Euclidean distance of two coordinate float arrays (ignores nan)</summary>
<remarks></remarks>
<param name="a1"></param>
<param name="a2"></param>
<returns></returns>
<example><code></code></example>
val petLpetW: float[][]
val map: mapping: ('T -> 'U) -> array: 'T[] -> 'U[]
<summary>Builds a new array whose elements are the results of applying the given function to each of the elements of the array.</summary>
<param name="mapping">The function to transform elements of the array.</param>
<param name="array">The input array.</param>
<returns>The array of transformed elements.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input array is null.</exception>
<example id="map-1"><code lang="fsharp"> let inputs = [| "a"; "bbb"; "cc" |] inputs |&gt; Array.map (fun x -&gt; x.Length) </code> Evaluates to <c>[| 1; 3; 2 |]</c></example>
val x: float[]
val petWpetLsepL: float[][]
val dbscanPlot: GenericChart.GenericChart
val head: source: seq<'T> -> 'T
<summary>Returns the first element of the sequence.</summary>
<param name="source">The input sequence.</param>
<returns>The first element of the sequence.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input sequence is null.</exception>
<exception cref="T:System.ArgumentException">Thrown when the input does not have any elements.</exception>
<example id="head-1"><code lang="fsharp"> let inputs = ["banana"; "pear"] inputs |&gt; Seq.head </code> Evaluates to <c>banana</c></example>
<example id="head-2"><code lang="fsharp"> [] |&gt; Seq.head </code> Throws <c>ArgumentException</c></example>
val length: source: seq<'T> -> int
<summary>Returns the length of the sequence</summary>
<param name="source">The input sequence.</param>
<returns>The length of the sequence.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input sequence is null.</exception>
<example id="item-1"><code lang="fsharp"> let inputs = ["a"; "b"; "c"] inputs |&gt; Seq.length </code> Evaluates to <c>3</c></example>
val failwithf: format: Printf.StringFormat<'T,'Result> -> 'T
<summary>Print to a string buffer and raise an exception with the given result. Helper printers must return strings.</summary>
<param name="format">The formatter.</param>
<returns>The formatted result.</returns>
<example>See <c>Printf.failwithf</c> (link: <see cref="M:Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail``2" />) for examples.</example>
val result: DbScan.DbscanResult<float array>
val euclidean: a1: 'a array -> a2: 'a array -> float (requires member get_Zero and member (-) and member (+) and member op_Explicit and member ( * ))
<summary>Euclidean distance of two coordinate arrays</summary>
<remarks></remarks>
<param name="a1"></param>
<param name="a2"></param>
<returns></returns>
<example><code></code></example>
val chartCluster: GenericChart.GenericChart
DbScan.DbscanResult.Clusterlist: seq<seq<float array>>
val ofSeq: source: seq<'T> -> 'T[]
<summary>Builds a new array from the given enumerable object.</summary>
<param name="source">The input sequence.</param>
<returns>The array of elements from the sequence.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input sequence is null.</exception>
<example id="ofseq-1"><code lang="fsharp"> let inputs = seq { 1; 2; 5 } inputs |&gt; Array.ofSeq </code> Evaluates to <c>[| 1; 2; 5 |]</c>. </example>
val l: seq<float array>
val x: float array
val distinct: array: 'T[] -> 'T[] (requires equality)
<summary>Returns an array that contains no duplicate entries according to generic hash and equality comparisons on the entries. If an element occurs multiple times in the array then the later occurrences are discarded.</summary>
<param name="array">The input array.</param>
<returns>The result array.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input array is null.</exception>
<example id="distinct-1"><code lang="fsharp"> let input = [| 1; 1; 2; 3 |] input |&gt; Array.distinct </code> Evaluates to <c>[| 1; 2; 3 |]</c></example>
static member Chart.Point: xy: seq<#System.IConvertible * #System.IConvertible> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'c * ?MultiText: seq<'c> * ?TextPosition: StyleParam.TextPosition * ?MultiTextPosition: seq<StyleParam.TextPosition> * ?MarkerColor: Color * ?MarkerColorScale: StyleParam.Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: StyleParam.MarkerSymbol * ?MultiMarkerSymbol: seq<StyleParam.MarkerSymbol> * ?Marker: TraceObjects.Marker * ?AlignmentGroup: string * ?OffsetGroup: string * ?StackGroup: string * ?Orientation: StyleParam.Orientation * ?GroupNorm: StyleParam.GroupNorm * ?UseWebGL: bool * ?UseDefaults: bool -> GenericChart.GenericChart (requires 'c :> System.IConvertible)
static member Chart.Point: x: seq<#System.IConvertible> * y: seq<#System.IConvertible> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'a2 * ?MultiText: seq<'a2> * ?TextPosition: StyleParam.TextPosition * ?MultiTextPosition: seq<StyleParam.TextPosition> * ?MarkerColor: Color * ?MarkerColorScale: StyleParam.Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: StyleParam.MarkerSymbol * ?MultiMarkerSymbol: seq<StyleParam.MarkerSymbol> * ?Marker: TraceObjects.Marker * ?AlignmentGroup: string * ?OffsetGroup: string * ?StackGroup: string * ?Orientation: StyleParam.Orientation * ?GroupNorm: StyleParam.GroupNorm * ?UseWebGL: bool * ?UseDefaults: bool -> GenericChart.GenericChart (requires 'a2 :> System.IConvertible)
static member Chart.withTraceInfo: ?Name: string * ?Visible: StyleParam.Visible * ?ShowLegend: bool * ?LegendRank: int * ?LegendGroup: string * ?LegendGroupTitle: Title -> (GenericChart.GenericChart -> GenericChart.GenericChart)
static member Chart.combine: gCharts: seq<GenericChart.GenericChart> -> GenericChart.GenericChart
val chartNoise: GenericChart.GenericChart
DbScan.DbscanResult.Noisepoints: seq<float array>
val distinct: source: seq<'T> -> seq<'T> (requires equality)
<summary>Returns a sequence that contains no duplicate entries according to generic hash and equality comparisons on the entries. If an element occurs multiple times in the sequence then the later occurrences are discarded.</summary>
<param name="source">The input sequence.</param>
<returns>The result sequence.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input sequence is null.</exception>
<example id="distinct-1"><code lang="fsharp"> [1; 1; 2; 3] |&gt; Seq.distinct </code> Evaluates to a sequence yielding the same results as <c>seq { 1; 2; 3 }</c></example>
val chartname: string
val noiseCount: int
val clusterCount: int
val clPtsCount: int
val sumBy: projection: ('T -> 'U) -> source: seq<'T> -> 'U (requires member (+) and member get_Zero)
<summary>Returns the sum of the results generated by applying the function to each element of the sequence.</summary>
<remarks>The generated elements are summed using the <c>+</c> operator and <c>Zero</c> property associated with the generated type.</remarks>
<param name="projection">A function to transform items from the input sequence into the type that will be summed.</param>
<param name="source">The input sequence.</param>
<returns>The computed sum.</returns>
<example id="sumby-1"><code lang="fsharp"> let input = [ "aa"; "bbb"; "cc" ] input |&gt; Seq.sumBy (fun s -&gt; s.Length) </code> Evaluates to <c>7</c>. </example>
static member Chart.withTemplate: template: Template -> (GenericChart.GenericChart -> GenericChart.GenericChart)
module ChartTemplates from Plotly.NET
val lightMirrored: Template
static member Chart.withXAxisStyle: ?TitleText: string * ?TitleFont: Font * ?TitleStandoff: int * ?Title: Title * ?Color: Color * ?AxisType: StyleParam.AxisType * ?MinMax: (#System.IConvertible * #System.IConvertible) * ?Mirror: StyleParam.Mirror * ?ShowSpikes: bool * ?SpikeColor: Color * ?SpikeThickness: int * ?ShowLine: bool * ?LineColor: Color * ?ShowGrid: bool * ?GridColor: Color * ?GridDash: StyleParam.DrawingStyle * ?ZeroLine: bool * ?ZeroLineColor: Color * ?Anchor: StyleParam.LinearAxisId * ?Side: StyleParam.Side * ?Overlaying: StyleParam.LinearAxisId * ?Domain: (float * float) * ?Position: float * ?CategoryOrder: StyleParam.CategoryOrder * ?CategoryArray: seq<#System.IConvertible> * ?RangeSlider: LayoutObjects.RangeSlider * ?RangeSelector: LayoutObjects.RangeSelector * ?BackgroundColor: Color * ?ShowBackground: bool * ?Id: StyleParam.SubPlotId -> (GenericChart.GenericChart -> GenericChart.GenericChart)
static member Chart.withYAxisStyle: ?TitleText: string * ?TitleFont: Font * ?TitleStandoff: int * ?Title: Title * ?Color: Color * ?AxisType: StyleParam.AxisType * ?MinMax: (#System.IConvertible * #System.IConvertible) * ?Mirror: StyleParam.Mirror * ?ShowSpikes: bool * ?SpikeColor: Color * ?SpikeThickness: int * ?ShowLine: bool * ?LineColor: Color * ?ShowGrid: bool * ?GridColor: Color * ?GridDash: StyleParam.DrawingStyle * ?ZeroLine: bool * ?ZeroLineColor: Color * ?Anchor: StyleParam.LinearAxisId * ?Side: StyleParam.Side * ?Overlaying: StyleParam.LinearAxisId * ?AutoShift: bool * ?Shift: int * ?Domain: (float * float) * ?Position: float * ?CategoryOrder: StyleParam.CategoryOrder * ?CategoryArray: seq<#System.IConvertible> * ?RangeSlider: LayoutObjects.RangeSlider * ?RangeSelector: LayoutObjects.RangeSelector * ?BackgroundColor: Color * ?ShowBackground: bool * ?Id: StyleParam.SubPlotId -> (GenericChart.GenericChart -> GenericChart.GenericChart)
val create3dChart: dfu: ('a array -> 'a array -> float) -> minPts: int -> eps: float -> input: seq<#seq<'a>> -> GenericChart.GenericChart (requires equality and 'a :> System.IConvertible)
val dfu: ('a array -> 'a array -> float) (requires equality and 'a :> System.IConvertible)
type 'T array = 'T[]
<summary>Single dimensional, zero-based arrays, written <c>int[]</c>, <c>string[]</c> etc.</summary>
<remarks>Use the values in the <see cref="T:Microsoft.FSharp.Collections.ArrayModule" /> module to manipulate values of this type, or the notation <c>arr.[x]</c> to get/set array values.</remarks>
<category>Basic Types</category>
val minPts: int
Multiple items
val int: value: 'T -> int (requires member op_Explicit)
<summary>Converts the argument to signed 32-bit integer. This is a direct conversion for all primitive numeric types. For strings, the input is converted using <c>Int32.Parse()</c> with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.</summary>
<param name="value">The input value.</param>
<returns>The converted int</returns>
<example id="int-example"><code lang="fsharp"></code></example>


--------------------
[<Struct>] type int = int32
<summary>An abbreviation for the CLI type <see cref="T:System.Int32" />.</summary>
<category>Basic Types</category>


--------------------
type int<'Measure> = int
<summary>The type of 32-bit signed integer numbers, annotated with a unit of measure. The unit of measure is erased in compiled code and when values of this type are analyzed using reflection. The type is representationally equivalent to <see cref="T:System.Int32" />.</summary>
<category>Basic Types with Units of Measure</category>
val eps: float
val input: seq<#seq<'a0>> (requires equality and 'a0 :> System.IConvertible)
val result: DbScan.DbscanResult<'a array> (requires equality and 'a :> System.IConvertible)
DbScan.DbscanResult.Clusterlist: seq<seq<'a array>>
val l: seq<'a array> (requires equality and 'a :> System.IConvertible)
val x: 'a array (requires equality and 'a :> System.IConvertible)
val x: seq<'a * 'a * 'a> (requires equality and 'a :> System.IConvertible)
static member Chart.Scatter3D: xyz: seq<#System.IConvertible * #System.IConvertible * #System.IConvertible> * mode: StyleParam.Mode * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'e * ?MultiText: seq<'e> * ?TextPosition: StyleParam.TextPosition * ?MultiTextPosition: seq<StyleParam.TextPosition> * ?MarkerColor: Color * ?MarkerColorScale: StyleParam.Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: StyleParam.MarkerSymbol3D * ?MultiMarkerSymbol: seq<StyleParam.MarkerSymbol3D> * ?Marker: TraceObjects.Marker * ?LineColor: Color * ?LineColorScale: StyleParam.Colorscale * ?LineWidth: float * ?LineDash: StyleParam.DrawingStyle * ?Line: Line * ?CameraProjectionType: StyleParam.CameraProjectionType * ?Camera: LayoutObjects.Camera * ?Projection: TraceObjects.Projection * ?UseDefaults: bool -> GenericChart.GenericChart (requires 'e :> System.IConvertible)
static member Chart.Scatter3D: x: seq<#System.IConvertible> * y: seq<#System.IConvertible> * z: seq<#System.IConvertible> * mode: StyleParam.Mode * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'a3 * ?MultiText: seq<'a3> * ?TextPosition: StyleParam.TextPosition * ?MultiTextPosition: seq<StyleParam.TextPosition> * ?MarkerColor: Color * ?MarkerColorScale: StyleParam.Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: StyleParam.MarkerSymbol3D * ?MultiMarkerSymbol: seq<StyleParam.MarkerSymbol3D> * ?Marker: TraceObjects.Marker * ?LineColor: Color * ?LineColorScale: StyleParam.Colorscale * ?LineWidth: float * ?LineDash: StyleParam.DrawingStyle * ?Line: Line * ?CameraProjectionType: StyleParam.CameraProjectionType * ?Camera: LayoutObjects.Camera * ?Projection: TraceObjects.Projection * ?UseDefaults: bool -> GenericChart.GenericChart (requires 'a3 :> System.IConvertible)
type Mode = | None | Lines | Lines_Markers | Lines_Text | Lines_Markers_Text | Markers | Markers_Text | Text member Convert: unit -> obj override ToString: unit -> string static member convert: (Mode -> obj) static member toString: (Mode -> string)
union case StyleParam.Mode.Markers: StyleParam.Mode
DbScan.DbscanResult.Noisepoints: seq<'a array>
type SubPlotId = | XAxis of int | YAxis of int | ZAxis | ColorAxis of int | Geo of int | Mapbox of int | Polar of int | Ternary of int | Scene of int | Carpet of string ... member Convert: unit -> obj override ToString: unit -> string static member convert: (SubPlotId -> obj) static member toString: (SubPlotId -> string)
union case StyleParam.SubPlotId.Scene: int -> StyleParam.SubPlotId
val clusteredChart3D: GenericChart.GenericChart
val euclideanNaNSquared: a1: float array -> a2: float array -> float
<summary>Squared Euclidean distance of two coordinate float arrays (ignores nan)</summary>
<remarks></remarks>
<param name="a1"></param>
<param name="a2"></param>
<returns></returns>
<example><code></code></example>
namespace Priority_Queue
val distance: (seq<float> -> seq<float> -> float)
val linker: (int * int * int -> float -> float -> float -> float)
module Linker from FSharp.Stats.ML.Unsupervised.HierarchicalClustering
<summary> The linkage criterion determines the distance between sets of observations as a function of the pairwise distances between observations </summary>
val wardLwLinker: int * int * int -> dAB: float -> dAC: float -> dBC: float -> float
<summary>Ward linkage criterion (UPGMA)<br />Calculates the <br />d(A u B, C)</summary>
<remarks></remarks>
<param name="mcABC"></param>
<param name="dAB"></param>
<param name="dAC"></param>
<param name="dBC"></param>
<returns></returns>
<example><code></code></example>
val result: Cluster<float array>
val generate<'T> : distance: Distance<float[]> -> linker: Linker.LancWilliamsLinker -> data: float[] array -> System.Collections.Generic.Dictionary<Cluster<float array>,FastPriorityQueue<ClusterIndex>>
<summary> Builds a hierarchy of clusters of data containing cluster labels </summary>
val item: index: int -> source: seq<'T> -> 'T
<summary>Computes the element at the specified index in the collection.</summary>
<param name="index">The index of the element to retrieve.</param>
<param name="source">The input sequence.</param>
<returns>The element at the specified index of the sequence.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input sequence is null.</exception>
<exception cref="T:System.ArgumentException">Thrown when the index is negative or the input sequence does not contain enough elements.</exception>
<example id="item-1"><code lang="fsharp"> let inputs = ["a"; "b"; "c"] inputs |&gt; Seq.item 1 </code> Evaluates to <c>"b"</c></example>
<example id="item-2"><code lang="fsharp"> let inputs = ["a"; "b"; "c"] inputs |&gt; Seq.item 4 </code> Throws <c>ArgumentException</c></example>
val x: System.Collections.Generic.KeyValuePair<Cluster<float array>,FastPriorityQueue<ClusterIndex>>
property System.Collections.Generic.KeyValuePair.Key: Cluster<float array> with get
<summary>Gets the key in the key/value pair.</summary>
<returns>A <typeparamref name="TKey" /> that is the key of the <see cref="T:System.Collections.Generic.KeyValuePair`2" />.</returns>
val threeClustersH: Cluster<float array> list list
val cutHClust: desiredNumber: int -> clusterTree: Cluster<float array> -> Cluster<float array> list list
<summary>cuts tree in chosen amount of clusters</summary>
<remarks></remarks>
<param name="desiredNumber"></param>
<param name="clusterTree"></param>
<returns></returns>
<example><code></code></example>
val inspectThreeClusters: string * string list list
val map: mapping: ('T -> 'U) -> list: 'T list -> 'U list
<summary>Builds a new collection whose elements are the results of applying the given function to each of the elements of the collection.</summary>
<param name="mapping">The function to transform elements from the input list.</param>
<param name="list">The input list.</param>
<returns>The list of transformed elements.</returns>
<example id="map-1"><code lang="fsharp"> let inputs = [ "a"; "bbb"; "cc" ] inputs |&gt; List.map (fun x -&gt; x.Length) </code> Evaluates to <c>[ 1; 3; 2 ]</c></example>
val cluster: Cluster<float array> list
val leaf: Cluster<float array>
val getClusterId: c: Cluster<'T> -> int
<summary>Returns cluster Id</summary>
<remarks></remarks>
<param name="c"></param>
<returns></returns>
<example><code></code></example>
val clusteredLabels: string list list
property List.Length: int with get
<summary>Gets the number of items contained in the list</summary>
val hLeaves: Cluster<float array> list
val flattenHClust: clusterTree: Cluster<float array> -> Cluster<float array> list
val dataSortedByClustering: (string * float array) list
val choose: chooser: ('T -> 'U option) -> list: 'T list -> 'U list
<summary>Applies a function to each element in a list and then returns a list of values <c>v</c> where the applied function returned <c>Some(v)</c>. Returns an empty list when the input list is empty or when the applied chooser function returns <c>None</c> for all elements. </summary>
<param name="chooser">The function to be applied to the list elements.</param>
<param name="list">The input list.</param>
<returns>The resulting list comprising the values <c>v</c> where the chooser function returned <c>Some(x)</c>.</returns>
<example id="choose-1"> Using the identity function <c>id</c> (is defined like <c>fun x -&gt; x</c>): <code lang="fsharp"> let input1 = [ Some 1; None; Some 3; None ] input1 |&gt; List.choose id </code> Evaluates to <code lang="fsharp"> [ 1; 3 ] </code></example>
<example id="choose-2"><code lang="fsharp"> type Happiness = | AlwaysHappy | MostOfTheTimeGrumpy type People = { Name: string; Happiness: Happiness } let takeJustHappyPersons person = match person.Happiness with | AlwaysHappy -&gt; Some person.Name | MostOfTheTimeGrumpy -&gt; None let candidatesForTheTrip = [ { Name = "SpongeBob" Happiness = AlwaysHappy } { Name = "Patrick" Happiness = AlwaysHappy } { Name = "Squidward" Happiness = MostOfTheTimeGrumpy } ] candidatesForTheTrip |&gt; List.choose takeJustHappyPersons </code> Evaluates to <code lang="fsharp"> [ "SpongeBob"; "Patrick" ] </code></example>
<example id="choose-3"><code lang="fsharp"> let input3: int option list = [] input3 |&gt; List.choose id Evaluates to: empty list </code></example>
<example id="choose-4"><code lang="fsharp"> let input4: string option list = [None; None] input4 |&gt; List.choose id Evaluates to empty list </code></example>
<example id="choose-5"> Using the identity function <c>id</c> (is defined like <c>fun x -&gt; x</c>): <code lang="fsharp"> let input5 = [ Some 1; None; Some 3; None ] input5 |&gt; List.choose id // evaluates [1; 3] </code></example>
val c: Cluster<float array>
val values: float array option
val tryGetLeafValue: c: Cluster<'T> -> 'T option
<summary>Returns cleaf value</summary>
<remarks></remarks>
<param name="c"></param>
<returns></returns>
<example><code></code></example>
union case Option.None: Option<'T>
<summary>The representation of "No value"</summary>
union case Option.Some: Value: 'T -> Option<'T>
<summary>The representation of "Value of type 'T"</summary>
<param name="Value">The input value.</param>
<returns>An option representing the value.</returns>
val hierClusteredDataHeatmap: GenericChart.GenericChart
val hlable: string list
val hdata: float array list
val unzip: list: ('T1 * 'T2) list -> 'T1 list * 'T2 list
<summary>Splits a list of pairs into two lists.</summary>
<param name="list">The input list.</param>
<returns>Two lists of split elements.</returns>
<example id="unzip-1"><code lang="fsharp"> let inputs = [(1, "one"); (2, "two")] let numbers, names = inputs |&gt; List.unzip </code> Evaluates <c>numbers</c> to <c>[1; 2]</c> and <c>names</c> to <c>["one"; "two"]</c>. </example>
val ruleOfThumb: float
module ClusterNumber from FSharp.Stats.ML.Unsupervised
val kRuleOfThumb: observations: seq<'a> -> float
<summary>Simple estimator for number of cluster (k) // can be used as the upper bound for other methods</summary>
<remarks></remarks>
<param name="observations"></param>
<returns></returns>
<example><code></code></example>
val kElbow: int
val iterations: int
val dispersionOfK: (int * float * float)[]
Multiple items
module Array from FSharp.Stats.DistanceMetrics

--------------------
module Array from FSharp.Stats
<summary> Module to compute common statistical measure on array </summary>

--------------------
module Array from Microsoft.FSharp.Collections
<summary>Contains operations for working with arrays.</summary>
<remarks> See also <a href="https://docs.microsoft.com/dotnet/fsharp/language-reference/arrays">F# Language Guide - Arrays</a>. </remarks>


--------------------
type Array = new: unit -> Array static member geomspace: start: float * stop: float * num: int * ?IncludeEndpoint: bool -> float array static member linspace: start: float * stop: float * num: int * ?IncludeEndpoint: bool -> float[]

--------------------
new: unit -> Array
val dispersion: float
val std: float
val kmeans: dist: Distance<float[]> -> factory: CentroidsFactory<float[]> -> dataset: float[] array -> k: int -> KClusteringResult<float[]>
val euclideanNaNSquared: s1: seq<float> -> s2: seq<float> -> float
<summary>Squared Euclidean distance of two coordinate float sequences (ignores nan)</summary>
<remarks></remarks>
<param name="s1"></param>
<param name="s2"></param>
<returns></returns>
<example><code></code></example>
val DispersionOfClusterResult: kmeansResult: KClusteringResult<'a> -> float
<summary>Calculates the average squared distance from the data points<br />to the cluster centroid (also refered to as error)</summary>
<remarks></remarks>
<param name="kmeansResult"></param>
<returns></returns>
<example><code></code></example>
val dispersions: float[]
val mean: items: seq<'T> -> 'U (requires member (+) and member get_Zero and member DivideByInt and member (/))
<summary> Computes the population mean (Normalized by N) </summary>
<param name="items">The input sequence.</param>
<remarks>Returns default value if data is empty or if any entry is NaN.</remarks>
<returns>population mean (Normalized by N)</returns>
val stDev: items: seq<'T> -> 'U (requires member (-) and member get_Zero and member DivideByInt and member (+) and member ( * ) and member (+) and member (/) and member Sqrt)
<summary> Computes the sample standard deviation </summary>
<param name="items">The input sequence.</param>
<remarks>Returns NaN if data is empty or if any entry is NaN.</remarks>
<returns>standard deviation of a sample (Bessel's correction by N-1)</returns>
val elbowChart: GenericChart.GenericChart
static member Chart.Line: xy: seq<#System.IConvertible * #System.IConvertible> * ?ShowMarkers: bool * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'c * ?MultiText: seq<'c> * ?TextPosition: StyleParam.TextPosition * ?MultiTextPosition: seq<StyleParam.TextPosition> * ?MarkerColor: Color * ?MarkerColorScale: StyleParam.Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: StyleParam.MarkerSymbol * ?MultiMarkerSymbol: seq<StyleParam.MarkerSymbol> * ?Marker: TraceObjects.Marker * ?LineColor: Color * ?LineColorScale: StyleParam.Colorscale * ?LineWidth: float * ?LineDash: StyleParam.DrawingStyle * ?Line: Line * ?AlignmentGroup: string * ?OffsetGroup: string * ?StackGroup: string * ?Orientation: StyleParam.Orientation * ?GroupNorm: StyleParam.GroupNorm * ?Fill: StyleParam.Fill * ?FillColor: Color * ?FillPattern: TraceObjects.Pattern * ?UseWebGL: bool * ?UseDefaults: bool -> GenericChart.GenericChart (requires 'c :> System.IConvertible)
static member Chart.Line: x: seq<#System.IConvertible> * y: seq<#System.IConvertible> * ?ShowMarkers: bool * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'c * ?MultiText: seq<'c> * ?TextPosition: StyleParam.TextPosition * ?MultiTextPosition: seq<StyleParam.TextPosition> * ?MarkerColor: Color * ?MarkerColorScale: StyleParam.Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: StyleParam.MarkerSymbol * ?MultiMarkerSymbol: seq<StyleParam.MarkerSymbol> * ?Marker: TraceObjects.Marker * ?LineColor: Color * ?LineColorScale: StyleParam.Colorscale * ?LineWidth: float * ?LineDash: StyleParam.DrawingStyle * ?Line: Line * ?AlignmentGroup: string * ?OffsetGroup: string * ?StackGroup: string * ?Orientation: StyleParam.Orientation * ?GroupNorm: StyleParam.GroupNorm * ?Fill: StyleParam.Fill * ?FillColor: Color * ?FillPattern: TraceObjects.Pattern * ?UseWebGL: bool * ?UseDefaults: bool -> GenericChart.GenericChart (requires 'c :> System.IConvertible)
static member Chart.withYErrorStyle: ?Visible: bool * ?Type: StyleParam.ErrorType * ?Symmetric: bool * ?Array: seq<#System.IConvertible> * ?Arrayminus: seq<#System.IConvertible> * ?Value: float * ?Valueminus: float * ?Traceref: int * ?Tracerefminus: int * ?Copy_ystyle: bool * ?Color: Color * ?Thickness: float * ?Width: float -> (GenericChart.GenericChart -> GenericChart.GenericChart)
val aicBootstraps: int
val aicK: int[]
val aicMeans: float[]
val aicStd: float[]
val aic: (int * float)[][]
val b: int
val calcAIC: bootstraps: int -> iClustering: (int -> KClusteringResult<float[]>) -> maxK: int -> (int * float)[]
<summary>Akaike Information Criterion (AIC)</summary>
<remarks></remarks>
<param name="bootstraps"></param>
<returns></returns>
<example><code></code></example>
val iteration: (int * float)[]
val snd: tuple: ('T1 * 'T2) -> 'T2
<summary>Return the second element of a tuple, <c>snd (a,b) = b</c>.</summary>
<param name="tuple">The input tuple.</param>
<returns>The second value.</returns>
<example id="snd-example"><code lang="fsharp"> snd ("first", 2) // Evaluates to 2 </code></example>
module JaggedArray from FSharp.Stats
val transpose: arr: 'T[][] -> 'T[][]
<summary>Transposes a jagged array</summary>
<remarks></remarks>
<param name="arr"></param>
<returns></returns>
<example><code></code></example>
val aics: float[]
val unzip3: array: ('T1 * 'T2 * 'T3)[] -> 'T1[] * 'T2[] * 'T3[]
<summary>Splits an array of triples into three arrays.</summary>
<param name="array">The input array.</param>
<returns>The tuple of three arrays.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input array is null.</exception>
<example id="unzip3-1"><code lang="fsharp"> let inputs = [| (1, "one", "I"); (2, "two", "II") |] let numbers, names, roman = inputs |&gt; Array.unzip3 </code> Evaluates <c>numbers</c> to <c>[|1; 2|]</c>, <c>names</c> to <c>[|"one"; "two"|]</c> and <c>roman</c> to <c>[|"I"; "II"|]</c>. </example>
val aicChart: GenericChart.GenericChart
val silhouetteData: float[][]
System.IO.File.ReadAllLines(path: string) : string[]
System.IO.File.ReadAllLines(path: string, encoding: System.Text.Encoding) : string[]
val x: string
val tmp: string[]
val sI: ClusterNumber.SilhouetteResult[]
val silhouetteIndexKMeans: bootstraps: int -> iClustering: (int -> KClusteringResult<float[]>) -> data: float[][] -> maxK: int -> ClusterNumber.SilhouetteResult[]
<summary>The silhouette index can be used to determine the optimal cluster number in k means clustering.<br />bootstraps indicates the number the k means clustering is performed for each k and maxK indicated the maximal cluster number.</summary>
<remarks></remarks>
<param name="bootstraps"></param>
<param name="iClustering"></param>
<param name="data"></param>
<param name="maxK"></param>
<returns></returns>
<example><code></code></example>
val rawDataChart: GenericChart.GenericChart
val silhouetteIndicesChart: GenericChart.GenericChart
val x: ClusterNumber.SilhouetteResult
ClusterNumber.SilhouetteResult.ClusterNumber: int
ClusterNumber.SilhouetteResult.SilhouetteIndex: float
ClusterNumber.SilhouetteResult.SilhouetteIndexStDev: float
val combinedSilhouette: GenericChart.GenericChart
static member Chart.Grid: ?SubPlots: (StyleParam.LinearAxisId * StyleParam.LinearAxisId)[][] * ?XAxes: StyleParam.LinearAxisId[] * ?YAxes: StyleParam.LinearAxisId[] * ?RowOrder: StyleParam.LayoutGridRowOrder * ?Pattern: StyleParam.LayoutGridPattern * ?XGap: float * ?YGap: float * ?Domain: LayoutObjects.Domain * ?XSide: StyleParam.LayoutGridXSide * ?YSide: StyleParam.LayoutGridYSide -> (#seq<'a1> -> GenericChart.GenericChart) (requires 'a1 :> seq<GenericChart.GenericChart>)
static member Chart.Grid: nRows: int * nCols: int * ?SubPlots: (StyleParam.LinearAxisId * StyleParam.LinearAxisId)[][] * ?XAxes: StyleParam.LinearAxisId[] * ?YAxes: StyleParam.LinearAxisId[] * ?RowOrder: StyleParam.LayoutGridRowOrder * ?Pattern: StyleParam.LayoutGridPattern * ?XGap: float * ?YGap: float * ?Domain: LayoutObjects.Domain * ?XSide: StyleParam.LayoutGridXSide * ?YSide: StyleParam.LayoutGridYSide -> (#seq<GenericChart.GenericChart> -> GenericChart.GenericChart)
val gapStatisticsData: float[][]
val gapDataChart: GenericChart.GenericChart
module GapStatistics from FSharp.Stats.ML.Unsupervised
module PointGenerators from FSharp.Stats.ML.Unsupervised.GapStatistics
val generateUniformPoints: rnd: System.Random -> data: float[] array -> float[][]
<summary>Generate uniform points within the range of `data`.</summary>
<remarks></remarks>
<param name="rnd"></param>
<returns></returns>
<example><code></code></example>
val generateUniformPointsPCA: rnd: System.Random -> data: float[] array -> float[][]
static member Chart.withSize: width: float * height: float -> (GenericChart.GenericChart -> GenericChart.GenericChart)
static member Chart.withSize: ?Width: int * ?Height: int -> (GenericChart.GenericChart -> GenericChart.GenericChart)
val gaps: GapStatisticResult[]
val calculate: rndPointGenerator: GenericPointGenerator<'a> -> bootstraps: int -> calcDispersion: GenericClusterDispersion<'a> -> maxK: int -> data: 'a array -> GapStatisticResult[]
module ClusterDispersionMetric from FSharp.Stats.ML.Unsupervised.GapStatistics
val logDispersionKMeansInitRandom: (float[] array -> int -> float)
val k: int[]
val x: GapStatisticResult
GapStatisticResult.ClusterIndex: int
val disp: float[]
GapStatisticResult.Dispersion: float
val dispRef: float[]
GapStatisticResult.ReferenceDispersion: float
val gap: float[]
GapStatisticResult.Gaps: float
val std: float[]
GapStatisticResult.RefDispersionStDev: float
val gapStatisticsChart: GenericChart.GenericChart
val dispersions: GenericChart.GenericChart
val gaps: GenericChart.GenericChart
val sK: float[]
val sd: float
val sqrt: value: 'T -> 'U (requires member Sqrt)
<summary>Square root of the given number</summary>
<param name="value">The input value.</param>
<returns>The square root of the input.</returns>
<example id="log-example"><code lang="fsharp"> sqrt 2.0 // Evaluates to 1.414213562 sqrt 100.0 // Evaluates to 10.0 </code></example>
val gapChart: GenericChart.GenericChart
val kOpt: string
val init: count: int -> initializer: (int -> 'T) -> 'T[]
<summary>Creates an array given the dimension and a generator function to compute the elements.</summary>
<param name="count">The number of elements to initialize.</param>
<param name="initializer">The function to generate the initial values for each index.</param>
<returns>The created array.</returns>
<exception cref="T:System.ArgumentException">Thrown when count is negative.</exception>
<example id="init-1"><code lang="fsharp"> Array.init 4 (fun v -&gt; v + 5) </code> Evaluates to <c>[| 5; 6; 7; 8 |]</c></example>
<example id="init-2"><code lang="fsharp"> Array.init -5 (fun v -&gt; v + 5) </code> Throws <c>ArgumentException</c></example>
property System.Array.Length: int with get
<summary>Gets the total number of elements in all the dimensions of the <see cref="T:System.Array" />.</summary>
<exception cref="T:System.OverflowException">The array is multidimensional and contains more than <see cref="F:System.Int32.MaxValue" /> elements.</exception>
<returns>The total number of elements in all the dimensions of the <see cref="T:System.Array" />; zero if there are no elements in the array.</returns>
val findIndex: predicate: ('T -> bool) -> array: 'T[] -> int
<summary>Returns the index of the first element in the array that satisfies the given predicate. Raise <see cref="T:System.Collections.Generic.KeyNotFoundException" /> if none of the elements satisfy the predicate.</summary>
<param name="predicate">The function to test the input elements.</param>
<param name="array">The input array.</param>
<exception cref="T:System.Collections.Generic.KeyNotFoundException">Thrown if <c>predicate</c> never returns true.</exception>
<exception cref="T:System.ArgumentNullException">Thrown when the input array is null.</exception>
<returns>The index of the first element in the array that satisfies the given predicate.</returns>
<example id="findindex-1"><code lang="fsharp"> let inputs = [| 1; 2; 3; 4; 5 |] inputs |&gt; Array.findIndex (fun elm -&gt; elm % 2 = 0) </code> Evaluates to <c>1</c></example>
<example id="findindex-2"><code lang="fsharp"> let inputs = [| 1; 2; 3; 4; 5 |] inputs |&gt; Array.findIndex (fun elm -&gt; elm % 6 = 0) </code> Throws <c>KeyNotFoundException</c></example>
val id: x: 'T -> 'T
<summary>The identity function</summary>
<param name="x">The input value.</param>
<returns>The same value.</returns>
<example id="id-example"><code lang="fsharp"> id 12 // Evaulates to 12 id "abc" // Evaulates to "abc" </code></example>