Hello guys.I have sent a pull request for the PL2 scheme.Please do have a look.I will begin work on the DPH scheme after working on the feedback of this scheme.Also,I&#39;ll add the feature tests for this scheme after I&#39;ve worked on the feedback.Thanks. <br>
<br><a href="https://github.com/xapian/xapian/pull/8">https://github.com/xapian/xapian/pull/8</a><br><br><br><div class="gmail_quote">On Wed, Mar 13, 2013 at 12:14 AM, aarsh shah <span dir="ltr">&lt;<a href="mailto:aarshkshah1992@gmail.com" target="_blank">aarshkshah1992@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sorry, the derivative of P evaluates to<br><br>Q +  (Q * log (Q * wdf) ) -( Q * log lamda) - Q + (0.5 / wdf )<br><br>= Q * (log (Q * wdf) - log (lamda)  +( 0.5 / (Q * wdf)))<div class="HOEnZb">
<div class="h5"><br><br><br><div class="gmail_quote">On Tue, Mar 12, 2013 at 11:44 PM, aarsh shah <span dir="ltr">&lt;<a href="mailto:aarshkshah1992@gmail.com" target="_blank">aarshkshah1992@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>&gt;I think the formula you have there for wdfn is wrong -<br>
<a href="http://ir.dcs.gla.ac.uk/wiki/FormulasOfDFRModels" target="_blank">&gt;http://ir.dcs.gla.ac.uk/wiki/FormulasOfDFRModels</a> gives LaTeX source for<br>
&gt;what it calls tfn, which is your wdfn: <br>
&gt;tfn=tf\cdot\log_2(1+c\cdot\frac{avg\_l}{l})<br>&gt;So the &#39;1+c*&#39; bit is *inside* the log, i.e.:<br>&gt;wdfn = wdf * log(1 + c * average_doc_length/length_of_d)<br><br></div>Yeah sorry,that was a typo.<div>
<br>
<br>&gt;That agrees with Amati&#39;s slides from ESSIR 2007, except that he says<br>
&gt;&quot;ln&quot; not &quot;log&quot; in the tfn formula, which suggests log to the base e.<br>
&gt;The base of the log would only make a factor difference to wdfn, but<br>&gt;that seems like it would affect the overall weight in a more complex<br>&gt;way.<br>
&gt;Amati&#39;s phd thesis also has ln (equation 6.10 on page 118), and that<br>
&gt;ln is necessary for the H1 approximating H2 for large l observation<br>
&gt;to work (end of page 118).<br><br></div>I know,I&#39;ve gone through the relevant part of the thesis.But the thing is,Amati also did a paper on DFR schemes along with Van Rijsberge titled <br><i>Probabilistic models of information retrieval
based on measuring divergence    from randomness.<br></i>I&#39;ve read the paper through and through and in this paper,he has taken the base of the log to be 2 everywhere including the H2 normalization.Moreover,the terrier code has also taken the base to be 2 . So,I decided to go along with it. Please do let me know if you think a base of e is better .<div>

<br>
<br>&gt;I&#39;m not sure I totally follow you here.
<br>
&gt;Differentiating P with respect to wdf I get:<br>
&gt;Q*{log(wdfn) + wdfn/(2*ln(wdfn)) - log lambda - log e + 1/(4*wdfn)}<br>&gt;Where Q = log(1+c*avg_l/l)<br>
<br></div>Umm...Olly , I get a different derivative . <br>P = (Q * wdf * log( (Q * wdf ) / lamda) + ((lamda - Q * wdf) * log e) +( 0.5 * log(2 * pi * Q *wdf)))<br> <br>Let the base of all logarithms be e here . Then ,<br>

<br>P = ( Q * wdf * log (Q * wdf)) - (Q * wdf * log (lamda)) + (lamda - Q* wdf) + (0.5 * log (2 * pi * Q * wdf))<br>
<br>because log e =1 and log (a / b) = log a - log b.<br> <br>Therefore ,the derivative of P is<br><br>P = (Q * wdf * (1 / (Q * wdf))  * Q) + (Q * log (Q * wdf)) - (Q * log lamda) +  (0 -Q) + (0.5 * (1 / (2 * pi * Q * wdf)) * 2 * pi * Q)<br>


