pymatch icon indicating copy to clipboard operation
pymatch copied to clipboard

Can I match without replacement?

Open wj-c opened this issue 7 years ago • 10 comments

The matching process is done with replacement, so a single majority record can be matched to multiple minority records. Can I match without replacement? So a single majority record can only be matched to one minority record.

wj-c avatar Nov 09 '18 05:11 wj-c

I'm also interested in such an option.

tlooden avatar Jul 29 '19 12:07 tlooden

update: I've implemented a matching with replacement option in the matching method on my local machine. If using this option, it also permutes the dataframe indices so you can check for order effects (which are necessarily imposed by matching without replacement). Happy to help if you still need that!

tlooden avatar Jul 31 '19 22:07 tlooden

I am interested in this feature. Any prevision of when the pull request will be reviewed?

Warvito avatar Nov 02 '19 11:11 Warvito

Yeah, I am also waiting desperately for this feature. It would be very nice if this would be implemented!

JohannesWiesner avatar Nov 14 '19 13:11 JohannesWiesner

Yeah, I am also waiting desperately for this feature. It would be very nice if this would be implemented!

Very welcome to use the adapted version in the meanwhile which has this feature implemented!

https://github.com/tlooden/pymatch

tlooden avatar Nov 14 '19 20:11 tlooden

Yeah, I am also waiting desperately for this feature. It would be very nice if this would be implemented!

Very welcome to use the adapted version in the meanwhile which has this feature implemented!

https://github.com/tlooden/pymatch

Your version again throws the error "ValueError: Unable to coerce to Series, length must be 1: given 393". Seems to be related to issues #12 / #11

JohannesWiesner avatar Nov 18 '19 09:11 JohannesWiesner

Thank you for the feedback, i will have a look at that!

EDIT: yes i see what you mean. I had downgraded pandas to 0.23.4 in my pymatch environment, then it works. Hopefully both solutions will be merged.

tlooden avatar Nov 18 '19 09:11 tlooden

Thank you for the feedback, i will have a look at that!

EDIT: yes i see what you mean. I had downgraded pandas to 0.23.4 in my pymatch environment, then it works. Hopefully both solutions will be merged.

Any idea how to resolve the error ""ValueError: Unable to coerce to Series, length must be 1: given 393" without downgraded Pandas? I am unable to install Pandas 0.23.4 on my system so I'm looking for a way to modify the code to be compatible with a newer Pandas version.

MattFill avatar Feb 26 '22 03:02 MattFill

The same error here. Add this after you importing pymatch: class MyMatcher(Matcher): @staticmethod def _scores_to_accuracy(m, X, y): preds = [[1.0 if i >= .5 else 0.0 for i in m.predict(X)]] return (y.to_numpy().T == preds).sum() * 1.0 / len(y)

LechenQian avatar Aug 09 '22 06:08 LechenQian

I layered in the with_replacement flag in my fork and set the default value to False. It seems to work.

pip install git+https://github.com/chrico-bu-uab/pymatch.git#egg=pymatch

chrico-bu-uab avatar Sep 12 '23 15:09 chrico-bu-uab