Make it easy to use different color for mean in plot_partial_dependence
See original GitHub issueIt would be great to be able to give a different color or scheme to the average in pd plots.
For example, this plot is actually quite interesting in terms of ICE showing trends that are not in the average:
(yes this is real data and I’m excited that ICE is useful!)
I know which one is the average, but it’s kinda hard to see. If I set subsample to the default, it’s certainly impossible to see.
I tried to get the line out of the lines_
but I’m struggling a bit (and I think something is off there EDIT: I was on a pre #18359 commit).
Using the example from the docs you can do:
from sklearn.ensemble import RandomForestRegressor
from sklearn.datasets import fetch_california_housing
from sklearn.inspection import plot_partial_dependence
X, y = fetch_california_housing(return_X_y=True, as_frame=True)
features = ['MedInc', 'AveOccup', 'HouseAge', 'AveRooms', 'AveOccup']
est = RandomForestRegressor(n_estimators=10)
est.fit(X, y)
display = plot_partial_dependence(
est, X, features, kind="both", subsample=100,
n_jobs=3, grid_resolution=20, random_state=0
)
display.plot(n_cols=5)
for i in range(display.lines_.shape[1]):
display.lines_[0,i,-1].set_color('k')
display.axes_[0, i].legend() # needed to update the legend color
I don’t think the order of the lines in lines_
is documented.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Partial dependence plots with Scikit-learn
PartialDependenceDisplay allows us to plot a subset of individual predictions along with the average to get a better sense of the data:
Read more >Advanced Plotting With Partial Dependence
The partial dependence curves can be plotted for the multi-layer perceptron. In this case, line_kw is passed to from_estimator to change the color...
Read more >pdp: Partial Dependence Plots
Character string specifying the color to use for the partial dependence function when plot.pdp = TRUE. Default is "red". pdp.size.
Read more >MATLAB plotPartialDependence
This MATLAB function computes and plots the partial dependence between the predictor variables listed in Vars and the responses predicted by using the ......
Read more >how to set h20 partial_plot partial dependence plot figsize
Try adding the parameter figsize=(10, 6) (here this is 10 x 6 inches) or in a separate line of code model.figure_.set_size_inches(10, 6) ....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We need to find the right API because we already have
line_kw
. I don’t know if it would make sense to deprecate it and addice_lines_kw
andpd_line_kw
?or not deprecate but let
ice_lines_kw
andpd_line_kw
take priority overline_kw
(i.e. override)? This way one can still control all lines withline_kw
while having more fine-grain control with the new params