Hello,
assume the following minimal example
from pandas import DataFrame
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
samples = [100, 200]
epochs = [3, 4, 5]
kpi = ['ACC', 'PRC', 'REC', 'MM']
models = ['M0', 'M1', 'M2']
data = np.random.rand(12, 6)
df = pd.DataFrame(data)
df.columns = pd.MultiIndex.from_product([kpi, models], names=['kpi','models'])
df.index = pd.MultiIndex.from_product([samples, epochs], names=['samples', 'epochs'])
print(df)
which outputs the following dataframe with multiple indices both for the rows and for the columns
kpi ACC PRC REC MM
models M0 M1 M2 M0 M1 M2 M0 M1 M2 M0 M1 M2
samples epochs
100 3 0.906675 0.319360 0.675432 0.253069 0.584511 0.303165 0.248698 0.071041 0.454044 0.969305 0.922541 0.671037
4 0.142995 0.048634 0.315539 0.407142 0.345572 0.909697 0.757394 0.131977 0.595874 0.995964 0.516483 0.068203
5 0.905476 0.216253 0.252296 0.296729 0.128222 0.885560 0.891368 0.766562 0.086110 0.919574 0.543337 0.839931
200 3 0.776404 0.677118 0.190398 0.362749 0.740333 0.678845 0.761190 0.164483 0.369186 0.656634 0.481825 0.026312
4 0.395710 0.751088 0.016821 0.077905 0.916027 0.470270 0.349636 0.903484 0.851275 0.709731 0.004874 0.984908
5 0.564700 0.744458 0.011534 0.905957 0.135282 0.637977 0.633657 0.192773 0.175391 0.163563 0.679527 0.334195
I want to plot these results in the following configuration:
- One bar chart per each of the
kpi
index values([ACC, PRC, REC, MM])
- In each of these charts I will plot bars for each of the models
([M0, M1, M2])
- I want to be able to select which values will be selected based on the
samples
or theepochs
or for all of their combinations. For example, I might want to compare the models forepochs=3
and for all values ofsamples
, or forsamples=100
and for all values ofepochs
and somehow show this configuration on the plot (as a title maybe)?
- In each of these charts I will plot bars for each of the models
Any ideas?