Closed glouppe closed 8 years ago
CC @cranmer @jgpavez: This is still a draft, but please comment if you have questions, suggestions or critiques. For sure, this is also meant to evolve as I start coding things and realize I was wrong :)
Hi, this looks like a great start. First reactions:
wondering if RandomStreamsBase
of theano is relevant for the Simulator and/or BatchSampler
http://deeplearning.net/software/theano/library/tensor/shared_randomstreams.html#libdoc-tensor-shared-randomstreams
I just updated the RFC. There are quite significant changes with respect to the first iteration. The main one is the use of (Theano) variables at the core of the interface to allow for composition and dependencies.
Distribution or Density? It's a DensityRatio, so maybe each object should be a Density.
I renamed "Distribution" to "Random Variable", to emphasize that these objects represent more than just a probability density function.
I would call them parameters instead of hyper-parameters in this case. These are the lowest-level parameters for a parametrized distribution p(x|theta).
Changed.
we need an interface to evaluate the estimated density ratio for specified values of the parameters
This is now possible through the param_values
argument, used for specifying values to symbolic variables.
should there be both a Simulator and a BatchSampler or something similar, where the first can generate samples on the fly and the second is using a fixed set of pre-computed examples?
We could have that indeed.
There are a few notions of fit:
train classifier or other DensityRatioMixin density estimation for classifier score (if calibrate==True) fit the parameters of the resulting Distribution / model
In my mind, for a regressor-based implementation of a density ratio estimator, training the classifier + its calibration should happen in DensityRatio.fit
. Then, this (parametrized) object can be used in further step e.g. to fit the parameters of a distribution.
We should be able to support the case that the parameters of mixture coefficients are shared with parameters of one of the Distributions, and this will need to be connected to the parametrized classifier as well.
If think this should be possible by reusing the same theano variable object, though this makes me notice that the current proposal lacks the notion of "parametrized classifier". I'll think about that.
If calibrate==True, we should be able customize the density estimation technique
Agreed, I changed the interface to accommodate for that.
I think I now have a good vision of the requirements. I will try to produce in the next days/weeks a minimally working concrete implementation of this API, from which it will then be easier to discuss and reason.
Note for my future self: RegressorDensityRatio
should also provide options for controlling the number of training samples (for fitting the classifier) and the number of calibration samples.
Distribution or Density? It's a DensityRatio, so maybe each object should be a Density. I renamed "Distribution" to "Random Variable", to emphasize that these objects represent more than just a probability density function.
My understanding is that this interface is or the distribution (either explicitly known or indirectly through a simulator) for random variable x given some parameters theta. eg. the "p" in p(x|theta). I would avoid confusing the distribution with the random variable. I like either density or distribution better.
My understanding is that this interface is or the distribution (either explicitly known or indirectly through a simulator) for random variable x given some parameters theta. eg. the "p" in p(x|theta). I would avoid confusing the distribution with the random variable. I like either density or distribution bette
Sure no problem, I'll switch back to distribution.
Closing since this has now been implemented. New issues should be opened for more specific concerns.
This is a proposal for an API on density and density ratio estimation. This RFC first presents the proposed classes and then illustrates how typical use cases would be solved using this API. It mainly takes inspiration from the API of Theano and of scikit-learn.
Distributions
Interface
The
DistributionMixin
API provides a limited interface for (continuous) N-D distributions. (For now, in order to keep a simple and unique interface, we can assume that everything is continuous.)The
parameters
attributes stores the parameters of the distribution. They are provided eitherRooRealVar
.)The interface provides methods similar to scipy.stats rv_continuous for the pdf, cdf, likelihood, etc. They should also all accept a
param_values
dictionary, in order to use values in place of symbolic variables.The interface also provides a scikit-learn API through
fit
,score
,get_params
andset_params
, making it possible to plug a DistributionMixin object into a pipeline or into model selection tools.Examples
Standard distributions
Mixtures
When the likelihood is known
Likelihood-free setting
Comments
Mixture
object for composing distributions with density of the typep(x) = w0*p0(x) + w1*p1(x) + ...
. Parameters will be accessible using a syntax similar to scikit-learn parameter syntax. E.g.p0__loc
).DistributionMixin
interface. In this case, these objects will befit
from data like regular scikit-learn estimators.DistributionMixin
. In this case,pdf(X)
is not implemented. Yet bothfit
andscore
could be still be provided to optimize its parameters.Density ratios
Interface
The
DensityRatioMixin
provides a scikit-learn estimator interface for computing density ratios. The ratio function can either be learned from data drawn from the distributions of distributions, usingfit
, or by providingDistributionMixin
objects at initialization.Examples
Regressor/Classifier-based density ratio
Density ratio estimators can be implemented directly using a classifier/regressor, assuming a good calibration. If the classifier/regressor is not good enough, one could set
calibration="kde"
(or some other density estimation technique) to estimatep(s(x))
instead of usings(x)
directly (whencalibration=None
).Density ratio estimation from samples
Density ratio estimation from
DistributionMixin
objectsThe implementation of
RegressorDensityRatio
should check whetherp0
orp1
areMixture
. In this case, the ratio can be decomposed internally.Density ratio estimation with parametrized classifiers
If
p0
orp1
have non-constant internal parameters, then a parametrized classifier can/should be learned internally. As before, this could be handled by adding aparam_values
argument toRegressorDensityRatio
defining which tensor variables are free and what is their domain. Then it remains open the question on how to learn such a parametrized classifier, but in terms of API I think this is sufficient.Note: this really calls for a proposal of interface for what we will refer as a "parametrized classiifer" and how to build and predict from it.
Comments
DistributionMixin
in order to smartly computeDistributionMixin.score
, e.g. in the case ofMixture
defined on simulator components (see example above).