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

Classifiers that respect categoricals #34

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Conversation

shaycrk
Copy link
Contributor

@shaycrk shaycrk commented Oct 20, 2017

This PR creates a new pair of classifiers, CatInATree and CatInAForest, that respect categoricals when randomly sampling features. A few notes:

  • To make use of these, it also adds a couple of utilities to detect columns that should be grouped together as categoricals and modifies the _train method of ModelTrainer to pass these detected column groupings.
  • Note that because detecting categoricals relies on the feature config, it will fail to properly group all of the categoricals if column names are getting truncated.
  • The implementation here is to simply select a random subset of features that ensure all categorical values are selected together and then train a decision tree using the entire pre-selected subset throughout (as well as using this modified decision tree in a bagging classifier).
  • It does not, however, subset the features at each node as a random forest would -- this would require a more substantial rewrite of the guts of sklearn's decision trees, but would be a useful future project.

Creates a new pair of classifiers, CatInATree and CatInAForest, that respect categoricals when randomly sampling features.
remove the min_impurity_decrease parameter from DecisionTreeClassifier call to conform to sklearn 0.18
@codecov-io
Copy link

codecov-io commented Oct 20, 2017

Codecov Report

Merging #34 into master will increase coverage by <.01%.
The diff coverage is 90.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #34      +/-   ##
==========================================
+ Coverage   91.23%   91.23%   +<.01%     
==========================================
  Files          13       13              
  Lines         844      993     +149     
==========================================
+ Hits          770      906     +136     
- Misses         74       87      +13
Impacted Files Coverage Δ
catwalk/utils.py 82.67% <100%> (+5.12%) ⬆️
catwalk/model_trainers.py 93.19% <100%> (+0.99%) ⬆️
catwalk/estimators/transformers.py 86.56% <80%> (-13.44%) ⬇️
catwalk/estimators/classifiers.py 92.92% <92.85%> (-0.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9c08327...8a72cbf. Read the comment docs.

for non-categorical columns where imputation was performed, ensure the flag and
underlying column always come together for models that respect categoricals
(in the future, we may want to consider passing these separately but for the
purposes here we just add them in with the categoricals)
@shaycrk
Copy link
Contributor Author

shaycrk commented Oct 21, 2017

@hakoenig made the good point that with the new imputation branch we should also ensure that imputed flags always get picked up along with their underlying columns, so pushed a quick change that adds those groupings in here as well.

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