Skip to content

Commit 114cfac

Browse files
caglayantunaCaglayan TunaNicolasGensollen
authored
Improve PDF file created by FOM (#327)
* improve pdf file improve doc and function improve FOM improve fom with tests add local and sourwise option * update according to review * update * update * add helper functions with docs * Apply suggestions from code review Co-authored-by: Gensollen <[email protected]> * improve readability --------- Co-authored-by: Caglayan Tuna <[email protected]> Co-authored-by: Gensollen <[email protected]>
1 parent 6f8c15b commit 114cfac

File tree

4 files changed

+383
-40
lines changed

4 files changed

+383
-40
lines changed

src/leaspy/algo/settings.py

+17
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class OutputsSettings:
4242
Flag to plot convergence data every N iterations
4343
If None, no plots will be saved.
4444
Note that you can not plot convergence data without saving data (and not more frequently than these saves!)
45+
* plot_sourcewise : bool
46+
Flag to plot source based multidimensional parameters such as mixing_matrix for each source.
47+
Otherwise they will be plotted according to the other dimension such as feature.
48+
Default=False
4549
* overwrite_logs_folder : bool
4650
Flag to remove all previous logs if existing (default False)
4751
@@ -61,6 +65,7 @@ def __init__(self, settings):
6165
self.print_periodicity = None
6266
self.plot_periodicity = None
6367
self.save_periodicity = 50
68+
self.plot_sourcewise = False
6469
self.nb_of_patients_to_plot = 5
6570

6671
self.root_path = None
@@ -71,6 +76,8 @@ def __init__(self, settings):
7176
self._set_print_periodicity(settings)
7277
self._set_save_periodicity(settings)
7378
self._set_plot_periodicity(settings)
79+
self._set_nb_of_patients_to_plot(settings)
80+
self._set_plot_sourcewise(settings)
7481

7582
# only create folders if the user want to save data or plots and provided a valid path!
7683
self._create_root_folder(settings)
@@ -97,6 +104,12 @@ def _set_param_as_int_or_ignore(self, settings: dict, param: str):
97104
# Update the attribute of self in-place
98105
setattr(self, param, val)
99106

107+
def _set_plot_sourcewise(self, settings: dict):
108+
setattr(self, "plot_sourcewise", settings["plot_sourcewise"])
109+
110+
def _set_nb_of_patients_to_plot(self, settings: dict):
111+
self._set_param_as_int_or_ignore(settings, "nb_of_patients_to_plot")
112+
100113
def _set_print_periodicity(self, settings: dict):
101114
self._set_param_as_int_or_ignore(settings, "print_periodicity")
102115

@@ -516,6 +529,8 @@ def set_logs(self, path: Optional[Union[str, Path]] = None, **kwargs):
516529
Note that:
517530
* it should be a multiple of save_periodicity
518531
* setting a too low value (frequent) we seriously slow down you fit
532+
* plot_sourcewise : bool, optional, default False
533+
Set this to True to plot the source-based parameters sourcewise.
519534
* overwrite_logs_folder: bool, optional, default False
520535
Set it to ``True`` to overwrite the content of the folder in ``path``.
521536
* nb_of_patients_to_plot: int, optional default 5
@@ -538,6 +553,7 @@ def set_logs(self, path: Optional[Union[str, Path]] = None, **kwargs):
538553
"print_periodicity": None,
539554
"save_periodicity": 10,
540555
"plot_periodicity": 50,
556+
"plot_sourcewise": False,
541557
"overwrite_logs_folder": False,
542558
"nb_of_patients_to_plot": 5,
543559
}
@@ -548,6 +564,7 @@ def set_logs(self, path: Optional[Union[str, Path]] = None, **kwargs):
548564
"plot_periodicity",
549565
"save_periodicity",
550566
"nb_of_patients_to_plot",
567+
"plot_sourcewise",
551568
):
552569
if v is not None and not isinstance(v, int):
553570
raise LeaspyAlgoInputError(

0 commit comments

Comments
 (0)