Package BIP :: Package Bayes :: Module Melding :: Class FitModel
[hide private]
[frames] | no frames]

Class FitModel

source code

Fit a model to data generating Bayesian posterior distributions of input and outputs of the model.
Instance Methods [hide private]
 
__init__(self, K, L, model, ntheta, nphi, inits, tf, phinames, thetanames, wl=None, nw=1, verbose=False)
Initialize the model fitter.
source code
 
set_priors(self, pdists, ppars, tdists, tpars)
Set the prior distributions for Phi and Theta
source code
 
_init_priors(self, prior=None) source code
 
do_inference(self, prior, data, predlen, method) source code
 
run(self, data, method, monitor=False)
Fit the model against data
source code
 
_monitor_setup(self)
Sets up realtime plotting of inference
source code
 
_monitor_plot(self, series, prior)
Plots real time data
source code
 
plot_results(self, names=[])
Plot the final results of the inference
source code
 
_read_results(self)
read results from disk
source code
Method Details [hide private]

__init__(self, K, L, model, ntheta, nphi, inits, tf, phinames, thetanames, wl=None, nw=1, verbose=False)
(Constructor)

source code 
Initialize the model fitter.
Parameters:
  • K - Number of samples from the priors. On MCMC also the number of samples of the posterior.
  • L - Number of samples of the posteriors. Only used on SIR and ABC methods.
  • model - Callable (function) returning the output of the model, from a set of parameter values received as argument.
  • ntheta - Number of parameters included in the inference.
  • nphi - Number of outputs of the model.
  • inits - inits initial values for the model's variables.
  • tf - Length of the simulation, in units of time.
  • phinames - List of names (strings) with names of the model's variables
  • thetanames - List of names (strings) with names of parameters included on the inference.
  • wl - window lenght length of the inference window.
  • nw - Number of windows to analyze on iterative inference mode
  • verbose - Verbose output if True.

set_priors(self, pdists, ppars, tdists, tpars)

source code 
Set the prior distributions for Phi and Theta
Parameters:
  • pdists - distributions for the output variables. For example: [scipy.stats.uniform,scipy.stats.norm]
  • ppars - paramenters for the distributions in pdists. For example: [(0,1),(0,1)]
  • tdists - same as pdists, but for input parameters (Theta).
  • tpars - same as ppars, but for tdists.

run(self, data, method, monitor=False)

source code 
Fit the model against data
Parameters:
  • data - dictionary with variable names and observed series, as Key and value respectively.
  • method - Inference method: "ABC", "SIR" or "MCMC"