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

feat: adds residual vs fitted plotting function #100

Merged
merged 5 commits into from
Nov 20, 2020
Merged

Conversation

byooooo
Copy link
Collaborator

@byooooo byooooo commented Nov 20, 2020

Types of changes

addresses #72

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation

Actions (for code changes)

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov-io
Copy link

codecov-io commented Nov 20, 2020

Codecov Report

Merging #100 (1804eaa) into master (c8be9f0) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #100   +/-   ##
=======================================
  Coverage   96.69%   96.69%           
=======================================
  Files          12       12           
  Lines         787      787           
=======================================
  Hits          761      761           
  Misses         26       26           
Flag Coverage Δ
unittests 96.69% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c8be9f0...1804eaa. Read the comment docs.

@kjappelbaum kjappelbaum self-requested a review November 20, 2020 06:55
Copy link
Owner

@kjappelbaum kjappelbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @byooooo .
The only thing I'd recommend to change is that we indent the "Defaults to" in the docstrings.

Defaults to "objective [index]".
figsize (tuple, optional): Figure size for each individual residual
vs fitted objective plot.
Defaults to (6.0, 4.0).
Copy link
Owner

@kjappelbaum kjappelbaum Nov 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel there should be an indent for "Defaults to"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just fixed

labels (Union[List[str], None], optional): [description]. Defaults to None.
figsize (tuple, optional): [description]. Defaults to (8.0, 6.0).
labels (Union[List[str], None], optional): Labels for each objective.
Defaults to "objective [index]".
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably also needs an indent here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just fixed


Returns:
fig
"""

num_targets = y.shape[1]
fig, ax = plt.subplots( # pylint:disable=invalid-name
num_targets, num_targets, figsize=figsize
num_targets, num_targets, figsize=figsize, tight_layout=True
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something we do not have to fix here but In the function above the figsize argument behaves differently

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea i thought it made more sense to set the figsize individually for that function and have it auto-adjust by multiplying it based on the number of objectives. probably not good if we want to be consistent with the other function. it didn't make sense to do that for this function since the figure size for each individual subplot will be very small

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, we can maybe describe these behaviors in the docstrings

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah it is already there, sorry!

@@ -166,6 +166,63 @@ def plot_histogram(y: np.ndarray, palinstance, ax): # pylint:disable=invalid-na
)


def plot_res( # pylint:disable=invalid-name
y: np.array,
palinstance,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also not important for this PR, but we might want to do this in a future enhancement: We should also annotate the other types in the functions

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good

@kjappelbaum
Copy link
Owner

Probably we can add in another PR simple tests for the plotting functions. This is, we won't check if the plots look correct but at least make sure that no error is thrown if we use the functions (might be relevant if we change some of the PALBase API)

@kjappelbaum kjappelbaum linked an issue Nov 20, 2020 that may be closed by this pull request
@byooooo
Copy link
Collaborator Author

byooooo commented Nov 20, 2020

yea actually i was wondering where the unit tests were for this. If you want, i can add it as well

@kjappelbaum
Copy link
Owner

yea actually i was wondering where the unit tests were for this. If you want, i can add it as well

i didn't write test as i wasn't sure what is the best way to test plotting functions. But we might add some that just check that a non-empty figure is returned with correct number of subplots ... but we I can make a separate PR for that later today

@kjappelbaum kjappelbaum merged commit e3c17fe into master Nov 20, 2020
@kjappelbaum kjappelbaum deleted the plot_residuals branch November 20, 2020 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add residuals plot
3 participants