From fb064fe1d69a2e91787bf62bfe7c27a6ad0c0da9 Mon Sep 17 00:00:00 2001 From: Oskar Laverny Date: Mon, 25 Mar 2024 09:05:46 +0100 Subject: [PATCH 1/4] Update shapley_sensitivity.jl --- src/shapley_sensitivity.jl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/shapley_sensitivity.jl b/src/shapley_sensitivity.jl index 321fbd86..e9f10154 100644 --- a/src/shapley_sensitivity.jl +++ b/src/shapley_sensitivity.jl @@ -121,11 +121,20 @@ function find_cond_mean_var(cov::Matrix, return conditional_mean, conditional_var end -function cond_sampling(distribution::SklarDist, +function cond_sampling(distribution::SklarDist{Independentcopula{d},Tm}, + n_sample::Int, + idx::Vector{Int}, + idx_c::Vector{Int}, + x_cond::AbstractArray) where {d,Tm} + # conditional sampling in independent random vector is just subset sampling. + rand(Copulas.subsetdims(distribution, idx, n_sample) # this might need to be transposed. +end + +function cond_sampling(distribution::SklarDist{GaussianCopula{d,TΣ},Tm}, n_sample::Int, idx::Vector{Int}, idx_c::Vector{Int}, - x_cond::AbstractArray) + x_cond::AbstractArray) where {d,TΣ,Tm} # select the correct marginal distributions for the two subsets of features margins_dependent = [distribution.m[Int(i)] for i in idx] From d0232aadb870c02643c3db7779e004b4bba370cb Mon Sep 17 00:00:00 2001 From: Oskar Laverny Date: Mon, 25 Mar 2024 14:15:53 +0100 Subject: [PATCH 2/4] typo --- src/shapley_sensitivity.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shapley_sensitivity.jl b/src/shapley_sensitivity.jl index e9f10154..4ad701a0 100644 --- a/src/shapley_sensitivity.jl +++ b/src/shapley_sensitivity.jl @@ -127,7 +127,7 @@ function cond_sampling(distribution::SklarDist{Independentcopula{d},Tm}, idx_c::Vector{Int}, x_cond::AbstractArray) where {d,Tm} # conditional sampling in independent random vector is just subset sampling. - rand(Copulas.subsetdims(distribution, idx, n_sample) # this might need to be transposed. + rand(Copulas.subsetdims(distribution, idx, n_sample)) # this might need to be transposed. end function cond_sampling(distribution::SklarDist{GaussianCopula{d,TΣ},Tm}, From 85b45db49173388a0db47e4d6a95265fefd8795f Mon Sep 17 00:00:00 2001 From: Oskar Laverny Date: Mon, 25 Mar 2024 14:54:40 +0100 Subject: [PATCH 3/4] typo --- src/shapley_sensitivity.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shapley_sensitivity.jl b/src/shapley_sensitivity.jl index 4ad701a0..e5a7bde0 100644 --- a/src/shapley_sensitivity.jl +++ b/src/shapley_sensitivity.jl @@ -121,7 +121,7 @@ function find_cond_mean_var(cov::Matrix, return conditional_mean, conditional_var end -function cond_sampling(distribution::SklarDist{Independentcopula{d},Tm}, +function cond_sampling(distribution::SklarDist{IndependentCopula{d},Tm}, n_sample::Int, idx::Vector{Int}, idx_c::Vector{Int}, From d3a593ff008ff95c004b35b8ba157b1cd445819d Mon Sep 17 00:00:00 2001 From: Oskar Laverny Date: Mon, 25 Mar 2024 16:50:12 +0100 Subject: [PATCH 4/4] Make tests pass (still working on the docs, we'll see) --- src/shapley_sensitivity.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shapley_sensitivity.jl b/src/shapley_sensitivity.jl index e5a7bde0..0570ef0f 100644 --- a/src/shapley_sensitivity.jl +++ b/src/shapley_sensitivity.jl @@ -127,7 +127,7 @@ function cond_sampling(distribution::SklarDist{IndependentCopula{d},Tm}, idx_c::Vector{Int}, x_cond::AbstractArray) where {d,Tm} # conditional sampling in independent random vector is just subset sampling. - rand(Copulas.subsetdims(distribution, idx, n_sample)) # this might need to be transposed. + rand(Copulas.subsetdims(distribution, idx), n_sample) # this might need to be transposed. end function cond_sampling(distribution::SklarDist{GaussianCopula{d,TΣ},Tm},