<div dir="ltr">Hi Yacine,<div>If I'm understanding you correctly, I think what you have in mind is already implemented in scikit-learn in the <a href="http://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.TfidfVectorizer.html">TF-IDF vectorizer</a>.</div><div><br></div><div>Best,</div><div>   Jake</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"> <font size="1">Jake VanderPlas</font></div><div dir="ltr"><font size="1"> Senior Data Science Fellow</font></div><div dir="ltr"><span style="font-size:x-small"> Director of Open Software</span><div><div><font size="1"> </font><span style="font-size:x-small">University of Washington </span><span style="font-size:x-small">eScience Institute<br></span></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Sat, Jan 27, 2018 at 9:59 PM, Yacine MAZARI <span dir="ltr"><<a href="mailto:y.mazari@gmail.com" target="_blank">y.mazari@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div><div>Hello,<br><br></div>I would like to work on adding an additional feature to "sklearn.feature_extraction.<wbr>text.CountVectorizer".<br><br></div>In the current implementation, the definition of term frequency is the number of times a term t occurs in document d.<br></div><br>However, another definition that is very commonly used in practice is the <a href="https://en.wikipedia.org/wiki/Tf%E2%80%93idf#Term_frequency_2" target="_blank">term frequency adjusted for document length</a>, i.e: tf = raw counts / document length.<br><br></div>I intend to implement this by adding an additional boolean parameter "relative_frequency" to the constructor of CountVectorizer.<br></div>If the parameter is true, normalize X by document length (along x=1) in "CountVectorizer.fit_<wbr>transform()".<br><br></div>What do you think?<br></div>If this sounds reasonable an worth it, I will send a PR.<br><br></div>Thank you,<br></div>Yacine.<br></div>
<br>______________________________<wbr>_________________<br>
scikit-learn mailing list<br>
<a href="mailto:scikit-learn@python.org">scikit-learn@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scikit-learn" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/scikit-learn</a><br>
<br></blockquote></div><br></div>