Newer
Older
Penalty for smooth conformal set size.
"""
function set_size_penalty(
conf_model = ce.M.model
fitresult = ce.M.fitresult
X = CounterfactualExplanations.decode_state(ce)
loss = map(eachslice(X, dims=ndims(X))) do x
x = ndims(x) == 1 ? x[:,:] : x
if target_probs(ce, x)[1] >= 0.5
κ=κ,
temp=temp
)[1]
else
l = 0.0
end
return l
end
loss = agg(loss)
return loss
end
function distance_from_energy(
n::Int=10, niter=60, from_buffer=true, agg=mean, kwargs...
_dict[:energy_sampler] = ECCCo.EnergySampler(ce; niter=niter, nsamples=n, kwargs...)
push!(conditional_samples, rand(sampler, n; from_buffer=from_buffer))
loss = map(eachslice(x′, dims=ndims(x′))) do x
end
function distance_from_targets(
target_idx = ce.data.output_encoder.labels .== ce.target
target_samples = ce.data.X[:,target_idx] |>
Δ = map(eachcol(target_samples)) do xsample
end
return mean(Δ)
end