Clustering of points: k-means++, fuzzy k-means, DBSCAN and hierarchical clustering, with cluster validation helpers.
K-means++, fuzzy k-means and DBSCAN are backed by Apache Commons Math. Points are sequences of numbers (or arrays); a plain number is a 1-dimensional point. All points have to have the same, non-zero dimension and finite coordinates.
Every clustering function returns a vector of cluster maps (hclust returns it as :clusters). A cluster map contains:
:representative - the centre of the cluster (centroid for k-means++ and fuzzy k-means, the mean of cluster points for DBSCAN and hierarchical clustering),:size - the number of points,:indices - positions of the cluster points in the input sequence (the order within a cluster is not specified),:data - the cluster points (vectors of doubles), unless :add-data? is false.The order of clusters and the choice of representatives of k-means++, fuzzy k-means and DBSCAN depend on the random number generator. The default :rng is a new generator for every call, pass a seeded generator (fastmath.random/rng) for reproducible results.
Options are validated: an invalid option throws ex-info with the keys :option, :value and :expected. :value is the invalid value; it is nil when the value is the whole input or a whole result (data can be large), and a single point when the points differ in dimension. Unknown option keys are ignored.
:distance is a keyword (:euclidean, :chebyshev, :manhattan, :canberra, :earth-movers), a function of two points (ie. a function from fastmath.distance) or an Apache Commons Math DistanceMeasure (hclust takes a keyword or a function only, or :precomputed for a distance matrix). A distance has to be non-negative and equal to 0 for equal points (d(x, x) = 0): the radius selection of dbscan and silhouette rely on it and return wrong values otherwise.
Hierarchical clustering (hclust) returns a map with the cluster maps (:clusters) and the tree of merges (:tree, a dendrogram in the format of R hclust); cut cuts the tree into another number of clusters, cophenetic, cophenetic-correlation and ->linkage-matrix work on the tree.
Functions: kmeans++, fuzzy-kmeans, dbscan, infer-dbscan-radius, hclust (clustering and the radius selection), predict, wcss, silhouette (working on a clustering result), cut, cophenetic, cophenetic-correlation, ->linkage-matrix (working on a result of hclust).
Clustering of points: k-means++, fuzzy k-means, DBSCAN and hierarchical clustering, with cluster validation helpers. K-means++, fuzzy k-means and DBSCAN are backed by Apache Commons Math. Points are sequences of numbers (or arrays); a plain number is a 1-dimensional point. All points have to have the same, non-zero dimension and finite coordinates. Every clustering function returns a vector of cluster maps ([[hclust]] returns it as `:clusters`). A cluster map contains: - `:representative` - the centre of the cluster (centroid for k-means++ and fuzzy k-means, the mean of cluster points for DBSCAN and hierarchical clustering), - `:size` - the number of points, - `:indices` - positions of the cluster points in the input sequence (the order within a cluster is not specified), - `:data` - the cluster points (vectors of doubles), unless `:add-data?` is `false`. The order of clusters and the choice of representatives of k-means++, fuzzy k-means and DBSCAN depend on the random number generator. The default `:rng` is a new generator for every call, pass a seeded generator (`fastmath.random/rng`) for reproducible results. Options are validated: an invalid option throws `ex-info` with the keys `:option`, `:value` and `:expected`. `:value` is the invalid value; it is `nil` when the value is the whole input or a whole result (data can be large), and a single point when the points differ in dimension. Unknown option keys are ignored. `:distance` is a keyword (`:euclidean`, `:chebyshev`, `:manhattan`, `:canberra`, `:earth-movers`), a function of two points (ie. a function from `fastmath.distance`) or an Apache Commons Math `DistanceMeasure` ([[hclust]] takes a keyword or a function only, or `:precomputed` for a distance matrix). A distance has to be non-negative and equal to 0 for equal points (`d(x, x) = 0`): the radius selection of [[dbscan]] and [[silhouette]] rely on it and return wrong values otherwise. Hierarchical clustering ([[hclust]]) returns a map with the cluster maps (`:clusters`) and the tree of merges (`:tree`, a dendrogram in the format of R `hclust`); [[cut]] cuts the tree into another number of clusters, [[cophenetic]], [[cophenetic-correlation]] and [[->linkage-matrix]] work on the tree. Functions: [[kmeans++]], [[fuzzy-kmeans]], [[dbscan]], [[infer-dbscan-radius]], [[hclust]] (clustering and the radius selection), [[predict]], [[wcss]], [[silhouette]] (working on a clustering result), [[cut]], [[cophenetic]], [[cophenetic-correlation]], [[->linkage-matrix]] (working on a result of [[hclust]]).
Linear and generalized linear regression models with analysis, categorical encodings and isotonic regression.
lm fits ordinary (OLS) and weighted (WLS) least squares models, glm fits generalized linear models with the IRLS method for the families and links stored in families and links (custom ones are created with ->family and ->link), glm-nbinomial additionally estimates theta of the negative binomial family. Both fit functions can use an offset, weights, a transformation of the terms (see polynomial-transformer, trigonometric-transformer and b-spline-transformer) and regularization by data augmentation (add-penalty).
A fitted model is a record which can be called as a function (see predict). analysis returns leverage, residuals and influence measures, quantile-residuals the randomized quantile residuals of a GLM and dose the lethal or effective dose of a binomial model. Categorical terms are encoded with fastmath.ml.regression.contrast.
Linear and generalized linear regression models with analysis, categorical encodings and isotonic regression. [[lm]] fits ordinary (OLS) and weighted (WLS) least squares models, [[glm]] fits generalized linear models with the IRLS method for the families and links stored in [[families]] and [[links]] (custom ones are created with [[->family]] and [[->link]]), [[glm-nbinomial]] additionally estimates theta of the negative binomial family. Both fit functions can use an offset, weights, a transformation of the terms (see [[polynomial-transformer]], [[trigonometric-transformer]] and [[b-spline-transformer]]) and regularization by data augmentation ([[add-penalty]]). A fitted model is a record which can be called as a function (see [[predict]]). [[analysis]] returns leverage, residuals and influence measures, [[quantile-residuals]] the randomized quantile residuals of a GLM and [[dose]] the lethal or effective dose of a binomial model. Categorical terms are encoded with `fastmath.ml.regression.contrast`. Isotonic regression is available as [[pava]] and [[cir]].
Categorical data manipulation and various encoding methods.
A coding (contrast) replaces a categorical variable with n-1 numeric columns, which can be used as terms of a regression model. A coding is a map with the keys :levels, :names (names of the columns) and :mapping (a map from a level to a vector of n-1 coefficients).
Levels are collected from the data with ->levels. The order of levels matters: the first level is the reference of dummy and simple, the last one is dropped by deviation. To use a different reference, as contr.treatment(base=) of R, pass an explicit order to ->levels. A coding is applied to a column with encode, the meaning of the coefficients is returned by mean-contrasts.
Codings: dummy, simple, deviation, polynomial, helmert, reverse-helmert, reverse-helmert-unscaled, forward-difference, backward-difference and difference.
Categorical data manipulation and various encoding methods. A coding (contrast) replaces a categorical variable with `n-1` numeric columns, which can be used as terms of a regression model. A coding is a map with the keys `:levels`, `:names` (names of the columns) and `:mapping` (a map from a level to a vector of `n-1` coefficients). Levels are collected from the data with [[->levels]]. The order of levels matters: the first level is the reference of [[dummy]] and [[simple]], the last one is dropped by [[deviation]]. To use a different reference, as `contr.treatment(base=)` of R, pass an explicit `order` to [[->levels]]. A coding is applied to a column with [[encode]], the meaning of the coefficients is returned by [[mean-contrasts]]. Codings: [[dummy]], [[simple]], [[deviation]], [[polynomial]], [[helmert]], [[reverse-helmert]], [[reverse-helmert-unscaled]], [[forward-difference]], [[backward-difference]] and [[difference]].
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |