Skip to content

Commit

Permalink
v0.9.6 - Use RcppMLPACK directly instead of via a wrapper, emstreeR.
Browse files Browse the repository at this point in the history
  • Loading branch information
gagolews committed Jan 4, 2021
1 parent 87e8769 commit 346a88d
Show file tree
Hide file tree
Showing 60 changed files with 207 additions and 210 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install libcurl4-openssl-dev python3-rpy2 libmlpack-dev r-base-dev python3-dev pandoc
sudo Rscript -e "install.packages(c('genie', 'Rcpp', 'tinytest', 'emstreeR', 'knitr', 'roxygen2'))"
sudo Rscript -e "install.packages(c('genie', 'Rcpp', 'tinytest', 'RcppArmadillo', 'RcppMLPACK', 'knitr', 'roxygen2'))"
#sudo Rscript -e "devtools::install_github('gagolews/Rd2rst')"
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt --upgrade; fi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/r.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install libcurl4-openssl-dev python3-rpy2 libmlpack-dev r-base-dev
sudo Rscript -e "install.packages(c('genie', 'Rcpp', 'tinytest', 'emstreeR', 'roxygen2'))"
sudo Rscript -e "install.packages(c('genie', 'Rcpp', 'tinytest', 'RcppArmadillo', 'RcppMLPACK', 'roxygen2'))"
- name: Test and check R
run: |
sudo make r-test
Expand Down
7 changes: 3 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: genieclust
Type: Package
Title: The Genie++ Hierarchical Clustering Algorithm with Noise Points Detection
Version: 0.9.6
Date: 2021-01-04
Date: 2021-01-05
Authors@R: c(
person("Marek", "Gagolewski",
role = c("aut", "cre", "cph"),
Expand Down Expand Up @@ -37,9 +37,8 @@ Imports:
stats,
utils
Suggests:
datasets,
emstreeR
LinkingTo: Rcpp
datasets
LinkingTo: Rcpp, RcppArmadillo, RcppMLPACK
Encoding: UTF-8
SystemRequirements: OpenMP, C++11
RoxygenNote: 7.1.1
4 changes: 2 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# `genieclust` Package NEWS


## genieclust 0.9.6 (under development)
## genieclust 0.9.6 (2021-01-05)

- [Python] Python >= 3.7 is now required (implied by `numpy`).

- ... (nothing yet) ...
- [R] Use `RcppMLPACK` directly instead of via a wrapper, `emstreeR`.


## genieclust 0.9.5 (2021-01-04)
Expand Down
4 changes: 4 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ pair_sets_index <- function(x, y = NULL) {
.Call(`_genieclust_pair_sets_index`, x, y)
}

.emst_mlpack <- function(X) {
.Call(`_genieclust___emst_mlpack`, X)
}

.gclust <- function(mst, gini_threshold, verbose) {
.Call(`_genieclust___gclust`, mst, gini_threshold, verbose)
}
Expand Down
4 changes: 2 additions & 2 deletions R/gclust.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# ############################################################################ #
# #
# Copyleft (C) 2020, Marek Gagolewski <https://www.gagolewski.com> #
# Copyleft (C) 2020-2021, Marek Gagolewski <https://www.gagolewski.com> #
# #
# #
# This program is free software: you can redistribute it and/or modify #
Expand Down Expand Up @@ -165,7 +165,7 @@
#' pair_sets_index(y_test, y_pred)
#'
#' # Fast for low-dimensional Euclidean spaces:
#' if (require("emstreeR")) h <- gclust(emst_mlpack(X))
#' h <- gclust(emst_mlpack(X))
#'
#' @rdname gclust
#' @export
Expand Down
42 changes: 16 additions & 26 deletions R/mst.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# ############################################################################ #
# #
# Copyleft (C) 2020, Marek Gagolewski <https://www.gagolewski.com> #
# Copyleft (C) 2020-2021, Marek Gagolewski <https://www.gagolewski.com> #
# #
# #
# This program is free software: you can redistribute it and/or modify #
Expand Down Expand Up @@ -177,18 +177,12 @@ registerS3method("mst", "dist", "mst.dist")
#'
#' @description
#' Provides access to an implementation of the Dual-Tree Borůvka
#' algorithm based on kd-trees. It is fast for (very) low-dimensional
#' algorithm based on kd-trees from MLPACK. It is fast for (very) low-dimensional
#' Euclidean spaces. For higher dimensional spaces (say, over 5 features)
#' or other metrics,
#' use the parallelised Prim-like algorithm implemented in \code{\link{mst}()}.
#' or other metrics, use the parallelised Prim-like algorithm implemented
#' in \code{\link{mst}()}.
#'
#'
#' @details
#' Calls \code{emstreeR::mlpack_mst()} and converts the result
#' so that it is compatible with the output of \code{\link{mst}()}.
#'
#' If the \code{emstreeR} package is not available, an error is generated.
#'
#' @param X a numeric matrix (or an object coercible to one,
#' e.g., a data frame with numeric-like columns)
#' @param verbose logical; whether to print diagnostic messages
Expand All @@ -209,20 +203,16 @@ registerS3method("mst", "dist", "mst.dist")
emst_mlpack <- function(X, verbose=FALSE)
{
X <- as.matrix(X)
if (requireNamespace("emstreeR", quietly=TRUE)) {

if (!verbose)
capture.output({mst <- emstreeR:::mlpack_mst(X)})
else
mst <- emstreeR:::mlpack_mst(X)

structure(t(mst),
class="mst",
method="euclidean",
Labels=dimnames(X)[[1]]
)

} else {
stop("emstreeR` package is not installed.")
}

if (!verbose)
capture.output({mst <- .emst_mlpack(X)})
else
mst <- .emst_mlpack(X)

structure(
mst,
class="mst",
method="euclidean",
Labels=dimnames(X)[[1]]
)
}
2 changes: 1 addition & 1 deletion devel/sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# -- Project information -----------------------------------------------------

project = 'genieclust'
copyright = '2020, Marek Gagolewski'
copyright = '2021, Marek Gagolewski'
author = 'Marek Gagolewski'

# The full version, including alpha/beta/rc tags
Expand Down
9 changes: 1 addition & 8 deletions devel/sphinx/rapi/emst_mlpack.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ emst_mlpack: Euclidean Minimum Spanning Tree
Description
~~~~~~~~~~~

Provides access to an implementation of the Dual-Tree Borůvka algorithm based on kd-trees. It is fast for (very) low-dimensional Euclidean spaces. For higher dimensional spaces (say, over 5 features) or other metrics, use the parallelised Prim-like algorithm implemented in `mst() <mst.html>`__.
Provides access to an implementation of the Dual-Tree Borůvka algorithm based on kd-trees from MLPACK. It is fast for (very) low-dimensional Euclidean spaces. For higher dimensional spaces (say, over 5 features) or other metrics, use the parallelised Prim-like algorithm implemented in `mst() <mst.html>`__.

Usage
~~~~~
Expand All @@ -22,13 +22,6 @@ Arguments
| ``verbose`` | logical; whether to print diagnostic messages |
+-------------+------------------------------------------------------------------------------------------------+

Details
~~~~~~~

Calls ``emstreeR::mlpack_mst()`` and converts the result so that it is compatible with the output of `mst() <mst.html>`__.

If the ``emstreeR`` package is not available, an error is generated.

Value
~~~~~

Expand Down
2 changes: 1 addition & 1 deletion devel/sphinx/rapi/gclust.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ Examples
pair_sets_index(y_test, y_pred)
# Fast for low-dimensional Euclidean spaces:
if (require("emstreeR")) h <- gclust(emst_mlpack(X))
h <- gclust(emst_mlpack(X))
6 changes: 2 additions & 4 deletions devel/tinytest/test-gclust.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ if (require("genie")) {
#for (k in 2:20) expect_equal(adjusted_rand_score(cutree(h1, k), cutree(h2, k)), 1.0)
}

if (suppressMessages(require("emstreeR"))) {
print(system.time(h2 <- gclust(emst_mlpack(X, verbose=verbose), verbose=verbose)))
#for (k in 2:20) expect_equal(adjusted_rand_score(cutree(h1, k), cutree(h2, k)), 1.0)
}
print(system.time(h2 <- gclust(emst_mlpack(X, verbose=verbose), verbose=verbose)))
#for (k in 2:20) expect_equal(adjusted_rand_score(cutree(h1, k), cutree(h2, k)), 1.0)


# 2020-06-21
Expand Down
13 changes: 5 additions & 8 deletions devel/tinytest/test-mst.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ expect_true(all(t2[,1] < t2[,2]))
expect_true(all(diff(t2[,3])>=0))



if (require("emstreeR")) {
print(system.time(t2 <- emst_mlpack(X)))
expect_equal(t1[,1], t2[,1])
expect_equal(t1[,2], t2[,2])
print(system.time(t2 <- emst_mlpack(X)))
expect_equal(t1[,1], t2[,1])
expect_equal(t1[,2], t2[,2])
# print(abs(sum(t1[,3])-sum(t2[,3])))
expect_true(abs(sum(t1[,3])-sum(t2[,3]))<1e-12)
}
expect_true(abs(sum(t1[,3])-sum(t2[,3]))<1e-12)



Expand All @@ -50,7 +47,7 @@ for (M in c(1, 5, 10)) {
# print(abs(sum(t1[,3])-sum(t2[,3])))
expect_true(abs(sum(t1[,3])-sum(t2[,3]))<1e-12)

if (distance == "euclidean" && M == 1 && require("emstreeR")) {
if (distance == "euclidean" && M == 1) {
t2 <- emst_mlpack(X)
expect_equal(t1[,1], t2[,1])
expect_equal(t1[,2], t2[,2])
Expand Down
9 changes: 1 addition & 8 deletions docs/_sources/rapi/emst_mlpack.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ emst_mlpack: Euclidean Minimum Spanning Tree
Description
~~~~~~~~~~~

Provides access to an implementation of the Dual-Tree Borůvka algorithm based on kd-trees. It is fast for (very) low-dimensional Euclidean spaces. For higher dimensional spaces (say, over 5 features) or other metrics, use the parallelised Prim-like algorithm implemented in `mst() <mst.html>`__.
Provides access to an implementation of the Dual-Tree Borůvka algorithm based on kd-trees from MLPACK. It is fast for (very) low-dimensional Euclidean spaces. For higher dimensional spaces (say, over 5 features) or other metrics, use the parallelised Prim-like algorithm implemented in `mst() <mst.html>`__.

Usage
~~~~~
Expand All @@ -22,13 +22,6 @@ Arguments
| ``verbose`` | logical; whether to print diagnostic messages |
+-------------+------------------------------------------------------------------------------------------------+

Details
~~~~~~~

Calls ``emstreeR::mlpack_mst()`` and converts the result so that it is compatible with the output of `mst() <mst.html>`__.

If the ``emstreeR`` package is not available, an error is generated.

Value
~~~~~

Expand Down
2 changes: 1 addition & 1 deletion docs/_sources/rapi/gclust.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ Examples
pair_sets_index(y_test, y_pred)
# Fast for low-dimensional Euclidean spaces:
if (require("emstreeR")) h <- gclust(emst_mlpack(X))
h <- gclust(emst_mlpack(X))
2 changes: 1 addition & 1 deletion docs/_static/documentation_options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: '0.9.6.dev0',
VERSION: '0.9.6',
LANGUAGE: 'None',
COLLAPSE_INDEX: false,
BUILDER: 'html',
Expand Down
6 changes: 3 additions & 3 deletions docs/genieclust.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Python Package genieclust Reference &mdash; genieclust 0.9.6.dev0 documentation</title>
<title>Python Package genieclust Reference &mdash; genieclust 0.9.6 documentation</title>



Expand Down Expand Up @@ -66,7 +66,7 @@


<div class="version">
0.9.6.dev0
0.9.6
</div>


Expand Down Expand Up @@ -261,7 +261,7 @@ <h1>Python Package <cite>genieclust</cite> Reference<a class="headerlink" href="
<div role="contentinfo">
<p>

&copy; Copyright 2020, Marek Gagolewski
&copy; Copyright 2021, Marek Gagolewski

</p>
</div>
Expand Down
6 changes: 3 additions & 3 deletions docs/genieclust_compare_partitions.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>genieclust.compare_partitions &mdash; genieclust 0.9.6.dev0 documentation</title>
<title>genieclust.compare_partitions &mdash; genieclust 0.9.6 documentation</title>



Expand Down Expand Up @@ -66,7 +66,7 @@


<div class="version">
0.9.6.dev0
0.9.6
</div>


Expand Down Expand Up @@ -822,7 +822,7 @@
<div role="contentinfo">
<p>

&copy; Copyright 2020, Marek Gagolewski
&copy; Copyright 2021, Marek Gagolewski

</p>
</div>
Expand Down
6 changes: 3 additions & 3 deletions docs/genieclust_genie.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>genieclust.Genie &mdash; genieclust 0.9.6.dev0 documentation</title>
<title>genieclust.Genie &mdash; genieclust 0.9.6 documentation</title>



Expand Down Expand Up @@ -66,7 +66,7 @@


<div class="version">
0.9.6.dev0
0.9.6
</div>


Expand Down Expand Up @@ -610,7 +610,7 @@ <h1>genieclust.Genie<a class="headerlink" href="#genieclust-genie" title="Permal
<div role="contentinfo">
<p>

&copy; Copyright 2020, Marek Gagolewski
&copy; Copyright 2021, Marek Gagolewski

</p>
</div>
Expand Down
6 changes: 3 additions & 3 deletions docs/genieclust_inequity.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>genieclust.inequity &mdash; genieclust 0.9.6.dev0 documentation</title>
<title>genieclust.inequity &mdash; genieclust 0.9.6 documentation</title>



Expand Down Expand Up @@ -66,7 +66,7 @@


<div class="version">
0.9.6.dev0
0.9.6
</div>


Expand Down Expand Up @@ -379,7 +379,7 @@
<div role="contentinfo">
<p>

&copy; Copyright 2020, Marek Gagolewski
&copy; Copyright 2021, Marek Gagolewski

</p>
</div>
Expand Down
6 changes: 3 additions & 3 deletions docs/genieclust_internal.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>genieclust.internal &mdash; genieclust 0.9.6.dev0 documentation</title>
<title>genieclust.internal &mdash; genieclust 0.9.6 documentation</title>



Expand Down Expand Up @@ -66,7 +66,7 @@


<div class="version">
0.9.6.dev0
0.9.6
</div>


Expand Down Expand Up @@ -540,7 +540,7 @@
<div role="contentinfo">
<p>

&copy; Copyright 2020, Marek Gagolewski
&copy; Copyright 2021, Marek Gagolewski

</p>
</div>
Expand Down
Binary file modified docs/genieclust_plots-1.pdf
Binary file not shown.
Binary file modified docs/genieclust_plots-2.pdf
Binary file not shown.
Binary file modified docs/genieclust_plots-3.pdf
Binary file not shown.
Binary file modified docs/genieclust_plots-4.pdf
Binary file not shown.
Loading

0 comments on commit 346a88d

Please sign in to comment.