Skip to content

Commit

Permalink
CompatHelper: bump compat for "PrettyTables" to "0.11" (#260)
Browse files Browse the repository at this point in the history
* CompatHelper: bump compat for "PrettyTables" to "0.11"

* Update `rstar` docstring and tests

* Bump version

* Fix remaining test error

* Update docstring accordingly

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David Widmann <[email protected]>
  • Loading branch information
github-actions[bot] and devmotion authored Feb 12, 2021
1 parent 19e563b commit 9dcd979
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uuid = "c7f686f2-ff18-58e9-bc7b-31028e88f75d"
keywords = ["markov chain monte carlo", "probablistic programming"]
license = "MIT"
desc = "Chain types and utility functions for MCMC simulations."
version = "4.6.0"
version = "4.7.0"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down Expand Up @@ -36,7 +36,7 @@ Formatting = "0.4"
IteratorInterfaceExtensions = "0.1.1, 1"
MLJModelInterface = "0.3.5, 0.4"
NaturalSort = "1"
PrettyTables = "0.9, 0.10"
PrettyTables = "0.9, 0.10, 0.11"
RecipesBase = "0.7, 0.8, 1.0"
SpecialFunctions = "^0.8, 0.9, 0.10, 1.0"
StatsBase = "0.32, 0.33"
Expand Down
25 changes: 12 additions & 13 deletions src/rstar.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""
rstar([rng ,] classif::Supervised, chains::Chains; kwargs...)
rstar([rng ,] classif::Supervised, x::AbstractMatrix, y::AbstractVector; kwargs...)
rstar([rng ,]classif::Supervised, chains::Chains; kwargs...)
rstar([rng ,]classif::Supervised, x::AbstractMatrix, y::AbstractVector; kwargs...)
Compute the R* convergence diagnostic of MCMC.
This implementation is an adaption of Algorithm 1 & 2, described in [Lambert & Vehtari]. Note that the correctness of the statistic depends on the convergence of the classifier used internally in the statistic. You can track if the training of the classifier converged by inspection of the printed RMSE values from the XGBoost backend. To adjust the number of iterations used to train the classifier set `niter` accordingly.
This implementation is an adaption of Algorithm 1 & 2, described in [^LambertVehtari]. Note
that the correctness of the statistic depends on the convergence of the classifier used
internally in the statistic. You can inspect the training of the classifier by adjusting the
verbosity level.
# Keyword Arguments
* `subset = 0.8` ... Subset used to train the classifier, i.e. 0.8 implies 80% of the samples are used.
Expand All @@ -14,15 +17,12 @@ This implementation is an adaption of Algorithm 1 & 2, described in [Lambert & V
# Usage
```julia
using MLJ, MLJModels
# You need to load MLJBase and the respective package your are using for classification first.
# Load an MLJ classifier to compute the statistic, e.g., the XGBoost classifier.
using MLJModels
XGBoost = @load XGBoostClassifier
# Select a classifier to compute the Rstar statistic.
# For example the XGBoost classifier.
classif = @load XGBoostClassifier()
# Compute 100 samples of the R* statistic using sampling from according to the prediction probabilities.
Rs = rstar(classif, chn, iterations = 20)
# Compute 20 samples of the R* statistic using sampling from according to the prediction probabilities.
Rs = rstar(XGBoost(), chn; iterations=20)
# estimate Rstar
R = mean(Rs)
Expand All @@ -31,8 +31,7 @@ R = mean(Rs)
histogram(Rs)
```
## References:
[Lambert & Vehtari] Ben Lambert and Aki Vehtari. "R∗: A robust MCMC convergence diagnostic with uncertainty using gradient-boostined machines." Arxiv 2020.
[^LambertVehtari]: Ben Lambert and Aki Vehtari. "R∗: A robust MCMC convergence diagnostic with uncertainty using gradient-boostined machines." Arxiv 2020.
"""
function rstar(rng::Random.AbstractRNG, classif::MLJModelInterface.Supervised, x::AbstractMatrix, y::AbstractVector{Int}; iterations = 10, subset = 0.8, verbosity = 0)

Expand Down
4 changes: 2 additions & 2 deletions test/rstar_tests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using MCMCChains
using MLJModels
using MLJXGBoostInterface
using Test

N = 1000
Expand All @@ -9,7 +8,8 @@ colnames = ["a", "b", "c", "d", "e", "f", "g", "h"]
internal_colnames = ["c", "d", "e", "f", "g", "h"]
chn = Chains(val, colnames, Dict(:internals => internal_colnames))

classif = @load XGBoostClassifier()
XGBoost = @load XGBoostClassifier
classif = XGBoost()

@testset "R star test" begin
# Compute R* statistic for a mixed chain.
Expand Down

2 comments on commit 9dcd979

@cpfiffer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/29985

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v4.7.0 -m "<description of version>" 9dcd97999404e9694ebef905acf47616a84775a7
git push origin v4.7.0

Please sign in to comment.