-
Notifications
You must be signed in to change notification settings - Fork 7
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
436 dont pass entire data container #439
Conversation
src/counterfactuals/core_struct.jl
Outdated
:iteration_count => 0, | ||
:mutability => DataPreprocessing.mutability_constraints(data), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
:iteration_count => 0, | |
:mutability => DataPreprocessing.mutability_constraints(data), | |
:iteration_count => 0, :mutability => DataPreprocessing.mutability_constraints(data) |
src/objectives/distance_utils.jl
Outdated
@@ -39,6 +39,7 @@ end | |||
Computes the distance of the counterfactual from a point in the target main. | |||
""" | |||
function distance_from_target(ce::AbstractCounterfactualExplanation; K::Int=50, kwrgs...) | |||
get!(ce.search, :potential_neighbours, CounterfactualExplanations.find_potential_neighbours(ce)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
get!(ce.search, :potential_neighbours, CounterfactualExplanations.find_potential_neighbours(ce)) | |
get!( | |
ce.search, | |
:potential_neighbours, | |
CounterfactualExplanations.find_potential_neighbours(ce), | |
) |
src/counterfactuals/core_struct.jl
Outdated
4. Initializes the loss. | ||
""" | ||
function initialize!(ce::CounterfactualExplanation) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
src/objectives/penalties.jl
Outdated
|
||
return loss | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
end | |
end |
src/objectives/traits.jl
Outdated
PenaltyRequirements(::Type{<:typeof(distance_from_target)}) = | ||
NeedsNeighbours() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
PenaltyRequirements(::Type{<:typeof(distance_from_target)}) = | |
NeedsNeighbours() | |
PenaltyRequirements(::Type{<:typeof(distance_from_target)}) = NeedsNeighbours() |
src/generators/Generators.jl
Outdated
|
||
Computes the total loss of a counterfactual explanation with respect to the search objective. | ||
""" | ||
total_loss(ce::AbstractCounterfactualExplanation) = ℓ(ce.generator, ce) + h(ce.generator, ce) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
total_loss(ce::AbstractCounterfactualExplanation) = ℓ(ce.generator, ce) + h(ce.generator, ce) | |
total_loss(ce::AbstractCounterfactualExplanation) = | |
ℓ(ce.generator, ce) + h(ce.generator, ce) |
src/generators/Generators.jl
Outdated
|
||
Computes the total loss of a counterfactual explanation with respect to the search objective. | ||
""" | ||
total_loss(ce::AbstractCounterfactualExplanation) = hasfield(typeof(ce.generator), :loss) ? ℓ(ce.generator, ce) + h(ce.generator, ce) : nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
total_loss(ce::AbstractCounterfactualExplanation) = hasfield(typeof(ce.generator), :loss) ? ℓ(ce.generator, ce) + h(ce.generator, ce) : nothing | |
total_loss(ce::AbstractCounterfactualExplanation) = if hasfield(typeof(ce.generator), :loss) | |
ℓ(ce.generator, ce) + h(ce.generator, ce) | |
else | |
nothing | |
end |
src/objectives/traits.jl
Outdated
|
||
Check if a generator needs access to neighbors in the target class. | ||
""" | ||
needs_neighbours(gen::AbstractGenerator) = hasfield(typeof(gen), :penalty) ? any(needs_neighbours.(gen.penalty)) : false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
needs_neighbours(gen::AbstractGenerator) = hasfield(typeof(gen), :penalty) ? any(needs_neighbours.(gen.penalty)) : false | |
needs_neighbours(gen::AbstractGenerator) = | |
hasfield(typeof(gen), :penalty) ? any(needs_neighbours.(gen.penalty)) : false |
src/generators/Generators.jl
Outdated
total_loss(ce::AbstractCounterfactualExplanation) = if hasfield(typeof(ce.generator), :loss) | ||
ℓ(ce.generator, ce) + h(ce.generator, ce) | ||
else | ||
nothing | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
total_loss(ce::AbstractCounterfactualExplanation) = if hasfield(typeof(ce.generator), :loss) | |
ℓ(ce.generator, ce) + h(ce.generator, ce) | |
else | |
nothing | |
end | |
total_loss(ce::AbstractCounterfactualExplanation) = | |
if hasfield(typeof(ce.generator), :loss) | |
ℓ(ce.generator, ce) + h(ce.generator, ce) | |
else | |
nothing | |
end |
|
||
Fit a transformer to the data for an `InputTransformer` object. This is a no-op. | ||
""" | ||
function fit_transformer(data::CounterfactualData, input_encoder::InputTransformer; kwargs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function fit_transformer(data::CounterfactualData, input_encoder::InputTransformer; kwargs...) | |
function fit_transformer( | |
data::CounterfactualData, input_encoder::InputTransformer; kwargs... | |
) |
It turns out that passing the data container was not the issue: I tried using Instead, there were a few unnecessary forward passes through the entire dataset that have now been removed. There is now little to no dependency of performance on the dataset size (as in number of samples). |
No description provided.