yellowbrick
yellowbrick copied to clipboard
Extend ColorMap with target type detection and color resolution
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:
- Operate as a function or dictionary that returns a color for a value.
- Should be able to return both categorical and continuous color scales.
- Should be able to accept a palette or cmap name, or a list of colors and resolve them.
- 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', ...]
Can I be assigned this issue? Please help me proceed with this.
@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!