Repository navigation
Add new convenience function get_flow_id #792
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| """ | ||
| ================== | ||
| Obtaining Flow IDs | ||
| ================== | ||
|
|
||
| This tutorial discusses different ways to obtain the ID of a flow in order to perform further | ||
| analysis. | ||
| """ | ||
|
|
||
| #################################################################################################### | ||
| import sklearn.tree | ||
|
|
||
| import openml | ||
|
|
||
| clf = sklearn.tree.DecisionTreeClassifier() | ||
|
|
||
| #################################################################################################### | ||
| # 1. Obtaining a flow given a classifier | ||
| # ====================================== | ||
| # | ||
|
|
||
| flow = openml.extensions.get_extension_by_model(clf).model_to_flow(clf).publish() | ||
| flow_id = flow.flow_id | ||
| print(flow_id) | ||
|
|
||
| #################################################################################################### | ||
| # This piece of code is rather involved. First, it retrieves an | ||
| # :class:`~openml.extensions.Extension` which is registered and can handle the given model, | ||
| # in our case it is :class:`openml.extensions.sklearn.SklearnExtension`. Second, the extension | ||
| # converts the classifier into an instance of :class:`openml.flow.OpenMLFlow`. Third and finally, | ||
| # the publish method checks whether the current flow is already present on OpenML. If not, | ||
| # it uploads the flow, otherwise, it updates the current instance with all information computed | ||
| # by the server (which is obviously also done when uploading/publishing a flow). | ||
| # | ||
| # To simplify the usage we have created a helper function which automates all these steps: | ||
|
|
||
| flow_id = openml.flows.get_flow_id(model=clf) | ||
| print(flow_id) | ||
|
|
||
| #################################################################################################### | ||
| # 2. Obtaining a flow given its name | ||
| # ================================== | ||
| # The schema of a flow is given in XSD (`here | ||
| # <https://github.com/openml/OpenML/blob/master/openml_OS/views/pages/api_new/v1/xsd/openml.implementation.upload.xsd>`_). # noqa E501 | ||
| # Only two fields are required, a unique name, and an external version. While it should be pretty | ||
| # obvious why we need a name, the need for the additional external version information might not | ||
| # be immediately clear. However, this information is very important as it allows to have multiple | ||
| # flows with the same name for different versions of a software. This might be necessary if an | ||
| # algorithm or implementation introduces, renames or drop hyperparameters over time. | ||
|
|
||
| print(flow.name, flow.external_version) | ||
|
|
||
| #################################################################################################### | ||
| # The name and external version are automatically added to a flow when constructing it from a | ||
| # model. We can then use them to retrieve the flow id as follows: | ||
|
|
||
| flow_id = openml.flows.flow_exists(name=flow.name, external_version=flow.external_version) | ||
| print(flow_id) | ||
|
|
||
| #################################################################################################### | ||
| # We can also retrieve all flows for a given name: | ||
| flow_ids = openml.flows.get_flow_id(name=flow.name) | ||
| print(flow_ids) | ||
|
|
||
| #################################################################################################### | ||
| # This also work with the actual model (generalizing the first part of this example): | ||
| flow_ids = openml.flows.get_flow_id(model=clf, exact_version=False) | ||
| print(flow_ids) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| from .flow import OpenMLFlow | ||
|
|
||
| from .functions import get_flow, list_flows, flow_exists, assert_flows_equal | ||
| from .functions import get_flow, list_flows, flow_exists, get_flow_id, assert_flows_equal | ||
|
|
||
| __all__ = [ | ||
| 'OpenMLFlow', | ||
| 'get_flow', | ||
| 'list_flows', | ||
| 'get_flow_id', | ||
| 'flow_exists', | ||
| 'assert_flows_equal', | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.