# mlr3cluster 0.5.0

## New learners

* `clust.gmeans`: G-means clustering from the gmeans package, which extends k-means by automatically determining the number of clusters.
* `clust.kmeans_rcpp`: K-means clustering via `ClusterR::KMeans_rcpp()` from the ClusterR package.
* `clust.kmodes`: K-modes clustering for categorical data from the klaR package.

## New measures

* `clust.sse_ratio`: Within-cluster sum of squares divided by total sum of squares, a normalized measure of cluster compactness.

## Other improvements

* `clust.cobweb` now exposes the `output_debug_info` parameter, matching the other RWeka-based learners.
* `clust.cobweb`, `clust.em`, `clust.ff`, and `clust.SimpleKMeans` now support marshaling.
* `clust.kcca` now exposes simulated annealing through `classify = "simann"` and the `simann` parameter.
* `clust.meanshift` now predicts on new data. It runs mean shift from each observation with the bandwidth and convergence threshold used for training, then assigns the observation to the mode it reaches. Previously, prediction warned and returned the training partition.
* `clust.movMF` now exposes the `ids` parameter, which initializes the EM algorithm from fixed component memberships.
* `clust.protoclust` now predicts on new data by assigning each observation to the cluster with the nearest prototype. Previously, prediction warned and returned the training partition. Its model now stores the fitted object and training data in a list.
* `clust.skmeans` now exposes `start` for selecting the initialization and `maxchains` for the `"pclust"` and `"LIHC"` methods.
* `clust.stdbscan` now supports observation weights through `weights`, matching `clust.dbscan`.

## Bug fixes

* Clustering measures now handle character features consistently with factor and ordered features. Distance-based measures use Gower distances instead of treating character values as missing, while measures that require numeric features report an informative error.
* `as_prediction_clust()` now converts whole-numbered `partition` values to integers instead of rejecting them.
* `clust.agnes`, `clust.diana`, `clust.genie`, and `clust.hclust` now validate `k` against the number of training observations when predicting. They previously used the number of rows in the new data even though `cutree()` cuts the training tree.
* `clust.ap` now breaks similarity ties deterministically when predicting, matching the assignment rule of the apcluster package.
* `clust.ap` no longer fails to train on tasks with a feature named `m`.
* `clust.bico` and `clust.kcca` now require `k >= 2`, matching their existing training requirements. Invalid values now fail when set rather than during training.
* `clust.clara` and `clust.pam` now reject prediction when trained with `stand = TRUE`, because `clue::cl_predict()` would otherwise assign clusters using unstandardized new data.
* `clust.cmeans` now returns a plain probability matrix without `clue`'s internal attributes.
* `clust.cobweb`, `clust.ff`, and `clust.xmeans` now allow the seed `S = 0`, which Weka accepts, matching the seed bound of `clust.em` and `clust.SimpleKMeans`.
* `clust.dbscan_fpc` now rejects prediction when trained with `scale = TRUE`. This prevents comparisons between unscaled new data and `eps`, which applies to the scaled training data.
* `clust.hclust` and `clust.protoclust` now require the Minkowski power `p` to be greater than 0, matching `stats::dist()`.
* `clust.hdbscan` now requires `minPts >= 2`, matching `dbscan::hdbscan()`. Smaller values now fail when set rather than during training.
* `clust.kcca` now validates `initcent` as a single string and documents its default as `"randomcent"`. Invalid values now fail when set rather than producing an obscure S4 validity error during training.
* `clust.kcca` no longer exposes the `ntry` and `min.size` parameters, which are `flexclust::qtclust()` control options that `flexclust::kcca()` ignores.
* `clust.kkmeans` now resolves prediction distance ties with `"first"` instead of `"random"`, so predictions are reproducible without setting a seed.
* `clust.mclust` now stores `$assignments` as an integer vector, consistent with the other learners, instead of the double vector returned by mclust.
* `clust.optics`, `clust.som`, and `clust.tclust` now coerce logical features to numeric, so tasks with only logical features train and predict instead of erroring in the upstream packages.
* `clust.SimpleKMeans` now declares `min_density` as a nonnegative double instead of a positive integer, since Weka accepts fractional canopy densities.
* `PredictionClust` now preserves measure weights from tasks with a `weights_measure` column in `$weights` and `as.data.table()` instead of dropping them.
* `PredictionClust` now errors during construction when a partition label has no matching `prob` column, instead of silently accepting inconsistent predictions.

# mlr3cluster 0.4.1

## Bug fixes

* `clust.agnes`, `clust.diana`, `clust.genie`, `clust.hclust`, and `clust.protoclust` now cut the tree at the current `k` when predicting, so changing `k` between training and prediction takes effect.
* `clust.ap` no longer errors when affinity propagation finds a single cluster.
* `clust.bico` now reclusters the BICO coreset with k-means via `stream::DSC_TwoStage()`, so `k` determines the number of predicted clusters instead of returning the raw micro-clusters. Training warns when the coreset is too small to produce `k` clusters.
* `clust.clara` now errors informatively when predicting with `metric = "jaccard"` or `medoids.x = FALSE` instead of failing with an obscure upstream error.
* `clust.dbscan_fpc` now errors informatively when predicting after training with `seeds = FALSE` instead of failing with an obscure upstream error.
* `clust.flexmix` now trains via `flexmix::stepFlexmix()`, so `nrep` actually runs repeated EM initializations and keeps the best fit instead of being silently ignored. Setting `nrep` together with `cluster` now errors.
* `clust.genie`, `clust.kkmeans`, and `clust.kproto` now error informatively during training when the task has fewer than 2 features, which the upstream implementations cannot handle.
* `clust.kkmeans` now predicts by assigning observations to the nearest cluster centroid in the kernel-induced feature space, since input-space distances produced wrong assignments for nonlinear kernels. The model is now a list with the fitted object, training data, and per-cluster kernel statistics.
* `clust.movMF` now derives the stored `$assignments` from the predict method, so predicting on the training data yields the training assignments.
* `clust.som` now predicts and derives the stored `$assignments` via `kohonen::map()`, so models trained with `keep.data = FALSE` no longer fail at predict or store empty assignments.
* `clust.stdbscan` now errors during training when the task does not have exactly 3 features (two spatial coordinates and one temporal coordinate) instead of silently using the wrong columns.
* `clust.tclust` no longer exposes the `iter.max` parameter, which is deprecated in tclust 2.0 in favor of `niter1`, `niter2`, and `nkeep`.
* `clust.wss` and `clust.entropy` now return `NaN` instead of 0 for empty predictions, which for `clust.wss` silently skewed aggregated resampling scores.
* `PredictionClust`: combined and empty prediction data now retain the `PredictionData` class, so `resample()` no longer errors on resampling iterations with an empty test set.
* `PredictionClust`: when the partition is derived from a probability matrix, it now uses the cluster labels from the column names instead of the column positions.
* `PredictionClust`: empty prob predictions now combine with non-empty ones without error and no longer serialize a spurious `prob.V1` column via `as.data.table()`.
* `PredictionClust`: `as.data.table()` no longer drops the partition column for prob-only predictions constructed with `check = FALSE`, returning `NA` partitions instead.

# mlr3cluster 0.4.0

## New learners

* `clust.flexmix`: Finite mixture model clustering from the flexmix package.
* `clust.genie`: Genie hierarchical clustering from the genieclust package.
* `clust.kcca`: K-centroids cluster analysis from the flexclust package, supporting k-means, k-medians, spherical, Jaccard, and extended Jaccard families.
* `clust.movMF`: Von Mises-Fisher mixture clustering from the movMF package.
* `clust.skmeans`: Spherical k-means clustering from the skmeans package.
* `clust.som`: Self-organizing maps from the kohonen package.
* `clust.stdbscan`: ST-DBSCAN spatio-temporal clustering from the stdbscan package (#83).
* `clust.tclust`: Robust trimmed clustering from the tclust package.

## New measures

* `clust.avg_between`: Average between-cluster distance.
* `clust.avg_within`: Average within-cluster distance.
* `clust.davies_bouldin`: Davies-Bouldin index.
* `clust.dunn2`: Alternative Dunn index using average distances.
* `clust.entropy`: Cluster size distribution entropy.
* `clust.pearsongamma`: Pearson Gamma correlation between distances and cluster membership.
* `clust.wb_ratio`: Within/between distance ratio.

## Other improvements

* Learners no longer store the training data or dissimilarity matrix in the model by default: `clust.agnes`, `clust.diana`, `clust.fanny`, and `clust.pam` now expose `keep.diss` and `keep.data`, `clust.clara` and `clust.kproto` expose `keep.data`, and `clust.ap` exposes `includeSim`, all initialized to `FALSE`. Set the respective parameter to `TRUE` to restore the previous behavior.
* Clustering quality measures `clust.ch`, `clust.dunn`, and `clust.wss` are now computed natively instead of relying on `fpc::cluster.stats()`. The fpc package is no longer a hard dependency.
* `clust.cobweb`, `clust.em`, `clust.ff`, `clust.SimpleKMeans`, and `clust.xmeans` now declare the `missings` property, since Weka handles missing attribute values natively.
* `clust.diana` gains the `stop.at.k` parameter from `cluster::diana()`.
* `clust.em` drops the `exclusive` property and `clust.MBatchKMeans` drops `fuzzy`. Use the `prob` predict type to select learners with soft memberships.

## Bug fixes

* `mlr3cluster` is now added to `mlr_reflections$loaded_packages` to fix errors when using the package in parallel.
* `as_prediction_clust.data.frame()` no longer errors with `unused argument (with = FALSE)` when given a plain `data.frame`.
* `clust.cmeans` now reports a proper error message when an invalid `weights` value is given instead of failing with a type error.
* `clust.cmeans`, `clust.kkmeans`, and `clust.kmeans` now accept a matrix of initial cluster centers for the `centers` parameter, matching the upstream functions.
* `clust.cobweb` now declares the `hierarchical` property instead of `partitional`, and `clust.meanshift` declares `density` instead of `partitional`.
* `clust.dbscan`, `clust.dbscan_fpc`, `clust.hdbscan`, and `clust.optics` now declare the `partial` property instead of `complete`, since these algorithms can leave observations unassigned (noise points labeled 0).
* `clust.featureless` now returns `prob` predictions whose most probable cluster matches the predicted `partition`, with cluster column names consistent with the other learners supporting the `prob` predict type.
* `clust.silhouette` now returns `NaN` instead of `0` when all observations belong to a single cluster, since the silhouette width is undefined for k < 2.

# mlr3cluster 0.3.0

* feat: Add CLARA clustering learner `clust.clara` from the cluster package.
* feat: Add k-prototypes clustering learner `clust.kproto` from the clustMixType package.
* feat: Add spectral clustering learner `clust.specc` from the kernlab package.
* fix: `LearnerClustDBSCANfpc` now correctly passes the `newdata` argument in the predict method.
* fix: `LearnerClustKKMeans` now correctly passes kernel parameters via the `kpar` list to `kernlab::kkmeans()`.
* fix: `clust.silhouette` measure now has the correct range of `[-1, 1]`.
* docs: Fix typos in measure documentation.

# mlr3cluster 0.2.0

* feat: `Mlr3Error` and `Mlr3Warning` classes for errors and warnings.
* feat: Add protoclust learner from the protoclust package.
* feat: EM learner now supports probabilistic assignments.
* fix: Update learner parameter sets to match upstream package changes.
* docs: Documentation improvements.
* chore: mlr3cluster now requires R 3.4.0. Following data.table's minimum R version.
* chore: mlr3cluster now requires mlr3 (>= 1.3.0) and mlr3misc (>= 0.19.0).

# mlr3cluster 0.1.12

* feat: Add `cluster_selection_epsilon` parameter to HDBSCAN learner and
  initialize `minPts` to 5.
* docs: Better learner example section.

# mlr3cluster 0.1.11

* fix: Mclust learner no longer sets the control default with a function not in
  import to stay compliant with paradox package conventions.

# mlr3cluster 0.1.10

* feat: Add BIRCH learner from the stream package.
* feat: Add BICO learner from the stream package.

# mlr3cluster 0.1.9

* feat: Add DBSCAN learner from the fpc package.
* feat: Add HDBSCAN learner from the dbscan package.
* feat: Add OPTICS learner from the dbscan package.
* chore: Compatibility with upcoming paradox release.
* chore: Move to testthat3.
* refactor: General code refactoring.

# mlr3cluster 0.1.8

* feat: Add new task based on `ruspini` dataset.

# mlr3cluster 0.1.7

* chore: Replace 'clusterCrit' measures with alternatives from cluster and fpc packages.
* fix: Remove broken unloading test.

# mlr3cluster 0.1.6

* feat: Add states as row names to `usarrests` task.
* fix: Remove dictionary items after unloading package.

# mlr3cluster 0.1.5

* feat: Add Mclust learner.
* fix: Fix error associated with new dbscan release.

# mlr3cluster 0.1.4

* refactor: General code refactoring.

# mlr3cluster 0.1.3

* feat: Add filter to `PredictionClust`.
* fix: Small bug fixes.
* refactor: General code refactoring.

# mlr3cluster 0.1.2

* feat: Add Hclust learner.
* feat: Add within sum of squares measure.
* docs: Add tests and documentation for Hclust.
* docs: Add documentation for WSS measure.
* refactor: Code factor adaptations.

# mlr3cluster 0.1.1

* feat: Add eight new learners.
* feat: Add `assignments` and `save_assignments` fields to `LearnerClust` class.

# mlr3cluster 0.1.0

* Initial upload to CRAN.
