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

ERROR: LoadError: Cannot convert CounterfactualData to series data for plotting #462

Open
feldob opened this issue Jul 18, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@feldob
Copy link

feldob commented Jul 18, 2024

I am trying to follow the tutorial and run into problems. This is the error I get for the first code snippet on the page:

ERROR: LoadError: Cannot convert CounterfactualData to series data for plotting
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] _prepare_series_data(x::CounterfactualData)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/BGM3l/src/series.jl:8
  [3] _series_data_vector(x::CounterfactualData, plotattributes::Dict{Symbol, Any})
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/BGM3l/src/series.jl:36
  [4] macro expansion
    @ ~/.julia/packages/RecipesPipeline/BGM3l/src/series.jl:129 [inlined]
  [5] apply_recipe(plotattributes::AbstractDict{Symbol, Any}, ::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl:300
  [6] _process_userrecipes!(plt::Any, plotattributes::Any, args::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jl:38
  [7] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jl:72
  [8] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
    @ Plots ~/.julia/packages/Plots/du2dt/src/plot.jl:223
  [9] plot!(plt::Plots.Plot, args::Any; kw...)
    @ Plots ~/.julia/packages/Plots/du2dt/src/plot.jl:213
 [10] plot!(args::Any; kw...)
    @ Plots ~/.julia/packages/Plots/du2dt/src/plot.jl:202
 [11] scatter!(args::Any; kw...)
    @ Plots ~/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl:429
 [12] top-level scope
    @ /usr/src/app/script.jl:9
in expression starting at /usr/src/app/script.jl:9

Seems like some sort of binding is missing to the plotting library to support the library specific structs. Do I need additional dependencies or loaded modules? I created a Dockerfile and a script for reproducibility:

FROM julia:rc-bookworm

# Set the working directory
WORKDIR /usr/src/app

# Install required Julia packages
RUN julia -e 'using Pkg; Pkg.add(url="https://github.com/JuliaTrustworthyAI/TaijaData.jl")'
RUN julia -e 'using Pkg; Pkg.add(url="https://github.com/JuliaTrustworthyAI/CounterfactualExplanations.jl")'
RUN julia -e 'using Pkg; Pkg.add("Plots")'

# Copy the Julia script into the container
COPY script.jl .

# Command to run the script
CMD ["julia", "script.jl"]

For completeness, here is the code from script.jl:

using CounterfactualExplanations, TaijaData, Plots

n = 500
data = TaijaData.load_moons(n)
counterfactual_data = CounterfactualExplanations.DataPreprocessing.CounterfactualData(data...)
X = counterfactual_data.X
y = counterfactual_data.y
plt = plot()
scatter!(counterfactual_data)

Best Regards
Felix

@pat-alt
Copy link
Member

pat-alt commented Jul 18, 2024

Hi Felix, the piece that's missing here is using TaijaPlotting. That part of the code is omitted in the tutorial although it probably shouldn't be. Sorry about this and thanks for flagging. I'll keep this issue open as a reminder to update the docs.

@pat-alt pat-alt added the documentation Improvements or additions to documentation label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants