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

CrossValidationPlot object #2252

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mgrange1998
Copy link
Contributor

Summary:
CrossValidation is one of the most frequent plots used accross Ax. This change imports it to the ax.analysis module, simplifies its logic and provides a easy to use access point, which takes in the common experiment and model data types.

  • "get_df()" exports a basic dataframe with the data used to generate the
    plot
  • "get_fig()" exports the classic cross validation plots, with the same functionality as used today.

New Usage

from ax.analysis.cross_validation_plot import CrossValidationPlot

cv_plot = CrossValidationPlot(experiment=scheduler.experiment, model=model)
plot = cv_plot.get_fig()

Old Usage

from ax.plot.diagnostic import interact_cross_validation_plotly
from ax.modelbridge.cross_validation import cross_validate

cv_results = cross_validate(model=model)
plot = interact_cross_validation_plotly(cv_results)

Differential Revision: D54432757

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D54432757

@facebook-github-bot facebook-github-bot added CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported labels Mar 6, 2024
mgrange1998 added a commit to mgrange1998/Ax that referenced this pull request Mar 6, 2024
Summary:

CrossValidation is one of the most frequent plots used accross Ax. This change imports it to the ax.analysis module, simplifies its logic and provides a easy to use access point, which takes in the common `experiment` and `model` data types.

- "get_df()" exports a basic dataframe with the data used to generate the
plot
- "get_fig()" exports the classic cross validation plots, with the same functionality as used today.


## New Usage
```
from ax.analysis.cross_validation_plot import CrossValidationPlot

cv_plot = CrossValidationPlot(experiment=scheduler.experiment, model=model)
plot = cv_plot.get_fig()
```


## Old Usage
```
from ax.plot.diagnostic import interact_cross_validation_plotly
from ax.modelbridge.cross_validation import cross_validate

cv_results = cross_validate(model=model)
plot = interact_cross_validation_plotly(cv_results)
```

Differential Revision: D54432757
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D54432757

mgrange1998 added a commit to mgrange1998/Ax that referenced this pull request Mar 6, 2024
Summary:

CrossValidation is one of the most frequent plots used accross Ax. This change imports it to the ax.analysis module, simplifies its logic and provides a easy to use access point, which takes in the common `experiment` and `model` data types.

- "get_df()" exports a basic dataframe with the data used to generate the
plot
- "get_fig()" exports the classic cross validation plots, with the same functionality as used today.


## New Usage
```
from ax.analysis.cross_validation_plot import CrossValidationPlot

cv_plot = CrossValidationPlot(experiment=scheduler.experiment, model=model)
plot = cv_plot.get_fig()
```


## Old Usage
```
from ax.plot.diagnostic import interact_cross_validation_plotly
from ax.modelbridge.cross_validation import cross_validate

cv_results = cross_validate(model=model)
plot = interact_cross_validation_plotly(cv_results)
```

Differential Revision: D54432757
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D54432757

@codecov-commenter
Copy link

codecov-commenter commented Mar 6, 2024

Codecov Report

Attention: Patch coverage is 96.30996% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 94.87%. Comparing base (e8018a2) to head (dd06d1b).

❗ Current head dd06d1b differs from pull request most recent head 3803c9a. Consider uploading reports for the commit 3803c9a to get more accurate results

Files Patch % Lines
ax/analysis/helpers/color_helpers.py 66.66% 3 Missing ⚠️
ax/analysis/helpers/plot_helpers.py 86.36% 3 Missing ⚠️
ax/analysis/helpers/scatter_helpers.py 96.42% 2 Missing ⚠️
ax/analysis/cross_validation_plot.py 97.22% 1 Missing ⚠️
ax/analysis/helpers/cross_validation_helpers.py 98.61% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #2252    +/-   ##
========================================
  Coverage   94.86%   94.87%            
========================================
  Files         467      476     +9     
  Lines       46455    46726   +271     
========================================
+ Hits        44068    44329   +261     
- Misses       2387     2397    +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

mgrange1998 added a commit to mgrange1998/Ax that referenced this pull request Mar 6, 2024
Summary:

CrossValidation is one of the most frequent plots used accross Ax. This change imports it to the ax.analysis module, simplifies its logic and provides a easy to use access point, which takes in the common `experiment` and `model` data types.

- "get_df()" exports a basic dataframe with the data used to generate the
plot
- "get_fig()" exports the classic cross validation plots, with the same functionality as used today.


## New Usage
```
from ax.analysis.cross_validation_plot import CrossValidationPlot

cv_plot = CrossValidationPlot(experiment=scheduler.experiment, model=model)
plot = cv_plot.get_fig()
```


## Old Usage
```
from ax.plot.diagnostic import interact_cross_validation_plotly
from ax.modelbridge.cross_validation import cross_validate

cv_results = cross_validate(model=model)
plot = interact_cross_validation_plotly(cv_results)
```

Differential Revision: D54432757
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D54432757

Summary:

To prepare of creating the "CrossValidationPlot" module, this change imports the dependent code from "ax.plots". 
It also cleans up the original code by breaking it apart into different helper files, and trimming out methods which are not used to create this plot. Some new unit tests are being added as well.



## In new ax.analysis CrossValidationPlot

The function of the code is broken out neatly by function:

Constants, string operations, basic formatting helpers
- ax/analysis/helpers/constants.py - 21 lines
- ax/analysis/helpers/color_helpers.py - 33 lines
- ax/analysis/helpers/plot_helpers.py - 76 lines
- ax/analysis/helpers/layout_helpers.py - 96 lines

Plot Logic
- ax/analysis/helpers/scatter_helpers.py - 180 lines
- ax/analysis/helpers/cross_validation_helpers.py - 291 lines

CrossValidationPlot object (see next diff)
- ax/analysis/cross_validation_plot.py - 109 lines

806 total lines


## Required files from ax.plot needed to create cross validation plot
- ax/plot/scatter.py - 1722 lines
- ax/plot/diagnostic.py - 691 lines
- ax/plot/helper - 995 lines
- ax/plot/base.py - 94 lines
- ax/plot/color.py - 120 lines

3622 total lines of code across the files which have the logic for cross validation plots

This is a 77.75% decrease in lines of code. This will make understanding and using this plot easier for users and developers.

Differential Revision: D54495372
Summary:

CrossValidation is one of the most frequent plots used accross Ax. This change imports it to the ax.analysis module, simplifies its logic and provides a easy to use access point, which takes in the common `experiment` and `model` data types.

- "get_df()" exports a basic dataframe with the data used to generate the
plot
- "get_fig()" exports the classic cross validation plots, with the same functionality as used today.


## New Usage
```
from ax.analysis.cross_validation_plot import CrossValidationPlot

cv_plot = CrossValidationPlot(experiment=scheduler.experiment, model=model)
plot = cv_plot.get_fig()
```


## Old Usage
```
from ax.plot.diagnostic import interact_cross_validation_plotly
from ax.modelbridge.cross_validation import cross_validate

cv_results = cross_validate(model=model)
plot = interact_cross_validation_plotly(cv_results)
```

Differential Revision: D54432757
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D54432757

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants