Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Shapley method #158

Conversation

devmotion
Copy link
Member

This PR seems to fix the docs issues in #134 locally.

@Vaibhavdixit02 Vaibhavdixit02 merged commit bedb96e into compathelper/new_version/2023-11-14-23-08-53-265-03909794485 Apr 4, 2024
4 of 5 checks passed
# conditional sampling in independent random vector is just subset sampling.
Array(rand(Copulas.subsetdims(distribution, idx), n_sample)') # this might need to be transposed.
samples = zeros(eltype(x_cond), length(idx), n_sample)
Copy link
Member Author

Choose a reason for hiding this comment

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

Preallocation is a bit safer, otherwise the eltype of the samples can be a bit surprising (see below).

if n_dep == 1
dist_cond = Normal(cond_mean[1, 1], cond_var[1, 1])
sample_norm = rand(dist_cond, n_sample)
dist_cond = Normal(cond_mean[1, 1], sqrt(cond_var[1, 1]))
Copy link
Member Author

Choose a reason for hiding this comment

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

The second argument of Normal is the standard deviation.

Comment on lines +103 to +104
# The copula returns samples of `Float64`s
θ = convert(AbstractArray{Float32}, θ)
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is an upstream problem - the copula (and hence also input_distribution) lost the type information and generate samples of type Float64.

Copy link
Member

Choose a reason for hiding this comment

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

yup makes sense cc:@lrnv

Copy link
Contributor

@lrnv lrnv Apr 4, 2024

Choose a reason for hiding this comment

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

Yep Copulas.jl was intended to be type-agnostic at the beginning, but sometimes it gets it wrong, as Distributions.jl… see, e.g., there. And since I did not write tests from the beginning for this particular feature, I forgot about it.

Opened an issue, will look at it when I have a bit of time (not right now, unfortunately) For the moment you have to keep this convertion as far as i can tell, sorry about that.

@devmotion devmotion deleted the dw/copula branch April 4, 2024 01:35
@Vaibhavdixit02
Copy link
Member

Sorry for the delay in fixing it I know you guys were waiting on it but I got busy and this wasn't as trivial as it seemed. Great stuff as always @devmotion, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants