<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Apr 1, 2018 at 6:36 PM, Randy Ellis <span dir="ltr"><<a href="mailto:randalljellis@gmail.com" target="_blank">randalljellis@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">Hello to the Scikit-learn community!<br><br>I am doing case-control matching for an electronic health records study. My question is, is it possible to run Sklearn's NearestNeighbors function without replacement? As in, match the treated group to the untreated group without re-using any of the untreated group data points? If so, how? By default, it uses replacement. I know this because I tested it on some data of mine. <br><br>The code I used is in the confirmed answer here: <a href="https://stats.stackexchange.com/questions/206832/matched-pairs-in-python-propensity-score-matching" target="_blank">https://stats.stackexchange.<wbr>com/questions/206832/matched-<wbr>pairs-in-python-propensity-<wbr>score-matching</a><br><div><font color="#242729" face="Arial, Helvetica Neue, Helvetica, sans-serif"><span style="font-size:15px"><br></span></font></div><div>Thanks so much in advance,</div></div></blockquote><div><br></div><div>No, pairwise matching without replacement is not implemented within scikit-learn's nearest neighbors routines.</div><div><br></div><div>It seems like an algorithm you would have to think carefully about because the number of potential pairs grows exponentially with the number of points, and I don't think it's true that choosing the nearest available neighbor of points in sequence will guarantee you to find the optimal configuration. You'd also have to carefully define what you mean by "optimal"... are you seeking to minimize the sum of all distances? The sum of squared distances? The maximum distance? The results would change depending on the metric you define. And you'd probably have to figure out some way to reduce the exponential search space in order to calculate the result in a reasonable amount of time for your data.</div><div><br></div><div>You might look into the literature on propensity score matching; I think that's one area where this kind of neighbors-without-replacement algorithm is often used.</div><div><br></div><div>Best,</div><div>   Jake</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class="HOEnZb"><font color="#888888"><div><br></div><div>-- <br><div class="m_4971091106641875942gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="color:rgb(0,0,0);font-family:Tahoma;font-size:13px"><div style="font-family:arial,sans-serif"><font face="arial, helvetica, sans-serif"><span style="font-size:13.3333px"><b>Randall J. Ellis, B.S.</b></span></font></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><font face="arial, helvetica, sans-serif"><font style="color:rgb(0,0,0);font-size:13px">PhD Student, Biomedical Science, Mount Sinai<br style="font-size:13.3333px"></font><span style="color:rgb(0,0,0);font-size:13.3333px">Special Volunteer, </span><font color="#000000"><span style="font-size:13.3333px"><a href="http://www.michaelideslab.org/" target="_blank">http://www.<wbr>michaelideslab.org/</a>, NIDA IRP</span></font></font></div><div style="font-family:arial,sans-serif"><span style="font-size:13.3333px"><font face="arial, helvetica, sans-serif">Cell: <a href="tel:(954)%20260-9891" value="+19542609891" target="_blank">(954)-260-9891</a></font></span></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div></font></span></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></div>