Results Processing
Dependencies
Mix.install([
{:exla, "~> 0.1.0-dev", github: "elixir-nx/nx", sparse: "exla", override: true},
{:nx, "~> 0.1.0-dev", github: "elixir-nx/nx", sparse: "nx", override: true},
{:scholar, "~> 0.1.0", github: "elixir-nx/scholar", branch: "main"},
{:explorer, "~> 0.1.0-dev", github: "elixir-nx/explorer", branch: "main"},
{:vega_lite, "~> 0.1.3"},
{:kino, "~> 0.5.2"}
])
alias Explorer.DataFrame
alias Explorer.Series
alias VegaLite, as: Vl
Feed Forward Neural Network
losses_df =
"FFNN.losses.csv"
|> DataFrame.read_csv!()
|> DataFrame.mutate(
epoch: &Series.add(&1["epoch"], 1),
attempt: &Series.add(&1["attempt"], 1)
)
Vl.new(width: 800, height: 600)
|> Vl.data_from_series(DataFrame.to_map(losses_df))
|> Vl.mark(:line)
|> Vl.encode_field(:x, "epoch", type: :ordinal, title: "Epoch")
|> Vl.encode_field(:y, "loss", type: :quantitative, title: "Loss")
|> Vl.encode_field(:color, "attempt", type: :nominal, title: "Attempt")
results_df =
"FFNN.results.csv"
|> DataFrame.read_csv!()
|> DataFrame.mutate(attempt: &Series.add(&1["attempt"], 1))
make_colors = fn serie ->
results_df
|> Access.get(serie)
|> Series.to_list()
|> Enum.map(fn _ -> serie end)
|> Series.from_list()
end
attempt = Series.concat(results_df["attempt"], results_df["attempt"])
metrics = results_df["accuracy"]
colors = make_colors.("accuracy")
metrics = Series.concat(metrics, results_df["precision"])
colors = Series.concat(colors, make_colors.("precision"))
results_df = DataFrame.from_columns(attempt: attempt, color: colors, metric: metrics)
Vl.new(width: 800, height: 600)
|> Vl.data_from_series(DataFrame.to_map(results_df))
|> Vl.mark(:bar)
|> Vl.encode_field(:x, "attempt", type: :ordinal, title: "Attempt")
|> Vl.encode_field(:y, "metric", type: :quantitative, title: "Value")
|> Vl.encode_field(:color, "color", type: :nominal, title: "Metric")
|> Vl.encode_field(:x_offset, "color", type: :nominal, title: "Metric")
Auto Encoder
losses_df =
"AE.losses.csv"
|> DataFrame.read_csv!()
|> DataFrame.mutate(
epoch: &Series.add(&1["epoch"], 1),
attempt: &Series.add(&1["attempt"], 1)
)
Vl.new(width: 800, height: 600)
|> Vl.mark(:line)
|> Vl.data_from_series(DataFrame.to_map(losses_df))
|> Vl.encode_field(:x, "epoch", type: :ordinal, title: "Epoch")
|> Vl.encode_field(:y, "loss", type: :quantitative, title: "Loss")
|> Vl.encode_field(:color, "attempt", type: :nominal, title: "Attempt")
Vl.new(width: 800, height: 600)
|> Vl.mark(:line)
|> Vl.data_from_series(DataFrame.to_map(losses_df))
|> Vl.encode_field(:x, "epoch", type: :ordinal, title: "Epoch")
|> Vl.encode_field(:y, "mae", type: :quantitative, title: "Mean Absolute Error")
|> Vl.encode_field(:color, "attempt", type: :nominal, title: "Attempt")
results_df =
"AE.results.csv"
|> DataFrame.read_csv!()
|> DataFrame.mutate(attempt: &Series.add(&1["attempt"], 1))
Vl.new(width: 800, height: 600)
|> Vl.mark(:bar)
|> Vl.data_from_series(DataFrame.to_map(results_df))
|> Vl.encode_field(:x, "threshold", type: :ordinal, title: "Threshold")
|> Vl.encode_field(:color, "attempt", type: :nominal, title: "Attempt")
|> Vl.encode_field(:y, "fp", type: :quantitative, title: "False Positives")
|> Vl.encode_field(:x_offset, "attempt", type: :nominal, title: "Attempt")
Vl.new(width: 800, height: 600)
|> Vl.mark(:bar)
|> Vl.data_from_series(DataFrame.to_map(results_df))
|> Vl.encode_field(:x, "threshold", type: :ordinal, title: "Threshold")
|> Vl.encode_field(:color, "attempt", type: :nominal, title: "Attempt")
|> Vl.encode_field(:y, "tp", type: :quantitative, title: "True Positives")
|> Vl.encode_field(:x_offset, "attempt", type: :nominal, title: "Attempt")
GAN
losses_df =
"GAN.losses.csv"
|> DataFrame.read_csv!()
|> DataFrame.mutate(
epoch: &Series.add(&1["epoch"], 1),
attempt: &Series.add(&1["attempt"], 1)
)
Vl.new(width: 800, height: 600)
|> Vl.mark(:line)
|> Vl.data_from_series(DataFrame.to_map(losses_df))
|> Vl.encode_field(:x, "epoch", type: :ordinal, title: "Epoch")
|> Vl.encode_field(:y, "g_loss", type: :quantitative, title: "Generator Loss")
|> Vl.encode_field(:color, "attempt", type: :nominal, title: "Attempt")
Vl.new(width: 800, height: 600)
|> Vl.mark(:line)
|> Vl.data_from_series(DataFrame.to_map(losses_df))
|> Vl.encode_field(:x, "epoch", type: :ordinal, title: "Epoch")
|> Vl.encode_field(:y, "d_loss", type: :quantitative, title: "Discriminator Loss")
|> Vl.encode_field(:color, "attempt", type: :nominal, title: "Attempt")
mean_losses_df =
losses_df
|> DataFrame.group_by(["epoch"])
|> DataFrame.summarise(d_loss: [:mean], g_loss: [:mean])
make_colors = fn serie ->
mean_losses_df
|> Access.get(serie)
|> Series.to_list()
|> Enum.map(fn _ -> serie end)
|> Series.from_list()
end
epoch = Series.concat(mean_losses_df["epoch"], mean_losses_df["epoch"])
color = make_colors.("g_loss_mean")
metric = mean_losses_df["g_loss_mean"]
color = Series.concat(color, make_colors.("d_loss_mean"))
metric = Series.concat(metric, mean_losses_df["d_loss_mean"])
mean_losses_df = DataFrame.from_columns(epoch: epoch, color: color, metric: metric)
Vl.new(width: 800, height: 600)
|> Vl.data_from_series(DataFrame.to_map(mean_losses_df))
|> Vl.mark(:line)
|> Vl.encode_field(:x, "epoch", type: :nominal, title: "Epoch")
|> Vl.encode_field(:y, "metric", type: :quantitative, title: "Metric")
|> Vl.encode_field(:color, "color", type: :nominal, title: "Metric")
results_df =
"GAN.results.csv"
|> DataFrame.read_csv!()
|> DataFrame.mutate(attempt: &Series.add(&1["attempt"], 1))
make_colors = fn serie ->
results_df
|> Access.get(serie)
|> Series.to_list()
|> Enum.map(fn _ -> serie end)
|> Series.from_list()
end
attempt = Series.concat(results_df["attempt"], results_df["attempt"])
metrics = results_df["accuracy"]
colors = make_colors.("accuracy")
metrics = Series.concat(metrics, results_df["precision"])
colors = Series.concat(colors, make_colors.("precision"))
results_df = DataFrame.from_columns(attempt: attempt, color: colors, metric: metrics)
Vl.new(width: 800, height: 600)
|> Vl.data_from_series(DataFrame.to_map(results_df))
|> Vl.mark(:bar)
|> Vl.encode_field(:x, "attempt", type: :ordinal, title: "Attempt")
|> Vl.encode_field(:y, "metric", type: :quantitative, title: "Value")
|> Vl.encode_field(:color, "color", type: :nominal, title: "Metric")
|> Vl.encode_field(:x_offset, "color", type: :nominal, title: "Metric")
sssasdsdadisplayddssddsddsdsad