Edit on GitHub

exp apply

Put the results from an experiment in the workspace.

Synopsis

usage: dvc exp apply [-h] [-q | -v] experiment

positional arguments:
  experiment     Experiment to be applied

Description

Restores the results of a given experiment (name or hash are accepted, see dvc exp run for details) into the workspace. This means changing the appropriate metafiles, parameter files, metrics, plots, and corresponding DVC-tracked data.

This is similar to dvc checkout, but for dvc experiments.

This is typically used after using dvc exp show or dvc exp diff to find the best experiment, and before committing to Git in order to make it persistent.

Note that this command will fail if the target experiment was not derived from the current Git commit.

Options

  • -h, --help - shows the help message and exit.
  • -q, --quiet - do not write anything to standard output. Exit with 0 if no problems arise, otherwise 1.
  • -v, --verbose - displays detailed tracing information from executing the dvc pull command.

Example: Make an experiment persistent

This example is based on our Get Started, where you can find the actual source code.

Let's say we have run 3 experiments in our project:

$ dvc exp show --include-params=featurize
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Experiment            โ”ƒ Created      โ”ƒ     auc โ”ƒ featurize.max_features โ”ƒ featurize.ngrams โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ workspace             โ”‚ -            โ”‚ 0.61314 โ”‚ 1500                   โ”‚ 2                โ”‚
โ”‚ 10-bigrams-experiment โ”‚ Jun 20, 2020 โ”‚ 0.61314 โ”‚ 1500                   โ”‚ 2                โ”‚
โ”‚ โ”œโ”€โ”€ exp-e6c97         โ”‚ Oct 21, 2020 โ”‚ 0.69830 โ”‚ 2000                   โ”‚ 2                โ”‚
โ”‚ โ”œโ”€โ”€ exp-1dad0         โ”‚ Oct 09, 2020 โ”‚ 0.57756 โ”‚ 1200                   โ”‚ 2                โ”‚
โ”‚ โ””โ”€โ”€ exp-1df77         โ”‚ Oct 09, 2020 โ”‚ 0.51676 โ”‚ 500                    โ”‚ 2                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Since exp-e6c97 has the best auc, we may want to commit it into our project (this is what we call to "make it persistent"):

$ dvc exp apply exp-e6c97
Changes for experiment 'exp-e6c97' have been applied...

We can inspect what changed in the workspace with Git,

$ git status
On branch master
Changes not staged for commit:
        modified:   dvc.lock
        modified:   params.yaml
        modified:   scores.json
$ git diff params.yaml
@@ -3,7 +3,7 @@ prepare:
 featurize:
-  max_features: 1500
+  max_features: 2000
   ngrams: 2

and with DVC:

$ dvc status
Data and pipelines are up to date.
$ dvc diff
Modified:
    data/features/
    data/features/test.pkl
    data/features/train.pkl
    model.pkl
files summary: 0 added, 0 deleted, 3 modified, 0 not in cache

To finish making this experiment persistent, we commit the changes to the repo:

$ git add .
$ git commit -m "persist exp-e6c97"

We can now see that the experiment is the new tip of our master branch:

$ dvc exp show --include-params=featurize
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Experiment โ”ƒ Created  โ”ƒ     auc โ”ƒ featurize.max_features โ”ƒ featurize.ngrams โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ workspace  โ”‚ -        โ”‚ 0.69830 โ”‚ 2000                   โ”‚ 2                โ”‚
โ”‚ master     โ”‚ 04:31 PM โ”‚ 0.69830 โ”‚ 2000                   โ”‚ 2                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Note that all the other experiments are based on a previous commit, so dvc exp show won't display them by default (but they're still saved).

Content

๐Ÿ› Found an issue? Let us know! Or fix it:

Edit on GitHub

โ“ Have a question? Join our chat, we will help you:

Discord Chat