0
$\begingroup$

I've been working with a set of few neural networks, and building bigger models by selecting a subset and combining them. I haven't been able to find a proper way to visualize the quality(value of objective function) of all the bigger models in a brief, sufficient and readable manner. I have tried bar-plots with a legend, parallel-coordinates-plots and parallel-categories-plots but none of them are quite readable. What other options are there?

TLDR; Given a set e.g. {A, B, C, ...} and a map from all possible subsets to real values e.g. {{} -> 0, {A} -> 0.5, {B} -> 1, {A, B} -> 1.5, ...} what good options are there to visualize the values of the map in a way that contains all the information and is readable?

Edit: I have added a sample of the code and visualization I have already tried.

import matplotlib.pyplot as plt
import numpy as np; np.random.seed(123123)
import pandas as pd
import plotly.express as px

def powerset(s: list) -> list:
    l = len(s)
    result = [
        tuple([s[i] for i in range(l) if 2**i & j])
        for j in range(2**l)
    ]
    return result

eg_set = ['A', 'B', 'C', 'D']
eg_powerset = powerset(eg_set)
eg_map = {x: y for x, y in zip(eg_powerset, np.round(np.random.uniform(0, 100, len(eg_powerset)), 2))}

for x in eg_map:
    print(x, ': ', eg_map[x])

() : 30.02
('A',) : 99.46
('B',) : 29.01
('A', 'B') : 83.02
('C',) : 72.14
('A', 'C') : 46.27
('B', 'C') : 17.68
('A', 'B', 'C') : 6.78
('D',) : 52.01
('A', 'D') : 23.23
('B', 'D') : 32.51
('A', 'B', 'D') : 72.2
('C', 'D') : 85.16
('A', 'C', 'D') : 53.26
('B', 'C', 'D') : 47.35
('A', 'B', 'C', 'D') : 78.38

# barplot
df = pd.DataFrame(eg_map.items(), columns=['subset', 'value'])
_, ax = plt.subplots(nrows=1, ncols=1, figsize=(5, 5))
df.plot.barh(x='subset', ax=ax)

Bar plot

# parallel coordinates
for x in eg_set:
    df[x] = df.subset.apply(lambda y: int(x in y))

dimensions = eg_set + ['value']
labels = {x: 'Contains \'{}\''.format(x) for x in eg_set}
labels['value'] = 'value'

fig = px.parallel_coordinates(df, dimensions=dimensions, labels=labels, color='value')
fig.show()

Parallel coordinates plot

# parallel categories
for x in eg_set:
    df[x] = df.subset.apply(lambda y: x in y)

fig = px.parallel_categories(df, dimensions=dimensions, labels=labels, color='value')
fig.update_traces(dimensions=[{"categoryorder": "category descending"} for _ in dimensions])
fig.show()

Parallel categories plot

$\endgroup$
2
  • 1
    $\begingroup$ Could you post examples of the visualizations you have already tried? $\endgroup$
    – liakoyras
    Commented Jul 20, 2023 at 8:47
  • $\begingroup$ @liakoyras sure thing! $\endgroup$
    – Mahdi
    Commented Jul 20, 2023 at 14:56

1 Answer 1

1
$\begingroup$

Out of the visualizations that you tried so far, while the bar chart looks the ugliest, with better sorting it could be the most readable. I suggest Gray code. Then, it would be quicker to understand how addition/subtraction/substitution of one element of the subset affects the total value. Otherwise it is just a dump of meaningless information (much more so to someone that is not intimately familiar with the topic).

And if you color code the values too, it would look a bit prettier and be even quicker to understand too (if you wanted to see if there is a pattern that leads to high numbers, you could just look at the warmer colors etc).

The other visualizations are too dependent on color (it's not just to help, it is actually impossible to read the charts in black and white) and the overlaps (especially in the coordinates plot) make them extremely hard to read.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.