DEMO:

obj: Mini demo to inspect a studies with multiple parameters...


In [11]:
# coding: utf-8
import pickle
from pprint import pformat
import numpy as np

np.set_printoptions(precision=4)
np.set_printoptions(edgeitems=1)

Load the report


In [12]:
with open("report.pkl", 'r') as pfile:
    report = pickle.load(pfile)

Inspect the report on all the floatting parameters


In [13]:
print("Unconstraint")
print("-" * 10)

print(" - total of {0} studies".format(len(report.recons_im)))
print(" - fixed parameters are : {0}".format(report.fixed_params))
print(" - floatting parameters are : {0}".format(report.floatting_params))
for param in report.floatting_params:
    print("   -- '{0}' takes values {1}".format(param,
                                                report.get_list_params(param)))

for metric in report.metrics_funcs:
    print(" - best score for {0} is {1}"
          "obtained with parameters #{2}".format(metric.func_name,
                                                 report.best_score(metric),
                                                 report.best_index(metric)))
    print(" - {0}".format(pformat(report.best_params(metric))))


Unconstraint
----------
 - total of 40 studies
 - fixed parameters are : ['gradient_kwargs', 'verbose', 'report', 'max_nb_of_iter', 'data', 'gradient_cls']
 - floatting parameters are : ['mu', 'linear_cls', 'linear_kwargs']
   -- 'mu' takes values [5e-07, 1e-06, 2e-06, 3e-06, 5e-06]
   -- 'linear_cls' takes values [<class 'pisap.numerics.linears.MallatWaveletTransform7_9Filters'>, <class 'pisap.numerics.linears.MeyerWaveletsCompactInFourierSpace'>]
   -- 'linear_kwargs' takes values [{'maxscale': 3}, {'maxscale': 4}, {'maxscale': 5}, {'maxscale': 6}]
 - best score for compute_ssim is 0.845118440137obtained with parameters #38
 - {'data': array([[ 373.8576  +0.j    , ..., -281.6154 -31.545j ],
       ..., 
       [-217.8377-187.4362j, ...,  143.9425+174.6482j]]),
 'gradient_cls': <class 'pisap.numerics.gradient.Grad2DAnalyse'>,
 'gradient_kwargs': {'ft_cls': <pisap.numerics.fourier.FFT object at 0x7f71a1b88e90>},
 'linear_cls': <class 'pisap.numerics.linears.MeyerWaveletsCompactInFourierSpace'>,
 'linear_kwargs': {'maxscale': 5},
 'max_nb_of_iter': 25,
 'mu': 5e-06,
 'report': False,
 'verbose': 0}
 - best score for compute_snr is 3.79423700418obtained with parameters #36
 - {'data': array([[ 373.8576  +0.j    , ..., -281.6154 -31.545j ],
       ..., 
       [-217.8377-187.4362j, ...,  143.9425+174.6482j]]),
 'gradient_cls': <class 'pisap.numerics.gradient.Grad2DAnalyse'>,
 'gradient_kwargs': {'ft_cls': <pisap.numerics.fourier.FFT object at 0x7f71a1b88e90>},
 'linear_cls': <class 'pisap.numerics.linears.MeyerWaveletsCompactInFourierSpace'>,
 'linear_kwargs': {'maxscale': 3},
 'max_nb_of_iter': 25,
 'mu': 5e-06,
 'report': False,
 'verbose': 0}
 - best score for compute_psnr is -20.3633761018obtained with parameters #36
 - {'data': array([[ 373.8576  +0.j    , ..., -281.6154 -31.545j ],
       ..., 
       [-217.8377-187.4362j, ...,  143.9425+174.6482j]]),
 'gradient_cls': <class 'pisap.numerics.gradient.Grad2DAnalyse'>,
 'gradient_kwargs': {'ft_cls': <pisap.numerics.fourier.FFT object at 0x7f71a1b88e90>},
 'linear_cls': <class 'pisap.numerics.linears.MeyerWaveletsCompactInFourierSpace'>,
 'linear_kwargs': {'maxscale': 3},
 'max_nb_of_iter': 25,
 'mu': 5e-06,
 'report': False,
 'verbose': 0}
 - best score for compute_nrmse is 1.04951613061obtained with parameters #36
 - {'data': array([[ 373.8576  +0.j    , ..., -281.6154 -31.545j ],
       ..., 
       [-217.8377-187.4362j, ...,  143.9425+174.6482j]]),
 'gradient_cls': <class 'pisap.numerics.gradient.Grad2DAnalyse'>,
 'gradient_kwargs': {'ft_cls': <pisap.numerics.fourier.FFT object at 0x7f71a1b88e90>},
 'linear_cls': <class 'pisap.numerics.linears.MeyerWaveletsCompactInFourierSpace'>,
 'linear_kwargs': {'maxscale': 3},
 'max_nb_of_iter': 25,
 'mu': 5e-06,
 'report': False,
 'verbose': 0}

