py-why / py-why/EconML

Moving transformer in TreatmentExpansionMixin

Open
#155 2 comments 0 reactions 1 assignee View on GitHub

@kbattocchi is already working on this.

Since Nov 11, 2019.

enhancement
Dominant language
Jupyter Notebook
Stars
4.8k
Forks
827
PR merge metrics
No merged PRs in 30d

Description

It seems that all of the classes the inherit from the TreatmentExpansionMixin so as to perform discrete treatment expansion, are doing the exact same transformer:

self._label_encoder = LabelEncoder()
self._one_hot_encoder = OneHotEncoder(categories='auto', sparse=False)
self.transformer = FunctionTransformer(
            func=(lambda T:
                  self._one_hot_encoder.transform(
                      self._label_encoder.transform(T).reshape(-1, 1))[:, 1:]),
            validate=False)

Shouldn't this piece of code move there? Or at least we can have a subclass called DiscreteTreatmentExpansionMixin, which is specific to this type of transformer and move this code there. It used to be that the OrthoForest was doing sth different, but this was a bug. Now it is doing exactly the same.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.