InteractivePlots
- class fedartml.InteractivePlots(labels, random_state=None, colors=None, distance='jensen-shannon', **plot_kwargs)[source]
Generate simulated interactive plots (with sliders) from the labels provided in a federated learning paradigm to exemplify identically and non-identically distributed labels across the local nodes (clients).
Parameters
- labelsarray-like
The target values (class labels in classification).
- random_stateint
Controls the shuffling applied to the generation of pseudorandom numbers. Pass an int for reproducible output across multiple function calls.
- colorslist
Colors list used to plot. Must have a length of 7 positions.
- distancestr
Distance to use for measuring heterogeneity (non-IID-ness) of the label’s distribution among clients. Possible choices: “jensen-shannon”, “hellinger”, “earth_movers”.
- **plot_kwargsdict
Keyword arguments used for customizing plots (inherited from matplotlib.pyplot).
- bar_divided_distr_dirichlet(Alpha, Local_Nodes)[source]
Create an interactive bar plot (with sliders) divided per each local node (client).
Parameters
- Alphaslider
Concentration parameter of the Dirichlet distribution.
- Local_Nodesslider
Number of local nodes (clients) used in the federated learning paradigm.
Returns
The return keyword is empty. The function shows the plot as output.
- bar_divided_distr_percent_noniid(Pctg_NonIID, Local_Nodes)[source]
Create an interactive bar plot (with sliders) divided per each local node (client).
Parameters
- Pctg_NonIIDslider
Percentage (between o and 100) desired of non-IID-ness for the federated data.
- Local_Nodesslider
Number of local nodes (clients) used in the federated learning paradigm.
Returns
The return keyword is empty. The function shows the plot as output.
- scatter_distr_dirichlet(Alpha, Local_Nodes)[source]
Create an interactive scatter plot (with sliders) per each local node (client) and label’s classes.
Parameters
- Alphaslider
Concentration parameter of the Dirichlet distribution.
- Local_Nodesslider
Number of local nodes (clients) used in the federated learning paradigm.
Returns
The return keyword is empty. The function shows the plot as output.
- scatter_distr_percent_noniid(Pctg_NonIID, Local_Nodes)[source]
Create an interactive scatter plot (with sliders) per each local node (client) and label’s classes.
Parameters
- Pctg_NonIIDslider
Percentage (between o and 100) desired of non-IID-ness for the federated data.
- Local_Nodesslider
Number of local nodes (clients) used in the federated learning paradigm.
Returns
The return keyword is empty. The function shows the plot as output.
- show_bar_divided_distr_dirichlet(**slider_kwargs)[source]
Show an interactive bar plot (with sliders) divided per each local node (client).
Parameters
- **slider_kwargs: dict
Keyword arguments used for customizing sliders (inherited from ipywidgets.interact).
Returns
The return keyword is empty. The function shows the sliders for Alpha and number of local nodes (clients).
References
Examples
>>> from fedartml import InteractivePlots >>> from keras.datasets import mnist >>> (train_X, train_y), (test_X, test_y) = mnist.load_data() >>> my_plot = InteractivePlots(labels = train_y) >>> my_plot.show_bar_divided_distr_dirichlet()
- show_bar_divided_distr_percent_noniid(**slider_kwargs)[source]
Show an interactive bar plot (with sliders) divided per each local node (client).
Parameters
- **slider_kwargs: dict
Keyword arguments used for customizing sliders (inherited from ipywidgets.interact).
Returns
The return keyword is empty. The function shows the sliders for Pctg_NonIID and number of local nodes (clients).
References
[1] Hsieh, K., Phanishayee, A., Mutlu, O., & Gibbons, P. (2020, November). The non-iid data quagmire of decentralized machine learning. In International Conference on Machine Learning (pp. 4387-4398). PMLR. https://proceedings.mlr.press/v119/hsieh20a/hsieh20a.pdf
Examples
>>> from fedartml import InteractivePlots >>> from keras.datasets import mnist >>> (train_X, train_y), (test_X, test_y) = mnist.load_data() >>> my_plot = InteractivePlots(labels = train_y) >>> my_plot.show_bar_divided_distr_percent_noniid()
- show_scatter_distr_dirichlet(**slider_kwargs)[source]
Show an interactive scatter plot (with sliders) per each local node (client) and label’s classes.
Parameters
- **slider_kwargs: dict
Keyword arguments used for customizing sliders (inherited from ipywidgets.interact).
Returns
The return keyword is empty. The function shows the sliders for Alpha and number of local nodes (clients).
References
[1] Tao Lin∗, Lingjing Kong∗, Sebastian U. Stich, Martin Jaggi. (2020). Ensemble Distillation for Robust Model Fusion in Federated Learning https://proceedings.neurips.cc/paper/2020/file/18df51b97ccd68128e994804f3eccc87-Supplemental.pdf
Examples
>>> from fedartml import InteractivePlots >>> from keras.datasets import mnist >>> (train_X, train_y), (test_X, test_y) = mnist.load_data() >>> my_plot = InteractivePlots(labels = train_y) >>> my_plot.show_scatter_distr_dirichlet()
- show_scatter_distr_percent_noniid(**slider_kwargs)[source]
Show an interactive scatter plot (with sliders) per each local node (client) and label’s classes.
Parameters
- **slider_kwargs: dict
Keyword arguments used for customizing sliders (inherited from ipywidgets.interact).
Returns
The return keyword is empty. The function shows the sliders for Pctg_NonIID and number of local nodes (clients).
References
[1] Hsieh, K., Phanishayee, A., Mutlu, O., & Gibbons, P. (2020, November). The non-iid data quagmire of decentralized machine learning. In International Conference on Machine Learning (pp. 4387-4398). PMLR. https://proceedings.mlr.press/v119/hsieh20a/hsieh20a.pdf
Examples
>>> from fedartml import InteractivePlots >>> from keras.datasets import mnist >>> (train_X, train_y), (test_X, test_y) = mnist.load_data() >>> my_plot = InteractivePlots(labels = train_y) >>> my_plot.show_scatter_distr_percent_noniid()
- show_stacked_distr_dirichlet(**slider_kwargs)[source]
Show an interactive stacked bar plot (with sliders) per each local node (client) and label’s classes.
Parameters
- **slider_kwargs: dict
Keyword arguments used for customizing sliders (inherited from ipywidgets.interact).
Returns
The return keyword is empty. The function shows the sliders for Alpha and number of local nodes (clients).
References
[1] Tao Lin∗, Lingjing Kong∗, Sebastian U. Stich, Martin Jaggi. (2020). Ensemble Distillation for Robust Model Fusion in Federated Learning https://proceedings.neurips.cc/paper/2020/file/18df51b97ccd68128e994804f3eccc87-Supplemental.pdf
Examples
>>> from fedartml import InteractivePlots >>> from keras.datasets import mnist >>> (train_X, train_y), (test_X, test_y) = mnist.load_data() >>> my_plot = InteractivePlots(labels = train_y) >>> my_plot.show_stacked_distr_dirichlet()
- show_stacked_distr_percent_noniid(**slider_kwargs)[source]
Show an interactive stacked bar plot (with sliders) per each local node (client) and label’s classes.
Parameters
- **slider_kwargs: dict
Keyword arguments used for customizing sliders (inherited from ipywidgets.interact).
Returns
The return keyword is empty. The function shows the sliders for Pctg_noniid and number of local nodes (clients).
References
[1] Hsieh, K., Phanishayee, A., Mutlu, O., & Gibbons, P. (2020, November). The non-iid data quagmire of decentralized machine learning. In International Conference on Machine Learning (pp. 4387-4398). PMLR. https://proceedings.mlr.press/v119/hsieh20a/hsieh20a.pdf
Examples
>>> from fedartml import InteractivePlots >>> from keras.datasets import mnist >>> (train_X, train_y), (test_X, test_y) = mnist.load_data() >>> my_plot = InteractivePlots(labels = train_y) >>> my_plot.show_stacked_distr_percent_noniid()
- stacked_distr_dirichlet(Alpha, Local_Nodes)[source]
Create an interactive stacked bar plot (with sliders) per each local node (client) and label’s classes.
Parameters
- Alphaslider
Concentration parameter of the Dirichlet distribution.
- Local_Nodesslider
Number of local nodes (clients) used in the federated learning paradigm.
Returns
The return keyword is empty. The function shows the plot as output.
- stacked_distr_percent_noniid(Pctg_NonIID, Local_Nodes)[source]
Create an interactive stacked bar plot (with sliders) per each local node (client) and label’s classes.
Parameters
- Pctg_NonIIDslider
Percentage (between o and 100) desired of non-IID-ness for the federated data.
- Local_Nodesslider
Number of local nodes (clients) used in the federated learning paradigm.
Returns
The return keyword is empty. The function shows the plot as output.