Inspect the report on a subset of the floatting parameters


In [14]:
print("Constraint #1")
print("-" * 10)

print("Now we fix those floatting parameters:")
key_fixed = report.floatting_params[:-1]
values_fixed = [[report.get_list_params(param)[0]]
                                     for param in report.floatting_params[:-1]]
filter_ = dict(zip(key_fixed, values_fixed))
print("  -- {0}".format(filter_))
print("The remaning floatting parameters is:")
key_floatting = report.floatting_params[-1]
values_floatting = report.get_list_params(report.floatting_params[-1])
print("  -- {0}".format({key_floatting:values_floatting}))

for metric in report.metrics_funcs:
    print(" - best score for "
          "{0} is {1} obtained with:".format(metric.func_name,
                                             report.best_score(metric, filter_)))
    print(" - {0}".format(pformat(report.best_params(metric, filter_))))


Constraint #1
----------
Now we fix those floatting parameters:
  -- {'mu': [5e-07], 'linear_cls': [<class 'pisap.numerics.linears.MallatWaveletTransform7_9Filters'>]}
The remaning floatting parameters is:
  -- {'linear_kwargs': [{'maxscale': 3}, {'maxscale': 4}, {'maxscale': 5}, {'maxscale': 6}]}
 - best score for compute_ssim is 0.843020282712 obtained with:
 - {'data': array([[ 373.8576  +0.j    , ..., -281.6154 -31.545j ],
       ..., 
       [-217.8377-187.4362j, ...,  143.9425+174.6482j]]),
 'gradient_cls': <class 'pisap.numerics.gradient.Grad2DAnalyse'>,
 'gradient_kwargs': {'ft_cls': <pisap.numerics.fourier.FFT object at 0x7f71a1b88e90>},
 'linear_cls': <class 'pisap.numerics.linears.MallatWaveletTransform7_9Filters'>,
 'linear_kwargs': {'maxscale': 6},
 'max_nb_of_iter': 25,
 'mu': 5e-07,
 'report': False,
 'verbose': 0}
 - best score for compute_snr is 3.76868549896 obtained with:
 - {'data': array([[ 373.8576  +0.j    , ..., -281.6154 -31.545j ],
       ..., 
       [-217.8377-187.4362j, ...,  143.9425+174.6482j]]),
 'gradient_cls': <class 'pisap.numerics.gradient.Grad2DAnalyse'>,
 'gradient_kwargs': {'ft_cls': <pisap.numerics.fourier.FFT object at 0x7f71a1b88e90>},
 'linear_cls': <class 'pisap.numerics.linears.MallatWaveletTransform7_9Filters'>,
 'linear_kwargs': {'maxscale': 3},
 'max_nb_of_iter': 25,
 'mu': 5e-07,
 'report': False,
 'verbose': 0}
 - best score for compute_psnr is -20.4469303115 obtained with:
 - {'data': array([[ 373.8576  +0.j    , ..., -281.6154 -31.545j ],
       ..., 
       [-217.8377-187.4362j, ...,  143.9425+174.6482j]]),
 'gradient_cls': <class 'pisap.numerics.gradient.Grad2DAnalyse'>,
 'gradient_kwargs': {'ft_cls': <pisap.numerics.fourier.FFT object at 0x7f71a1b88e90>},
 'linear_cls': <class 'pisap.numerics.linears.MallatWaveletTransform7_9Filters'>,
 'linear_kwargs': {'maxscale': 3},
 'max_nb_of_iter': 25,
 'mu': 5e-07,
 'report': False,
 'verbose': 0}
 - best score for compute_nrmse is 1.05966070139 obtained with:
 - {'data': array([[ 373.8576  +0.j    , ..., -281.6154 -31.545j ],
       ..., 
       [-217.8377-187.4362j, ...,  143.9425+174.6482j]]),
 'gradient_cls': <class 'pisap.numerics.gradient.Grad2DAnalyse'>,
 'gradient_kwargs': {'ft_cls': <pisap.numerics.fourier.FFT object at 0x7f71a1b88e90>},
 'linear_cls': <class 'pisap.numerics.linears.MallatWaveletTransform7_9Filters'>,
 'linear_kwargs': {'maxscale': 3},
 'max_nb_of_iter': 25,
 'mu': 5e-07,
 'report': False,
 'verbose': 0}

Inspect the report on a n other subset of floatting parameters


In [15]:
print("Constraint #2")
print("-" * 10)

print("Now we fix those floatting parameters:")
key_fixed = report.floatting_params[1:]
values_fixed = [[report.get_list_params(param)[0]]
                                      for param in report.floatting_params[1:]]
filter_ = dict(zip(key_fixed, values_fixed))
print("  -- {0}".format(filter_))
print("The remaning floatting parameters is:")
key_floatting = report.floatting_params[0]
values_floatting = report.get_list_params(report.floatting_params[0])
print("  -- {0}".format({key_floatting:values_floatting}))

for metric in report.metrics_funcs:
    print(" - best score for "
          "{0} is {1} obtained with:".format(metric.func_name,
                                             report.best_score(metric, filter_)))
    print(" - {0}".format(pformat(report.best_params(metric, filter_))))


Constraint #2
----------
Now we fix those floatting parameters:
  -- {'linear_cls': [<class 'pisap.numerics.linears.MallatWaveletTransform7_9Filters'>], 'linear_kwargs': [{'maxscale': 3}]}
The remaning floatting parameters is:
  -- {'mu': [5e-07, 1e-06, 2e-06, 3e-06, 5e-06]}
 - best score for compute_ssim is 0.844769160888 obtained with:
 - {'data': array([[ 373.8576  +0.j    , ..., -281.6154 -31.545j ],
       ..., 
       [-217.8377-187.4362j, ...,  143.9425+174.6482j]]),
 'gradient_cls': <class 'pisap.numerics.gradient.Grad2DAnalyse'>,
 'gradient_kwargs': {'ft_cls': <pisap.numerics.fourier.FFT object at 0x7f71a1b88e90>},
 'linear_cls': <class 'pisap.numerics.linears.MeyerWaveletsCompactInFourierSpace'>,
 'linear_kwargs': {'maxscale': 3},
 'max_nb_of_iter': 25,
 'mu': 5e-07,
 'report': False,
 'verbose': 0}
 - best score for compute_snr is 3.79159565917 obtained with:
 - {'data': array([[ 373.8576  +0.j    , ..., -281.6154 -31.545j ],
       ..., 
       [-217.8377-187.4362j, ...,  143.9425+174.6482j]]),
 'gradient_cls': <class 'pisap.numerics.gradient.Grad2DAnalyse'>,
 'gradient_kwargs': {'ft_cls': <pisap.numerics.fourier.FFT object at 0x7f71a1b88e90>},
 'linear_cls': <class 'pisap.numerics.linears.MeyerWaveletsCompactInFourierSpace'>,
 'linear_kwargs': {'maxscale': 3},
 'max_nb_of_iter': 25,
 'mu': 5e-07,
 'report': False,
 'verbose': 0}
 - best score for compute_psnr is -20.3663266298 obtained with:
 - {'data': array([[ 373.8576  +0.j    , ..., -281.6154 -31.545j ],
       ..., 
       [-217.8377-187.4362j, ...,  143.9425+174.6482j]]),
 'gradient_cls': <class 'pisap.numerics.gradient.Grad2DAnalyse'>,
 'gradient_kwargs': {'ft_cls': <pisap.numerics.fourier.FFT object at 0x7f71a1b88e90>},
 'linear_cls': <class 'pisap.numerics.linears.MeyerWaveletsCompactInFourierSpace'>,
 'linear_kwargs': {'maxscale': 3},
 'max_nb_of_iter': 25,
 'mu': 5e-07,
 'report': False,
 'verbose': 0}
 - best score for compute_nrmse is 1.0498727035 obtained with:
 - {'data': array([[ 373.8576  +0.j    , ..., -281.6154 -31.545j ],
       ..., 
       [-217.8377-187.4362j, ...,  143.9425+174.6482j]]),
 'gradient_cls': <class 'pisap.numerics.gradient.Grad2DAnalyse'>,
 'gradient_kwargs': {'ft_cls': <pisap.numerics.fourier.FFT object at 0x7f71a1b88e90>},
 'linear_cls': <class 'pisap.numerics.linears.MeyerWaveletsCompactInFourierSpace'>,
 'linear_kwargs': {'maxscale': 3},
 'max_nb_of_iter': 25,
 'mu': 5e-07,
 'report': False,
 'verbose': 0}