class scipy.maxentropy.bigmodel

A maximum-entropy (exponential-form) model on a large sample space.

The model expectations are not computed exactly (by summing or integrating over a sample space) but approximately (by Monte Carlo estimation). Approximation is necessary when the sample space is too large to sum or integrate over in practice, like a continuous sample space in more than about 4 dimensions or a large discrete space like all possible sentences in a natural language.

Approximating the expectations by sampling requires an instrumental distribution that should be close to the model for fast convergence. The tails should be fatter than the model.


beginlogging(filename[, freq]) Enable logging params for each fn evaluation to files named ‘filename.freq.pickle’, ‘filename.(2*freq).pickle’, ...
clearcache() Clears the interim results of computations depending on the
crossentropy(fx[, log_prior_x, base]) Returns the cross entropy H(q, p) of the empirical
dual([params, ignorepenalty, ignoretest]) Computes the Lagrangian dual L(theta) of the entropy of the
endlogging() Stop logging param values whenever setparams() is called.
entropydual([params, ignorepenalty, ignoretest]) Computes the Lagrangian dual L(theta) of the entropy of the
estimate() This function approximates both the feature expectation vector
expectations() Estimates the feature expectations E_p[f(X)] under the current
fit(K[, algorithm]) Fit the maxent model p whose feature expectations are given
grad([params, ignorepenalty]) Computes or estimates the gradient of the entropy dual.
log(params) This method is called every iteration during the optimization process.
lognormconst() Estimate the normalization constant (partition function) using
logparams() Saves the model parameters if logging has been
logpdf(fx[, log_prior_x]) Returns the log of the estimated density p(x) = p_theta(x) at the point x.
normconst() Returns the normalization constant, or partition function, for the current model.
pdf(fx) Returns the estimated density p_theta(x) at the point x with feature statistic fx = f(x).
pdf_function() Returns the estimated density p_theta(x) as a function p(f) taking a vector f = f(x) of feature statistics at any point x.
resample() (Re)samples the matrix F of sample features.
reset([numfeatures]) Resets the parameters self.params to zero, clearing the cache variables dependent on them.
setcallback([callback, callback_dual, ...]) Sets callback functions to be called every iteration, every function evaluation, or every gradient evaluation.
setparams(params) Set the parameter vector to params, replacing the existing parameters.
setsampleFgen(sampler[, staticsample]) Initializes the Monte Carlo sampler to use the supplied
setsmooth(sigma) Specifies that the entropy dual and gradient should be computed with a quadratic penalty term on magnitude of the parameters.
settestsamples(F_list, logprob_list[, ...]) Requests that the model be tested every ‘testevery’ iterations
stochapprox(K) Tries to fit the model to the feature expectations K using
test() Estimate the dual and gradient on the external samples, keeping track of the parameters that yield the minimum such dual.

Previous topic


Next topic


This Page