From e0622a370e034312b3e0a1664a40a6992ff3d0de Mon Sep 17 00:00:00 2001 From: Leon Haufe Date: Wed, 29 Jan 2025 09:53:03 +0100 Subject: [PATCH 1/4] removed normalization --- README.md | 13 ++----------- src/ParallelPlots.jl | 24 ++---------------------- test/runtests.jl | 1 - test/test_call_with_normalize.jl | 16 ---------------- test/test_recipe_observable.jl | 7 ++----- 5 files changed, 6 insertions(+), 55 deletions(-) delete mode 100644 test/test_call_with_normalize.jl diff --git a/README.md b/README.md index 6f5bbfd..d346325 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,7 @@ This Project is for the TU-Berlin Course "Julia Programming for Machine Learning Please make sure, that Julia `1.10` is used! This Module will return you a nice Scene you can use to display your Data with [Parallel Coordinates](https://en.wikipedia.org/wiki/Parallel_coordinates)
- - -_This Module was created with PkgTemplates.jl_ + ## Getting Started @@ -30,7 +28,6 @@ using ParallelPlots | Parameter | Default | Example | Description | |-------------------|----------|------------------------------------|------------------------------------------------------------------------------------------------------------------------| -| normalize::Bool | false | normalize=true | If the Data should be normalized (min/max) | | title::String | "" | title="My Title" | The Title of The Figure, | | colormap | :viridis | colormap=:thermal | The Colors of the [Lines](https://docs.makie.org/dev/explanations/colors) | | color_feature | nothing | color_feature="weight" | The Color of the Lines will be based on the values of this selected feature. If nothing, the last feature will be used | @@ -46,10 +43,6 @@ julia> using ParallelPlots julia> parallelplot(DataFrame(height=160:180,weight=60:80,age=20:40)) ``` ``` -# If you want to normalize the Data, you can add the value normalized=true, default is false -julia> parallelplot(DataFrame(height=160:180,weight=reverse(60:80),age=20:40),normalize=true) -``` -``` # If you want to set the size of the plot (default width:800, height:600) julia> parallelplot( DataFrame(height=160:180,weight=60:80,age=20:40), figure = (resolution = (300, 300),) ) ``` @@ -69,7 +62,7 @@ julia> parallelplot(DataFrame(height=160:180,weight=reverse(60:80),age=20:40), f ``` # Adjust Color and and feature parallelplot(df, - # You choose which axis/feature should be in charge for the coloring + # You choose which axis/feature should be in charge for the coloring color_feature="weight", # you can as well select, which Axis should be shown feature_selection=["height","age","income"], @@ -84,8 +77,6 @@ parallelplot(df, ) ``` -Please read the [Docs](/docs/build/index.html) for further Information - ### Working on ParallelPlots / Cheatsheet 1. Using ParallelPlots * Moving to the project folder diff --git a/src/ParallelPlots.jl b/src/ParallelPlots.jl index c0879a5..ffe0fa2 100644 --- a/src/ParallelPlots.jl +++ b/src/ParallelPlots.jl @@ -4,16 +4,6 @@ using CairoMakie using DataFrames -function normalize_DF(data::DataFrame) - for col in names(data) - data[!, col] = (data[!, col] .- minimum(data[!, col])) ./ - (maximum(data[!, col]) - minimum(data[!, col])) - end - - return data -end - - function input_data_check(data::DataFrame) if isnothing(data) throw(ArgumentError("Data cannot be nothing")) @@ -35,14 +25,13 @@ end # Constructors ```julia -ParallelPlot(data::DataFrame; normalize::Bool=false) +ParallelPlot(data::DataFrame, _Arguments_) ``` # Arguments | Parameter | Default | Example | Description | |-------------------|----------|------------------------------------|------------------------------------------------------------------------------------------------------------------------| -| normalize::Bool | false | normalize=true | If the Data should be normalized (min/max) | | title::String | "" | title="My Title" | The Title of The Figure, | | colormap | :viridis | colormap=:thermal | The Colors of the [Lines](https://docs.makie.org/dev/explanations/colors) | | color_feature | nothing | color_feature="weight" | The Color of the Lines will be based on the values of this selected feature. If nothing, the last feature will be used | @@ -57,9 +46,6 @@ ParallelPlot(data::DataFrame; normalize::Bool=false) julia> using ParallelPlots julia> parallelplot(DataFrame(height=160:180,weight=60:80,age=20:40)) -# If you want to normalize the Data, you can add the value normalized=true, default is false -julia> parallelplot(DataFrame(height=160:180,weight=reverse(60:80),age=20:40),normalize=true) - # If you want to set the size of the plot julia> parallelplot( DataFrame(height=160:180,weight=60:80,age=20:40), figure = (resolution = (300, 300),) ) @@ -94,7 +80,6 @@ parallelplot(df, @recipe(ParallelPlot, df) do scene Attributes( # additional attributes - normalize = false, title = "", # Title of the Figure colormap = :viridis, # https://docs.makie.org/dev/explanations/colors color_feature = nothing, # Which feature to use for coloring (column name) @@ -116,11 +101,6 @@ function Makie.plot!(pp::ParallelPlot) # check the given DataFrame input_data_check(data) - # Normalize the data if required - if pp.normalize[] - data = normalize_DF(data) - end - # Get the Fig and empty it, so its nice and clean for the next itaration fig = current_figure() empty!(fig) @@ -236,7 +216,7 @@ function Makie.plot!(pp::ParallelPlot) # add listener to Observable Arguments and trigger an update on change # loop thorough the given Arguments for kw in pp.kw - # e.g. normalize + # e.g. curve attribute_key = kw[1] on(pp[attribute_key]) do x # trigger update diff --git a/test/runtests.jl b/test/runtests.jl index 8454a75..a83b7a4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,7 +4,6 @@ include("test_argument_errors.jl") include("test_curved.jl") include("test_call_with_color_feature.jl") include("test_call_with_feature_labels.jl") -include("test_call_with_normalize.jl") include("test_custom_dimensions.jl") include("test_default_call.jl") include("test_recipe_observable.jl") diff --git a/test/test_call_with_normalize.jl b/test/test_call_with_normalize.jl deleted file mode 100644 index 4658137..0000000 --- a/test/test_call_with_normalize.jl +++ /dev/null @@ -1,16 +0,0 @@ -using ParallelPlots: parallelplot -using Test: @testset, @test - -@testset "call with normalize" begin - - # Generate sample multivariate data - df = create_person_df() - - #display - fig = parallelplot(df, normalize=true; title="Normalize") - - @test fig !== nothing - - save("parallel_coordinates_plot_normalized.png", fig) - -end \ No newline at end of file diff --git a/test/test_recipe_observable.jl b/test/test_recipe_observable.jl index a6a58af..6147695 100644 --- a/test/test_recipe_observable.jl +++ b/test/test_recipe_observable.jl @@ -9,11 +9,10 @@ using DataFrames # create the Data df_observable = Observable(create_person_df(2)) title_observable = Observable("") - normalize_observable = Observable(true) curve_observable = Observable(true) # create the Plot - fig, ax, sc = parallelplot(df_observable, normalize=normalize_observable, title=title_observable, curve = curve_observable) + fig, ax, sc = parallelplot(df_observable, title=title_observable, curve = curve_observable) save("pcp_initialized.png", fig) # we can change a parameter and the graph will be automaticly changed @@ -26,14 +25,12 @@ using DataFrames # Update Dataframe if(iseven(t)) - normalize_observable[] = false curve_observable[] = false title_observable[] = "" df_observable[] = create_person_df(5) else - normalize_observable[] = true curve_observable[] = true - title_observable[] = "Normalize" + title_observable[] = "Curved" df_observable[] = create_car_df(t) end From 96abfa62a8ee0c2de1675095431138a28c431405 Mon Sep 17 00:00:00 2001 From: Leon Haufe Date: Wed, 29 Jan 2025 09:55:03 +0100 Subject: [PATCH 2/4] removed normalization --- test/test_call_with_normalize.jl | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 test/test_call_with_normalize.jl diff --git a/test/test_call_with_normalize.jl b/test/test_call_with_normalize.jl deleted file mode 100644 index e69de29..0000000 From a2e9711cce8748191550c3409d9f42f7e6a7b154 Mon Sep 17 00:00:00 2001 From: Leon Haufe Date: Wed, 29 Jan 2025 10:19:24 +0100 Subject: [PATCH 3/4] removed normalization --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d346325..1ce220d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This Project is for the TU-Berlin Course "Julia Programming for Machine Learning"
Please make sure, that Julia `1.10` is used! -This Module will return you a nice Scene you can use to display your Data with [Parallel Coordinates](https://en.wikipedia.org/wiki/Parallel_coordinates)
+This Module will return you a nice Makie Plot you can use to display your Data with [Parallel Coordinates](https://en.wikipedia.org/wiki/Parallel_coordinates)
## Getting Started From 6829f113fc2691c085b758f4c9e8eb1ca36fa9e9 Mon Sep 17 00:00:00 2001 From: Leon Haufe Date: Wed, 29 Jan 2025 15:13:02 +0100 Subject: [PATCH 4/4] resolve Bug in Julia 1.6 --- test/test_recipe_observable.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_recipe_observable.jl b/test/test_recipe_observable.jl index 6487dad..4810469 100644 --- a/test/test_recipe_observable.jl +++ b/test/test_recipe_observable.jl @@ -5,7 +5,7 @@ using Test: @testset @testset "Use a Observable DataFrame" begin # create the Data - df_observable = Observable(create_person_df(2)) + df_observable = Observable(create_person_df(3)) title_observable = Observable("") curve_observable = Observable(true) @@ -29,7 +29,7 @@ using Test: @testset else curve_observable[] = true title_observable[] = "Curved" - df_observable[] = create_car_df(t) + df_observable[] = create_car_df(t+1) end