Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
This Project is for the TU-Berlin Course "Julia Programming for Machine Learning"<br>
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)<br>
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)<br>.
<img src="test/projectile_simulation.png" width="500" />

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
Expand All @@ -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
Expand Down
98 changes: 98 additions & 0 deletions chatgpt1.txt
Original file line number Diff line number Diff line change
@@ -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)

96 changes: 96 additions & 0 deletions chatgpt12.txt
Original file line number Diff line number Diff line change
@@ -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()
19 changes: 9 additions & 10 deletions docs/src/getting_started.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Getting Started

## Install Dependencies & Use ParallelPlots
Expand All @@ -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
```
Expand Down
8 changes: 5 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"<br>
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)<br>.
<img src="test/projectile_simulation.png" width="500" />

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.
Loading