hoxo-m / densratio_py

A Python Package for Density Ratio Estimation
https://github.com/hoxo-m/densratio_py
Other
127 stars 30 forks source link

what's the x and y? #1

Open chamwen opened 6 years ago

chamwen commented 6 years ago

An excellent package for Density Ratio Estimation, but for a greener, how to get the x, y variables confused me. For example, with a train data and test data, the x means a sample in train data? the y means a sample in test data? If so, how can we get a y that associated with x ?

ytakashina commented 6 years ago

It seems (to me) the comment in densratio.densratio is a bit confusing.

"""Estimate Density Ratio p(x)/q(y) Args: x: sample from p(x). y: sample from p(y).

Maybe the comment can be modified as follows:

"""Estimate Density Ratio p(x)/q(x). Args: x: sample from p(x). y: sample from q(x).

where p(x) and q(x) denote the test/train distributions on the same random variable X.

@chamwen

the x means a sample in train data? the y means a sample in test data?

I think x is a sample from a test distribution p(x), while y denotes a sample from a training distribution q(x).

how can we get a y that associated with x ?

Once the parameters are learned from samples using densratio.densratio(x, y), you can compute the density ratio on x_new with uLSIF.compute_density_ratio(x_new). The uLSIF object is returned from densratio.densratio(x, y).

See also: http://www.jmlr.org/papers/volume10/kanamori09a/kanamori09a.pdf.

ameya98 commented 5 years ago

This should be a lot clearer in the code now. To answer the above questions, suppose you have n samples x1 from a distribution p(x), and n samples x2 from a distribution q(x). Then, densratio estimates w(x) = p(x)/q(x). It can now even estimate the alpha-relative density ratio, as well as the alpha-relative PE-divergence and KL-divergence between p(x) and q(x).