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

Fixed inference results when cate_feature_names is not defined #225

Merged
merged 2 commits into from
Feb 25, 2020

Conversation

moprescu
Copy link
Contributor

No description provided.

Copy link
Contributor

@heimengqi heimengqi left a comment

Choose a reason for hiding this comment

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

Looks good!

Copy link
Collaborator

@kbattocchi kbattocchi left a comment

Choose a reason for hiding this comment

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

This is great. But could you please also add a test that covers the else branch so that we don't regress this change in the future?

@moprescu
Copy link
Contributor Author

This is great. But could you please also add a test that covers the else branch so that we don't regress this change in the future?

@kbattocchi I thought about that, but for that to work, we need a CATE estimator with linear final stage that will never have cate_feature_names defined. If you have a better idea for testing, let me know!

@kbattocchi
Copy link
Collaborator

kbattocchi commented Feb 25, 2020

This is great. But could you please also add a test that covers the else branch so that we don't regress this change in the future?

@kbattocchi I thought about that, but for that to work, we need a CATE estimator with linear final stage that will never have cate_feature_names defined. If you have a better idea for testing, let me know!

I think that one fairly straightforward approach would be to create a very simple wrapper like:

class NoFtNamesEst:
    def __init__(self, cate_est):
        self.cate_est = clone(cate_est, safe=False)

    def __getattr__(self, name):
        if name != 'cate_feature_names`:
            return getattr(self.cate_est, name)
        else:
            return self.__getattribute__(name)

and then test that you can get the inference results with either a plain DML estimator or a wrapped one.

Copy link
Collaborator

@kbattocchi kbattocchi left a comment

Choose a reason for hiding this comment

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

Consider renaming the test, but otherwise looks great.

cls.T = np.random.normal(0, 1, size=(cls.n, ))
cls.Y = np.random.normal(0, 1, size=(cls.n, ))

def test_inference_results(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rename to something like test_inference_no_feature_names or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I named it this way so we can add more tests under the same method in the future. And this is just one subtest.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay; I generally prefer to have a larger number of fine grained tests than a smaller number of broader tests where possible because it makes it quicker to track down the nature of the error when there's a failure, but I don't feel super strongly about it.

@moprescu moprescu merged commit 0c695e0 into master Feb 25, 2020
@moprescu moprescu deleted the moprescu/inference_fix branch February 25, 2020 20:08
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.

3 participants