From f6a8f6adb2877f754fc2b873bf35c51370f3af84 Mon Sep 17 00:00:00 2001 From: smo Date: Fri, 31 Jan 2025 15:58:03 +0100 Subject: [PATCH 1/2] add description of makie to readme --- README.md | 18 ++++++++++-------- docs/src/getting_started.md | 19 +++++++++---------- docs/src/index.md | 8 +++++--- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index aab93b0..a4a4462 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,10 @@ 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 Makie Plot you can use to display your Data with [Parallel Coordinates](https://en.wikipedia.org/wiki/Parallel_coordinates)
+This Module will return a nice Makie Plot you can use to display your Data using a [Parallel Coordinate Plot](https://en.wikipedia.org/wiki/Parallel_coordinates)
. +The package is heavily based on [Makie](https://docs.makie.org/). This is a data visualization tool that can be used to display various plots such as interactive 3d plots, static vector graphics or plots in a browser. Makie offers four backends that can be chosen from. This project uses [CairoMakie](https://docs.makie.org/stable/explanations/backends/cairomakie#CairoMakie) which is good for plotting vector graphics. ## Getting Started ### Install Dependencies & Use ParallelPlots @@ -23,18 +24,19 @@ Pkg.add(url="https://github.com/moritz155/ParallelPlots") using ParallelPlots ``` ### Usage +The plot can be customized in many ways. For that, parameters with the according values have to be passed along with the function call. Examples for function calls are depicted below. #### Available Parameter | Parameter | Default | Example | Description | |-------------------|----------|------------------------------------------|------------------------------------------------------------------------------------------------------------------------| -| title::String | "" | title="My Title" | The Title of The Figure, | +| 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 | -| feature_labels | nothing | feature_labels=["Weight","Age"] | Add your own Axis labels, just use the exact amount of labes as you have axis | -| feature_selection | nothing | feature_selection=["weight","age"] | Select, which features should be Displayed. If color_feature is not in this List, use the last one | -| curve | false | curve=true | Show the Lines Curved | -| show_color_legend | nothing | show_color_legend=true | Show the Color Legend. If parameter not set & color_feature not shown, it will be displayed automaticly | -| scale | nothing | scale=[identity, log, log2, log10, sqrt] | Choose, how each Axis should be scaled. | +| 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. | +| feature_labels | nothing | feature_labels=["Weight","Age"] | Add your own Axis labels, just make sure to use the exact amount of labels you have | +| feature_selection | nothing | feature_selection=["weight","age"] | Select which features should be Displayed. If color_feature is not in this List, use the last one | +| curve | false | curve=true | Either curved edges or sharp edges | +| show_color_legend | nothing | show_color_legend=true | Show the Color Legend. If parameter not set & color_feature not shown, it will be displayed automatically | +| scale | nothing | scale=[identity, log, log2, log10, sqrt] | Choose the scale of the axis. There must be one for each Y-axis. | #### Examples diff --git a/docs/src/getting_started.md b/docs/src/getting_started.md index be7d839..e3ca600 100644 --- a/docs/src/getting_started.md +++ b/docs/src/getting_started.md @@ -1,4 +1,3 @@ - # Getting Started ## Install Dependencies & Use ParallelPlots @@ -11,19 +10,19 @@ Pkg.add(url="https://github.com/moritz155/ParallelPlots") using ParallelPlots ``` ## Usage -### Available Parameter +The plot can be customized in many ways. For that, parameters with the according values have to be passed along with the function call. Examples for function calls are depicted below. +### Available Parameters | Parameter | Default | Example | Description | |-------------------|----------|------------------------------------------|------------------------------------------------------------------------------------------------------------------------| -| title::String | "" | title="My Title" | The Title of The Figure, | +| 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 | -| feature_labels | nothing | feature_labels=["Weight","Age"] | Add your own Axis labels, just use the exact amount of labes as you have axis | -| feature_selection | nothing | feature_selection=["weight","age"] | Select, which features should be Displayed. If color_feature is not in this List, use the last one | -| curve | false | curve=true | Show the Lines Curved | -| show_color_legend | nothing | show_color_legend=true | Show the Color Legend. If parameter not set & color_feature not shown, it will be displayed automaticly | -| scale | nothing | scale=[identity, log, log2, log10, sqrt] | Choose, how each Axis should be scaled. | - +| 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. | +| feature_labels | nothing | feature_labels=["Weight","Age"] | Add your own Axis labels, just make sure to use the exact amount of labels you have | +| feature_selection | nothing | feature_selection=["weight","age"] | Select which features should be Displayed. If color_feature is not in this List, use the last one | +| curve | false | curve=true | Either curved edges or sharp edges | +| show_color_legend | nothing | show_color_legend=true | Show the Color Legend. If parameter not set & color_feature not shown, it will be displayed automatically | +| scale | nothing | scale=[identity, log, log2, log10, sqrt] | Choose the scale of the axis. There must be one for each Y-axis. | ### Examples ``` diff --git a/docs/src/index.md b/docs/src/index.md index 23edfbf..591c814 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -5,8 +5,10 @@ [![Coverage](https://codecov.io/gh/moritz155/ParallelPlots/branch/main/graph/badge.svg)](https://codecov.io/gh/moritz155/ParallelPlots) ## General -This Project is for the TU-Berlin Course "Julia Programming for Machine Learning" +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) -![Parallel Plot Image](https://raw.githubusercontent.com/moritz155/ParallelPlots/refs/heads/main/test/projectile_simulation.png) +This Module will return a nice Makie Plot you can use to display your Data using a [Parallel Coordinate Plot](https://en.wikipedia.org/wiki/Parallel_coordinates)
. + + +The package is heavily based on [Makie](https://docs.makie.org/). This is a data visualization tool that can be used to display various plots such as interactive 3d plots, static vector graphics or plots in a browser. Makie offers four backends that can be chosen from. This project uses [CairoMakie](https://docs.makie.org/stable/explanations/backends/cairomakie#CairoMakie) which is good for plotting vector graphics. \ No newline at end of file From 9c84d9b1b44f6081867a871c2588e46ad90d257e Mon Sep 17 00:00:00 2001 From: smo Date: Fri, 31 Jan 2025 16:31:22 +0100 Subject: [PATCH 2/2] add chatgpt prompts --- chatgpt1.txt | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++ chatgpt12.txt | 96 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 chatgpt1.txt create mode 100644 chatgpt12.txt diff --git a/chatgpt1.txt b/chatgpt1.txt new file mode 100644 index 0000000..aaa3bc3 --- /dev/null +++ b/chatgpt1.txt @@ -0,0 +1,98 @@ +Q: Please write a julia function that receives an array of dicts and returns a subarray of dicts so that each entry in the array has at least two distinct values +A: I've created a function that: + + Takes an array of dictionaries as input + Uses filter() with a predicate function + For each dictionary, checks if the number of unique values is >= 2 using unique(values(dict)) + Returns only the dictionaries that meet this criteria + + In the example usage, only the second, third, and fifth dictionaries would be included in the result since they have at least two distinct values. + Would you like me to modify the function in any way or add additional functionality? + function filter_distinct_values(arr_of_dicts) + # Filter the array to keep only dicts with at least 2 distinct values + return filter(dict -> length(unique(values(dict))) >= 2, arr_of_dicts) + end + + # Example usage: + test_array = [ + Dict("a" => 1, "b" => 1, "c" => 1), # All same values + Dict("a" => 1, "b" => 2, "c" => 1), # Two distinct values + Dict("a" => 1, "b" => 2, "c" => 3), # Three distinct values + Dict("x" => "hello", "y" => "hello"), # All same values + Dict("x" => "hello", "y" => "world"), # Two distinct values + ] + + filtered = filter_distinct_values(test_array) +Q: 54-element Vector{Dict{String, Real}}: + Dict("launch_angles" => 0, "initial_velocities" => 40.0, "gravities" => 9.0, "air_resistances" => 0.0) + Dict("launch_angles" => 45, "initial_velocities" => 40.0, "gravities" => 9.0, "air_resistances" => 0.0) + Dict("launch_angles" => 90, "initial_velocities" => 40.0, "gravities" => 9.0, "air_resistances" => 0.0) + Dict("launch_angles" => 0, "initial_velocities" => 50.0, "gravities" => 9.0, "air_resistances" => 0.0) + Dict("launch_angles" => 45, "initial_velocities" => 50.0, "gravities" => 9.0, "air_resistances" => 0.0) + Dict("launch_angles" => 90, "initial_velocities" => 50.0, "gravities" => 9.0, "air_resistances" => 0.0) + Dict("launch_angles" => 0, "initial_velocities" => 40.0, "gravities" => 9.5, "air_resistances" => 0.0) + Dict("launch_angles" => 45, "initial_velocities" => 40.0, "gravities" => 9.5, "air_resistances" => 0.0) + Dict("launch_angles" => 90, "initial_velocities" => 40.0, "gravities" => 9.5, "air_resistances" => 0.0) + Dict("launch_angles" => 0, "initial_velocities" => 50.0, "gravities" => 9.5, "air_resistances" => 0.0) + Dict("launch_angles" => 45, "initial_velocities" => 50.0, "gravities" => 9.5, "air_resistances" => 0.0) + Dict("launch_angles" => 90, "initial_velocities" => 50.0, "gravities" => 9.5, "air_resistances" => 0.0) + Dict("launch_angles" => 0, "initial_velocities" => 40.0, "gravities" => 10.0, "air_resistances" => 0.0) + Dict("launch_angles" => 45, "initial_velocities" => 40.0, "gravities" => 10.0, "air_resistances" => 0.0) + Dict("launch_angles" => 90, "initial_velocities" => 40.0, "gravities" => 10.0, "air_resistances" => 0.0) + Dict("launch_angles" => 0, "initial_velocities" => 50.0, "gravities" => 10.0, "air_resistances" => 0.0) + I want the new dict to have as little entries as possible + +A: Looking at your data, I understand you want to find the minimum set of parameter combinations that still contains at least two distinct values for each parameter. Let me modify the previous function to help with this specific case. + This function will return the smallest possible set of dictionaries where: + + Each parameter (launch_angles, initial_velocities, etc.) has at least two different values represented across the set + The number of dictionaries is minimized + + For your specific data, it will create: + + One base dictionary with the first value for each parameter + One dictionary for each parameter that varies from the base dictionary + + This means you'll get at most n+1 dictionaries (where n is the number of parameters) instead of the original 54 dictionaries, while still maintaining the ability to study the effect of varying each parameter independently. + Would you like me to show an example of what the output looks like with your specific data, or would you like any modifications to the function? + function find_minimal_distinct_params(arr_of_dicts) + # Get all unique values for each parameter + params = keys(first(arr_of_dicts)) + param_values = Dict( + param => unique([d[param] for d in arr_of_dicts]) + for param in params + ) + + # For each parameter, we need only two different values + minimal_values = Dict( + param => param_values[param][1:min(2, length(values))] + for (param, values) in param_values + ) + + # Create the minimal set of dictionaries + result = Dict{String, Real}[] + + # First dictionary: use first value for each parameter + push!(result, Dict(param => values[1] for (param, values) in minimal_values)) + + # Additional dictionaries: change one parameter at a time to its second value + for param in params + if length(minimal_values[param]) > 1 + new_dict = copy(result[1]) + new_dict[param] = minimal_values[param][2] + push!(result, new_dict) + end + end + + return result + end + + # Test with your data + test_data = [ + Dict("launch_angles" => 0, "initial_velocities" => 40.0, "gravities" => 9.0, "air_resistances" => 0.0), + Dict("launch_angles" => 45, "initial_velocities" => 40.0, "gravities" => 9.0, "air_resistances" => 0.0), + # ... (rest of your data) + ] + + minimal_set = find_minimal_distinct_params(test_data) + diff --git a/chatgpt12.txt b/chatgpt12.txt new file mode 100644 index 0000000..7ade59e --- /dev/null +++ b/chatgpt12.txt @@ -0,0 +1,96 @@ +Q: I want to showcase a use case using a parallel plot. For that I need a simulation that takes in different parameters and calculates something. Then I want to display all results and their parameters in a parallelplot. I already have a package that creates a parallelplot based on a dataframe. Moreover, I want to use dr watson and julia. Please create fitting code and think of a good simulation that makes sense. The end dict should have the used parameters and the calculated values. +A: I'll help you create a simulation using Julia and Dr. Watson to generate data for a parallel plot. Let's design a simulation that explores the performance of different machine learning model hyperparameters on a dataset. This simulation: + + Uses DrWatson for parameter combinations + Simulates projectile motion + Calculates max height, total distance, and flight time + Varies initial velocity, launch angle, air resistance, and gravity + Provides a realistic physics-based calculation with multiple parameters + + Outputs include the parameters used and the calculated physical characteristics of the projectile's motion. + + using DrWatson + using DataFrames + using Distributions + + """ + Simulate projectile motion with varying parameters: + - Initial velocity + - Launch angle + - Air resistance coefficient + - Gravitational acceleration + """ + function projectile_simulation() + # Define parameter ranges + parameter_ranges = Dict( + :initial_velocity => 10.0:2.0:50.0, # m/s + :launch_angle => (0:10:90) * π/180, # radians + :air_resistance => 0.0:0.1:1.0, # drag coefficient + :gravity => 9.0:0.5:10.5 # m/s² + ) + + # Generate parameter combinations + parameter_combinations = collect(dict_list(parameter_ranges)) + + # Prepare results DataFrame + results = DataFrame( + initial_velocity = Float64[], + launch_angle = Float64[], + air_resistance = Float64[], + gravity = Float64[], + max_height = Float64[], + total_distance = Float64[], + time_of_flight = Float64[] + ) + + # Simulation of projectile motion with air resistance + for params in parameter_combinations + v0 = params[:initial_velocity] + θ = params[:launch_angle] + k = params[:air_resistance] + g = params[:gravity] + + # Calculate components + vx0 = v0 * cos(θ) + vy0 = v0 * sin(θ) + + # Analytical solution with air resistance + # Simplified model assuming linear air resistance + time_to_peak = vy0 / (g + k * vy0) + max_height = vy0 * time_to_peak - 0.5 * g * time_to_peak^2 + + # Total flight time (approximate) + total_time = 2 * time_to_peak + + # Horizontal distance (with air resistance approximation) + total_distance = vx0 * total_time * (1 - k * total_time) + + # Push results + push!(results, [ + v0, + θ * 180/π, # convert back to degrees for readability + k, + g, + max_height, + total_distance, + total_time + ]) + end + + return results + end + + # Main execution + function main() + results = projectile_simulation() + println("Total parameter combinations: ", nrow(results)) + println("\nSample results:") + display(first(results, 5)) + + # Optional statistical summary + println("\nStatistical Summary:") + display(describe(results)) + end + + # Run the simulation + main() \ No newline at end of file