Home > database >  How to boxplot multiple dictionaries on the same plot
How to boxplot multiple dictionaries on the same plot

Time:06-27

For a change point detection task, I am testing my own algorithm against a baseline, and I would like to plot the results from the two algorithms on the same boxplot.

My results (F Score values) are stored in a dictionary where the keys are two parameters a and b (both with 4 distinct values):

resultsOwnAlgorithm = {'a1, b1': [0.8, 0.7, 0.6, ...], 'a1, b2': [...], ..., 'a2, b1': [...], ...}
resultsBaseline = {'a1, b1': [0.7, 0.6, ...], 'a1, b2': [...], ..., 'a2, b1': [...], ...}

For now, I have a function to plot them individually. I create 4 subplots where a is set and b is changing, enter image description here

CodePudding user response:

  • The easiest solution is probably to combine all of the dictionaries into a single enter image description here

    DataFrame Views

    • dfs.head()
         a1, b1    a2, b2    a3, b3    a4, b4 Algorithm
    0  0.834463 -1.092923  4.875117 -4.946214  baseline
    1  1.338891  0.225008 -0.305499  0.570333  baseline
    2  0.261615  2.128844  2.194177  0.494803  baseline
    3  0.273740 -2.395624 -3.495572  0.006312  baseline
    4 -0.997368  0.984808 -3.956302  0.206667  baseline
    
    • dfm.head()
      Algorithm Parameters     Score
    0  baseline     a1, b1  0.834463
    1  baseline     a1, b1  1.338891
    2  baseline     a1, b1  0.261615
    3  baseline     a1, b1  0.273740
    4  baseline     a1, b1 -0.997368
    
  • Related