question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] DictMapper

See original GitHub issue

image In this example you pass the transformer a column to transform but also a dict. In this case you’d pass;

{'young': 1, 'adult': 2, 'old': 3}

A transformer that transformers based on a dictionary. I don’t know if sklearn has this feature but I couldn’t find it.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
koaningcommented, Jun 29, 2020

@kayhoogland this is why I usually wait until @MBrouns gives feedback before I implement something 😉.

From my end: I’ve tried using the Ordinal Encoder in the past but it is not an intuitive API.

I can imagine if you map strings to numeric values you could surely get some gridsearch value out of it though. I like you could enfore monotonicity across a discrete variable this way and how you might add the hard “up-down-up” shape too if you’d like.

{"young": 1, "adult": 2, "old": 3}
{"young": 1, "adult": 2, "old": 5}

Suppose you’d use these mappings in a disease suseptibility study, I can imagine it can be use-ful to gridsearch.

1reaction
MBrounscommented, Jun 29, 2020

Some things that might be worth discussing:

  1. Why does this need to live in a transformer? I don’t expect to gridsearch over it and it doesn’t contain learned properties as far as I can tell.

  2. Isn’t this what the OrdinalEncoder in sklearn does?

Read more comments on GitHub >

github_iconTop Results From Across the Web

dictmapper - PyPI
dictmapper was created to help transforming a sequence of python dictionaries to tabular format and specifically to transform json documents ...
Read more >
Source code for sklego.preprocessing.dictmapper
[docs]class DictMapper(TransformerMixin, BaseEstimator): """ Map the values of values of columns according to the input dictionary, fall back to the default ...
Read more >
tfsnippet.modules — TFSnippet 0.1.2 documentation
This module is a branch module, which maps the inputs into a list of outputs, according to the specified mapper list. Each item...
Read more >
scikit-lego/readme.md at main - GitHub
DeadZoneRegressor experimental feature that has a deadzone in the cost ... DictMapper assign numeric values on categorical columns; sklego.preprocessing.
Read more >
xyz.josephcz.dictmapper - Python package | Snyk
Learn more about xyz.josephcz.dictmapper: package health score, popularity, ... The encoding is a parameter of python built-in function open (See: Python ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found