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

Feature request: Model.predict doesn't automatically modify the input data #61

Open
davidshaw2018 opened this issue Dec 9, 2022 · 1 comment

Comments

@davidshaw2018
Copy link

Ideally, when we predict out on a fitted model, the predict method doesn't automatically modify the input dataset as it does here: https://github.com/ihmeuw-msca/regmod/blob/develop/src/regmod/models/model.py#L621

A proposed alternative:

def predict(df, inplace=True):
    ....
    return_df = pd.DataFrame()
    for i, param_name in enumerate(self.param_names):
        return_df[param_name] = self.params[i].get_param(coefs[i], data)
        if inplace:
            df[param_name] = return_df[param_name]
   return return_df

This way, the same default behavior is provided, but users passing in slices of dataframes or who in general rely on pure functions can also have that behavior enabled optionally.

@davidshaw2018
Copy link
Author

By the way, happy to do this myself too if Kelsey's busy!

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

No branches or pull requests

1 participant