geocmeans

geocmeans: An R package for spatial fuzzy c-means - Published in JOSS (2023)

https://github.com/jeremygelb/geocmeans

Science Score: 93.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 12 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

clustering cmeans fuzzy-classification-algorithms r spatial-analysis spatial-fuzzy-cmeans unsupervised-learning
Last synced: 6 months ago · JSON representation

Repository

An R package to perform Spatial Fuzzy C-means

Basic Info
  • Host: GitHub
  • Owner: JeremyGelb
  • License: gpl-2.0
  • Language: R
  • Default Branch: master
  • Homepage:
  • Size: 136 MB
Statistics
  • Stars: 28
  • Watchers: 1
  • Forks: 2
  • Open Issues: 0
  • Releases: 1
Topics
clustering cmeans fuzzy-classification-algorithms r spatial-analysis spatial-fuzzy-cmeans unsupervised-learning
Created almost 6 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog Contributing License Codemeta

README.md

geocmeans

An R package to perform Spatial Fuzzy C-means.

R-CMD-check Codecov test
coverage DOI

The website of the package is available here

Breaking news

Here we are! We are moving from maptools, sp, rgeos, raster and rgdal to sf, terra and tmap. All the functions and the documentation were modified accordingly. If you spot an error or a bug, please open an issue on github.

Installation

The stable version of geocmeans is available on CRAN. You can install it with the command below.

install.packages("geocmeans")

You can install a development version of the geocmeans package using the command below.

remotes::install_github(repo = "JeremyGelb/geocmeans", build_vignettes = TRUE, force = TRUE)

Authors

Jeremy Gelb, Laboratoire d’Équité Environnemental INRS (CANADA), Email: jeremy.gelb@ucs.inrs.ca

Contributors

Philippe Apparicio, Laboratoire d’Équité Environnemental INRS (CANADA), Email: philippe.apparicio@ucs.inrs.ca

About the package

Provides functions to apply Spatial Fuzzy c-means Algorithm, visualize and interpret results. This method is well suited when the user wants to analyze data with a fuzzy clustering algorithm and to account for the spatial dimension of the dataset. In addition, indexes for measuring the spatial consistency and classification quality are proposed. The algorithms were developed first for brain imagery as described in the articles of Cai and al. 2007 and Zaho and al. 2013. Gelb and Apparicio proposed to apply the method to perform a socio-residential and environmental taxonomy in Lyon (France). The methods can be applied to dataframes or to rasters.

Fuzzy classification algorithms

Four Fuzzy classification algorithms are proposed :

  • FCM: Fuzzy C-Means, with the function CMeans
  • GFCM: Generalized Fuzzy C-Means, with the function GFCMeans
  • SFCM: Spatial Fuzzy C-Means, with the function SFCMeans
  • SGFCM: Spatial Generalized Fuzzy C-Means, with the function SGFCMeans

Each function return a membership matrix, the data used for the classification (scaled if required) and the centers of the clusters.

For each algorithm, it is possible to calculate a “robust version” and to add a noise group (used to catch outliers). See the parameters robust and noise_cluser in the documentation for more details.

Parameter selections

The algorithms available require different parameters to be fixed by the user. The function selectParameters is a useful tool to compare the results of different combinations of parameters. A multicore version, selectParameters.mc, using a plan from the package future is also available to speed up the calculus.

Classification quality

Many indices of classification quality can be calculated with the function calcqualityIndexes:

  • Silhouette.index: the silhouette index (fclust::SIL.F)
  • Partition.entropy: the partition entropy index (fclust::PE)
  • Partition.coeff: the partition entropy coefficient (fclust::PC)
  • Modified.partition.coeff: the modified partition entropy coefficient (fclust::MPC)
  • XieBeni.index: the Xie and Beni index (fclust::XB)
  • FukuyamaSugeno.index: the Fukuyama and Sugeno index (geocmeans::calcFukuyamaSugeno)
  • DavidBoudlin.index: the David-Bouldin index (geocmeans::calcDavidBouldin)
  • CalinskiHarabasz.index: the Calinski-Harabasz index (geocmeans::calcCalinskiHarabasz)
  • GD43.index and GD53.index: two version of the generalized Dunn index (geocmeans::calcGD43 and calcGD53)
  • Negentropy.index: the Negentropy Increment index (geocmeans::calcNegentropyI)
  • Explained.inertia: the percentage of total inertia explained by the solution

Classification consistency

To assess the stability of the obtained clusters, a function for bootstrap validation is proposed: boot_group_validation. The results can be used to verify if the obtained clusters are stable and how much their centres vary.

Reproductibility

Clustering methods like CMeans depend on the initial centers selected. In geocmeans, they are selected randomly, and two runs of the functions can yield different results. To facilitate the reproductibility of the results, the main functions of the package (CMeans, GFCMeans, SFCMeans, SGFCMeans, selectParameters, selectParameters.mc) have a seed parameter. It can be set by the user to ensure that the results of the functions are exactly the same.

Interpretation

Several functions are also available to facilitate the interpretation of the classification:

  • summary statistics for each cluster: summarizeClusters (also accessible with the generic function summary)
  • spider charts: spiderPlots
  • violin plots: violinPlots
  • maps of the membership matrix: mapClusters (support polygon, points and polylines)

There is also a shiny app that can be used to go deeper in the result interpretation. It requires the packages shiny, leaflet, bslib, plotly, shinyWidgets, car.

Alt Text

Spatial diagnostic

Several spatial indices can be calculated to have a better spatial understanding of the obtained clusters, like the global or local Moran I calculated on the membership values, or the join-count-test on the most likely group for each observation. ELSA and Fuzzy ELSA statistics can also be calculated to identify areas with high or low multidimensional spatial autocorrelation in the membership values. See functions spConsistency, calcELSA, calcFuzzyELSA and spatialDiag.

We proposed an index to quantify the spatial inconsistency of a classification (Gelb and Apparicio). If in a classification close observations tend to belong to the same group, then the value of the index is close to 0. If the index is close to 1, then the belonging to groups is randomly distributed in space. A value higher than one can happen in the case of negative spatial autocorrelation. The index is described in the vignette adjustinconsistency. The function spatialDiag does a complete spatial diagnostic of the membership matrix resulting from a classification.

Examples

Detailed examples are given in the vignette introduction

vignette("introduction","geocmeans")

Testing

If you would like to install and run the unit tests interactively, include INSTALL_opts = "--install-tests" in the installation code.

remotes::install_github(repo = "JeremyGelb/geocmeans", build_vignettes = TRUE, force = TRUE, INSTALL_opts = "--install-tests")
testthat::test_package("geocmeans", reporter = "stop")

Contribute

To contribute to geocmeans, please follow these guidelines.

Please note that the geocmeans project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

geocmeans version 0.3.4 is licensed under GPL2 License.

JOSS Publication

geocmeans: An R package for spatial fuzzy c-means
Published
September 26, 2023
Volume 8, Issue 89, Page 5259
Authors
Gelb Jeremy ORCID
Laboratoire d'Équité Environnemental, Institut National de la Recherche Scientifique (INRS)
Editor
Martin Fleischmann ORCID
Tags
unsupervised classification cmeans spatial analysis fuzzy classification

GitHub Events

Total
  • Issues event: 1
  • Watch event: 1
  • Issue comment event: 2
  • Push event: 1
Last Year
  • Issues event: 1
  • Watch event: 1
  • Issue comment event: 2
  • Push event: 1

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 173
  • Total Committers: 2
  • Avg Commits per committer: 86.5
  • Development Distribution Score (DDS): 0.162
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
JeremyGelb j****b@u****a 145
JeremyGelb g****2@g****m 28
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 8
  • Total pull requests: 0
  • Average time to close issues: about 1 month
  • Average time to close pull requests: N/A
  • Total issue authors: 7
  • Total pull request authors: 0
  • Average comments per issue: 2.38
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: 7 months
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • HenrikBengtsson (1)
  • vincentj10 (1)
  • rsbivand (1)
  • KatieMurenbeeld (1)
  • Naeemkh (1)
  • JeremyGelb (1)
  • StephanLo (1)
Pull Request Authors
Top Labels
Issue Labels
bug (2)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • cran 318 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 9
  • Total maintainers: 1
proxy.golang.org: github.com/JeremyGelb/geocmeans
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.7%
Last synced: 6 months ago
proxy.golang.org: github.com/jeremygelb/geocmeans
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.7%
Last synced: 6 months ago
cran.r-project.org: geocmeans

Implementing Methods for Spatial Fuzzy Unsupervised Classification

  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 318 Last month
Rankings
Stargazers count: 11.3%
Forks count: 17.8%
Average: 26.5%
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Downloads: 37.9%
Maintainers (1)
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.5 depends
  • Rcpp >= 1.0.6 imports
  • Rdpack >= 2.1.1 imports
  • dplyr >= 0.8.3 imports
  • fclust >= 2.1.1 imports
  • fmsb >= 0.7.0 imports
  • future.apply >= 1.4.0 imports
  • ggplot2 >= 3.2.1 imports
  • grDevices >= 3.5 imports
  • leaflet >= 2.0.4.1 imports
  • matrixStats >= 0.58.0 imports
  • methods >= 3.5 imports
  • plotly >= 4.9.3 imports
  • progressr >= 0.4.0 imports
  • raster >= 3.4 imports
  • reldist >= 1.6.6 imports
  • reshape2 >= 1.4.4 imports
  • rgeos >= 0.5 imports
  • shiny >= 1.6.0 imports
  • sp >= 1.4 imports
  • spdep >= 1.1.2 imports
  • stats >= 3.5 imports
  • ClustGeo >= 2.0 suggests
  • RColorBrewer >= 1.1 suggests
  • bslib >= 0.2.5 suggests
  • car >= 3.0 suggests
  • covr * suggests
  • future >= 1.16.0 suggests
  • ggpubr >= 0.2.5 suggests
  • kableExtra >= 1.1.0 suggests
  • knitr >= 1.28 suggests
  • maptools >= 0.9 suggests
  • markdown >= 1.1 suggests
  • ppclust >= 1.1.0 suggests
  • rgdal >= 1.5 suggests
  • rgl >= 0.100 suggests
  • rmarkdown >= 2.1 suggests
  • sf >= 0.9 suggests
  • shinyWidgets >= 0.6 suggests
  • shinyhelper >= 0.3.2 suggests
  • testthat >= 3.0.0 suggests
  • tmap >= 3.3 suggests
  • viridis >= 0.5.1 suggests
  • waiter >= 0.2.2 suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/upload-artifact main composite
  • actions/upload-artifact v1 composite
  • openjournals/openjournals-draft-action master composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
.github/workflows/draft-pdf.yml actions
  • actions/checkout v2 composite
  • actions/upload-artifact v1 composite
  • openjournals/openjournals-draft-action master composite
.github/workflows/pkgdown.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
  • r-lib/actions/setup-r-dependencies v1 composite