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

Extend ColorMap with target type detection and color resolution #677

Open
bbengfort opened this issue Dec 28, 2018 · 2 comments
Open

Extend ColorMap with target type detection and color resolution #677

bbengfort opened this issue Dec 28, 2018 · 2 comments
Labels
level: intermediate python coding expertise required type: feature a new visualizer or utility for yb type: technical debt work to optimize or generalize code

Comments

@bbengfort
Copy link
Member

Describe the solution you'd like

The yellowbrick.style.colors.ColorMap object is one of the most underutilized objects in our code base and it solves many of the color issues we have such as #325 #327 #244 #556 #70 #73 #399. Now that #588 and #73 are solved in #676, I propose that we extend this object with target type detection and color resolution so that it can be used more meaningfully. The new implementation should do the following:

  1. Operate as a function or dictionary that returns a color for a value.
  2. Should be able to return both categorical and continuous color scales.
  3. Should be able to accept a palette or cmap name, or a list of colors and resolve them.
  4. Should be able to detect the target type and determine continuous or discrete colors

Is your feature request related to a problem? Please describe.

Our color handling is inconsistent at best. A number of visualizers such as RadViz, ParallelCoordinates, PCA, TSNE, etc. only allow for discrete/categorical colors when they could benefit from continuous colors for regression problems. The resolve_colors function only works for discrete values, the use of palette names and cmap names is also inconsistent. By creating a single color determination object across all of Yellowbrick, we'll have an easier time managing colorization in our plots.

Examples

Categorical colors with color maps/names:

colors = ColorMap(colors='Set1', names=['a', 'b', 'c'])
colors['a'] # 'red'
colors[0]  # 'red'

colors = ColorMap(colors='Blues', n_colors=2)
colors['a']
colors[0]
colors['b'] # raises KeyError

Continuous colors

colors = ColorMap(colors='Jet', minv=0.0, maxv=12.0)
colors[0.3]
colors[1.2]

Learning and transforming colors like an estimator

colors = ColorMap(colors='RdBuGn').fit(y)
colors.target_type_ # 'continuous' 
colors.transform(y) # list of colors returned 

colors = ColorMap().fit(y)
colors.target_type_ # 'discrete' 
colors.transform(y) # ['r', 'b', 'g', 'r', 'g', 'r', ...]
@bbengfort bbengfort added type: feature a new visualizer or utility for yb type: technical debt work to optimize or generalize code level: intermediate python coding expertise required labels Dec 29, 2018
@dnabanita7
Copy link
Contributor

Can I be assigned this issue? Please help me proceed with this.

@pdamodaran
Copy link
Contributor

@naba7 - We really appreciate your enthusiasm to contribute to Yellowbrick! We don’t usually specifically assign people to individual tasks unless it is something only they can take care of, we usually proceed by having the contributor open a PR and for the issue and then the discussion takes place there. We see that you have already opened a PR for #684, which is great! When you are ready to take care of the other issues, please go ahead and submit a PR for them as well.

Also, please bear with us during this time. We are all volunteers and are currently overloaded at the moment. We do intend to get back to you but it might take longer than usual.

Thanks again for contributing to Yellowbrick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level: intermediate python coding expertise required type: feature a new visualizer or utility for yb type: technical debt work to optimize or generalize code
Projects
None yet
Development

No branches or pull requests

3 participants