Two-Way Dependence Plots - #1690
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1690 +/- ##
=========================================
+ Coverage 100.0% 100.0% +0.1%
=========================================
Files 242 242
Lines 19174 19273 +99
=========================================
+ Hits 19166 19265 +99
Misses 8 8
Continue to review full report at Codecov.
|
b5eae5d to
fb3121f
Compare
c7aae1a to
347af36
Compare
freddyaboulton
left a comment
There was a problem hiding this comment.
@chukarsten Looks great! The only thing I think we should resolve before merge is how we should handle two-way plots for multiclass problems.
| data['class_label'] = np.repeat(classes, len(values[0])) | ||
| elif isinstance(features, (list, tuple)): | ||
| if len(features) == 2: | ||
| data = pd.DataFrame(avg_pred[0]) |
There was a problem hiding this comment.
This would only return the partial dependence for the first class for multiclass problems. I think we should either modify this to return the grid for all of the classes or raise an exception that two-way plots are not allowed for multiclass problems.
I don't think modifying this to return the values for all classes would be a heavy lift. I think doing something like this:
df = pd.DataFrame(avg_pred.reshape((-1, avg_pred.shape[-1])))
df.columns = values[1]
df.index = np.tile(values[0], avf_pred.shape[0])
df['classes'] = np.repeat(classes, len(values[0]))should get us most of the way there (though I didn't test 😬 ). The only thing left to modify is how the data is passed to the contour plot.
There was a problem hiding this comment.
I'm legitimately mystified by numpy's reshape function and even more by people that can so intuitively use it. Ok, cool, I'll implement this and try and see if I can follow the one-way multi-class example.
angela97lin
left a comment
There was a problem hiding this comment.
Looking great! Added a few minor comments but I think Freddy's comments are solid.
bchen1116
left a comment
There was a problem hiding this comment.
Agree with Angela and Freddy, but LGTM otherwise!
freddyaboulton
left a comment
There was a problem hiding this comment.
@chukarsten Thanks for adding support for 2-way for multiclass! Tests are solid!
| X = _convert_to_woodwork_structure(X) | ||
| X = _convert_woodwork_types_wrapper(X.to_dataframe()) | ||
|
|
||
| if isinstance(features, (list, tuple)): |
| fig = _subplots.make_subplots(rows=rows, cols=cols, subplot_titles=class_labels) | ||
| for i, label in enumerate(class_labels): | ||
|
|
||
| # Plotly trace indexing begins at 1 so we add 1 to i |
There was a problem hiding this comment.
nit-pick: This comment applies to the col=(i % 2) + 1 expression so I think we move it closer to that or get rid of it
There was a problem hiding this comment.
Thanks!!! Good call. I must have a bunch of stuff missing in here but I definitely have PR fatigue on this one.
… the two way part dep calculated, just trying to integrated it into the plots.
…alize this and make sure it makes sense. Also not sure x and y line up.
dc23895 to
968d4bd
Compare


… the two way part dep calculated, just trying to integrated it into the plots.
Pull Request Description
(replace this text with your description)
After creating the pull request: in order to pass the release_notes_updated check you will need to update the "Future Release" section of
docs/source/release_notes.rstto include this pull request by adding :pr:123.