<br>because of the derivative of::-<br>any constant = 0<br>log x = 1 / x<br>log(kx) = (1 / k * x ) * k where k is any constant<br>f(x) * g(x) = ((f(x) * g &#39; (x)) + (f &#39; (x) * g(x)) )<br><br>Hence,derivative of P evaluates to :<br>


<br>Q + (Q * log Q) + (Q * log (Q * wdf) ) -( Q * log lamda) - Q + (0.5 / wdf )<br><br>because log (a *b) = log a + log b <br><br>Thus,derivative of P is<br><br>Q * (log Q + log (Q * wdf ) - log lamda + (0.5 / (Q *wdf)))<div>

<br>
<br>&gt;can&#39;t wdfn be &lt; 1, in which case log(wdfn) and<br>
&gt;ln(wdfn) will be negative.<br><br></div>I just realized that this is true, if (1 + c ave_d  / len_d) is less than the base of the log for H2,wdfn can be less than 1  and log wdfn will be negative.I&#39;ll work on it and get back to you.And yes,in his thesis,Amati has considered only non negative values of c.<br>


<br>Ill keep working on refining the bound to make it as tight as I can.Will send in a pull request in a couple of days.Thank you so much for your detailed help . Implementing the other DFR schemes will be comparatively simpler once I understand this scheme properly.<br>


<br>-Regards<span><font color="#888888"><br>-Aarsh</font></span><div><div><br><br><br><br><br><br><br><br><br><blockquote class="gmail_quote"></blockquote>
 <blockquote class="gmail_quote"></blockquote><blockquote class="gmail_quote"></blockquote><blockquote class="gmail_quote">
<br>
<br>
<br>
</blockquote><br><br><div class="gmail_quote">On Tue, Mar 12, 2013 at 7:38 PM, Olly Betts <span dir="ltr">&lt;<a href="mailto:olly@survex.com" target="_blank">olly@survex.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div>On Tue, Mar 12, 2013 at 01:55:51AM +0530, aarsh shah wrote:<br>
&gt; Hello guys.I am working on implementing the PL2 weighting scheme of the DFR<br>
&gt; framework by Gianni Amati.<br>
&gt; It uses the Poisson approximation of the Binomial as the probabilistic<br>
&gt; model (P), the Laplace law of succession to calculate the after effect of<br>
&gt; sampling or the risk gain (L) and within document frequency  normalization<br>
&gt; H2(2) (as proposed by Amati in his PHD thesis).<br>
&gt;<br>
&gt; The formula for w(t,d) in this scheme is given by::-<br>
&gt;<br>
&gt; w(t,d) = wqf * L * P<br>
&gt; where<br>
&gt;          wqf = within query frequency<br>
&gt;          L = Laplace law of after effect sampling =1 / (wdfn + 1)<br>
&gt;          P = wdfn * log (wdfn / lamda) + (lamda - wdfn) log(e) + 0.5 * log<br>
&gt; (2 * pi * wdfn)<br>
&gt;          wdfn = wdf * (1+c * log(average length of document in database /<br>
&gt; length of document d )) (H2 Normalization )<br>
&gt;          lamda = mean of the Poisson distrubution = Collection frequency of<br>
&gt; the term   / Size of the database<br>
&gt;          and the base of all logarithms is 2.<br>
&gt;          c is a constant  parameter<br>
<br>
</div>I think the formula you have there for wdfn is wrong -<br>
<a href="http://ir.dcs.gla.ac.uk/wiki/FormulasOfDFRModels" target="_blank">http://ir.dcs.gla.ac.uk/wiki/FormulasOfDFRModels</a> gives LaTeX source for<br>
what it calls tfn, which is your wdfn:<br>
<br>
tfn=tf\cdot\log_2(1+c\cdot\frac{avg\_l}{l})<br>
<br>
So the &#39;1+c*&#39; bit is *inside* the log, i.e.:<br>
<br>
 wdfn = wdf * log(1 + c * average_doc_length/length_of_d)<br>
<br>
That agrees with Amati&#39;s slides from ESSIR 2007, except that he says<br>
&quot;ln&quot; not &quot;log&quot; in the tfn formula, which suggests log to the base e.<br>
The base of the log would only make a factor difference to wdfn, but<br>
that seems like it would affect the overall weight in a more complex<br>
way.<br>
<br>
Amati&#39;s phd thesis also has ln (equation 6.10 on page 118), and that<br>
ln is necessary for the H1 approximating H2 for large l observation<br>
to work (end of page 118).<br>
<div><br>
&gt; The code is almost complete but I am stuck at a few places which are as<br>
&gt; follows:-<br>
&gt;<br>
&gt; 1.) Calculating the upper bound of the weight for the get_maxpart( )<br>
&gt; function<br>
&gt;               This one calculation has been giving me sleepless nights for<br>
&gt; a couple of days now.The problem is that L is<br>
&gt;               a decreasing function for wdfn and P as per my calculations<br>
&gt; is a increasing function . I arrived at this conclusion<br>
&gt;               because the derivative of L is always negative<br>
<br>
</div>OK so far.<br>
<div><br>
&gt; and the<br>
&gt; derivative of P is always positive (In the derivative of P, log (lamda)<br>
&gt;               will always be negative as in his thesis,Amati states that<br>
&gt; for the PL2 model, collection frequency of term &lt;&lt; Collection<br>
&gt;               Size and so lamda will always be less than one .)<br>
<br>
</div>I&#39;m not sure I totally follow you here.<br>
<br>
Differentiating P with respect to wdf I get:<br>
<br>
Q*{log(wdfn) + wdfn/(2*ln(wdfn)) - log lambda - log e + 1/(4*wdfn)}<br>
<br>
Where Q = log(1+c*avg_l/l) which is &gt; 0 since avg_l, l, and (I assume) c<br>
are all &gt; 0, so Q doesn&#39;t affect when this does/doesn&#39;t become 0.<br>
<br>
If lambda &lt; 1, then as you say (- log lamba) is positive, but there&#39;s<br>
the -log(e) and also can&#39;t wdfn be &lt; 1, in which case log(wdfn) and<br>
ln(wdfn) will be negative.<br>
<div><br>
&gt; .So, in<br>
&gt; order to find the upper bound,I simply substituted wdf=1 for L<br>
&gt;               and used wdf = wdf_upper_bound for P and multiplied them by<br>
&gt; using upper doc length bound and lower doc length<br>
&gt;               for wdfn of L and P respectively.However,this does not give<br>
&gt; that tight a bound.<br>
<br>
</div>Having an upper bound is a good start.<br>
<div><br>
&gt; Not a word has been spoken about<br>
&gt;               upper bounds on DFR weights in Amati&#39;s thesis or on his<br>
&gt; papers on DFR .<br>
<br>
</div>The upper bounds are only needed because of some optimisations we do, so<br>
I&#39;m not surprised if they aren&#39;t discussed elsewhere.<br>
<div><br>
&gt; I even tried differentiating the product of<br>
&gt;               L and P and equated that to zero as discussed on IRC but that<br>
&gt; landed me with a complicated equation with no answer<br>
&gt;               in sight.Please tell me what you&#39;ll think.<br>
<br>
</div>I got that down to this, but indeed it doesn&#39;t look easy to solve:<br>
<br>
log(w) + w*(w+1)*log(e)/log(w) = log(2*pi)+2*log(e*lamba)+lamba*log(e)<br>
<br>
I&#39;m not all that confident that&#39;s even right either.<br>
<div><br>
&gt; 2.) Documentation<br>
&gt;<br>
&gt;               This scheme belongs to a family of weighting schemes.Please<br>
&gt; do let me if I need to write any additional documentation<br>
&gt;                to introduce this new framework and the new weighting<br>
&gt; schemes.<br>
<br>
</div>I don&#39;t think we need a lengthy document about them, but it would be<br>
useful to refer people to where the schemes are defined, and also<br>
briefly mention when they might want to use a particular scheme - for<br>
example, PL2 is apparently good if you want early precision.<br>
<br>
Cheers,<br>
    Olly<br>
</blockquote></div><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>