Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ac/mcnnm #3

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Ac/mcnnm #3

wants to merge 7 commits into from

Conversation

achenzion
Copy link
Collaborator

initial MC commit + refactor to centralize synthetic outcome creation for ease of integration with MC

@achenzion achenzion requested a review from apoorvalal February 9, 2025 18:17
NOTE: Built in collaboration with ChatGPT o3-mini-high

"""
def __init__(self, lambda_param=1e-3, max_iter=500, tol=1e-4, verbose=False):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good (and surprisingly simple!); would be good to parametrize whether to partial out FEs before fitting MC though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya. Can add the parameters, but got to decide the right way to pull them out. I couldn't come up with an elegant way that nested the intercept inclusion for the other methods, but maybe that is a problem for synth.py. Originally I was thinking maybe that can but upstream, but realized the FE will need to be iterative within each SVT iteration (if I recall correctly) so will need a mcnnm specific implementation.

@apoorvalal
Copy link
Owner

Thanks for taking a crack at this; I've been down the LLM finetuning/evals mines lately and haven't been able to develop this much.

Also I remember Susan and co's package does the iterative SVT work in C++; might be feasible to do the same via pyensmallen (or even directly use the c++ code in their library via pybind11).

@apoorvalal
Copy link
Owner

apoorvalal commented Feb 9, 2025

This and this are best factor model libraries I've found in python; could be useful to benchmark against them / potentially wrap them.

@achenzion
Copy link
Collaborator Author

Thanks for taking a crack at this; I've been down the LLM finetuning/evals mines lately and haven't been able to develop this much.

Also I remember Susan and co's package does the iterative SVT work in C++; might be feasible to do the same via pyensmallen (or even directly use the c++ code in their library via pybind11).

Ya, I started going down that rabbit hole. Here is the code explicitly https://github.com/susanathey/MCPanel/blob/master/src/mcnnm_R.cpp

After trying a bit I did some research to try and figure it out, but got a bit stuck. It was suggested that a python binding might not be that much better for the base SVD which makes sense. We'd probably only benefit from binding the whole iterative SVT. Agree worth exploring those alternatives (alt packages AND porting the implementation from that package) for benchmarking.

@achenzion
Copy link
Collaborator Author

@apoorvalal how were you thinking about generalizing the syntax for Synth to MC, Vertical Reg and Horizintal Reg? I pulled out the _get_synthetic which seemed necessary given MC is less "weight" focused, but other comments before this merge? I figure we can connect MC with Synth in the next PR.

achenzion

This comment was marked as off-topic.

Ayal Chen-Zion added 2 commits February 15, 2025 14:24
…how results. Edit ADH notebook to highlight matching error.
@achenzion achenzion requested a review from apoorvalal February 16, 2025 03:24
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was a use of synth instead of matching_synth so the matching section wasn't actually using matching estimator. It threw an error when corrected, but I did not address it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Y, W,N_treated = convert_to_W(Y_treated, Y_control, T_pre)
print("Y control std:",np.std(Y_control))
# Fit matrix completion model
mcnnm = MatrixCompletionEstimator(lambda_param=1e+1, max_iter=500, tol=1e-8,verbose=verbose)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now added lambda that performed reasonable on ADH data. Need to add cross validation for lambda selection or consider alternative intelligent selection (printed std of Y above to consider, but did not use)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants