Create a complex radar chart with different scales for each variable Source: https://towardsdatascience.com/how-to-create-and-visualize-complex-radar-charts-f7764d0f3652 Args: data (`List[dict]`): the results (list of metric + value pairs). E.g. data = [{"accuracy": 0.9,
(data, model_names, invert_range=[], config=None, fig=None)
| 136 | |
| 137 | |
| 138 | def radar_plot(data, model_names, invert_range=[], config=None, fig=None): |
| 139 | """Create a complex radar chart with different scales for each variable |
| 140 | Source: https://towardsdatascience.com/how-to-create-and-visualize-complex-radar-charts-f7764d0f3652 |
| 141 | |
| 142 | Args: |
| 143 | data (`List[dict]`): the results (list of metric + value pairs). |
| 144 | E.g. data = [{"accuracy": 0.9, "precision":0.8},{"accuracy": 0.7, "precision":0.6}] |
| 145 | names (`List[dict]`): model names. |
| 146 | E.g. names = ["model1", "model 2", ...] |
| 147 | invert_range (`List[dict]`, optional): the metrics to invert (in cases when smaller is better, e.g. speed) |
| 148 | E.g. invert_range=["latency_in_seconds"] |
| 149 | config (`dict`, optional) : a specification of the formatting configurations, namely: |
| 150 | |
| 151 | - rad_ln_args (`dict`, default `{"visible": True}`): The visibility of the radial (circle) lines. |
| 152 | |
| 153 | - outer_ring (`dict`, default `{"visible": True}`): The visibility of the outer ring. |
| 154 | |
| 155 | - angle_ln_args (`dict`, default `{"visible": True}`): The visibility of the angle lines. |
| 156 | |
| 157 | - rgrid_tick_lbls_args (`dict`, default `{"fontsize": 12}`): The font size of the tick labels on the scales. |
| 158 | |
| 159 | - theta_tick_lbls (`dict`, default `{"fontsize": 12}`): The font size of the variable labels on the plot. |
| 160 | |
| 161 | - theta_tick_lbls_pad (`int`, default `3`): The padding of the variable labels on the plot. |
| 162 | |
| 163 | - theta_tick_lbls_brk_lng_wrds (`bool`, default `True` ): Whether long words in the label are broken up or not. |
| 164 | |
| 165 | - theta_tick_lbls_txt_wrap (`int`, default `15`): Text wrap for tick labels |
| 166 | |
| 167 | - incl_endpoint (`bool`, default `False`): Include value endpoints on calse |
| 168 | |
| 169 | - marker (`str`, default `"o"`): the shape of the marker used in the radar plot. |
| 170 | |
| 171 | - markersize (`int`, default `3`): the shape of the marker used in the radar plot. |
| 172 | |
| 173 | - legend_loc (`str`, default `"upper right"`): the location of the legend in the radar plot. Must be one of: 'upper left', 'upper right', 'lower left', 'lower right'. |
| 174 | |
| 175 | - bbox_to_anchor (`tuple`, default `(2, 1)`: anchor for the legend. |
| 176 | fig (`matplotlib.figure.Figure`, optional): figure used to plot the radar plot. |
| 177 | |
| 178 | Returns: |
| 179 | `matplotlib.figure.Figure` |
| 180 | """ |
| 181 | data = pd.DataFrame(data) |
| 182 | data.index = model_names |
| 183 | variables = data.keys() |
| 184 | if all(x in variables for x in invert_range) is False: |
| 185 | raise ValueError("All of the metrics in `invert_range` should be in the data provided.") |
| 186 | min_max_per_variable = data.describe().T[["min", "max"]] |
| 187 | min_max_per_variable["min"] = min_max_per_variable["min"] - 0.1 * ( |
| 188 | min_max_per_variable["max"] - min_max_per_variable["min"] |
| 189 | ) |
| 190 | min_max_per_variable["max"] = min_max_per_variable["max"] + 0.1 * ( |
| 191 | min_max_per_variable["max"] - min_max_per_variable["min"] |
| 192 | ) |
| 193 | |
| 194 | ranges = list(min_max_per_variable.itertuples(index=False, name=None)) |
| 195 | ranges = [ |
searching dependent graphs…