> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wandb.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# sweep で最良の run の artifact を検索するにはどうすればよいですか？

sweep で最も高い性能を示した run から artifact を取得するには、次のコードを使用します。このコードは、sweep の Runs を検証 accuracy で並べ替え、最上位の run を選択して、その run がログした各 artifact をダウンロードします。

```python theme={null}
api = wandb.Api()
sweep = api.sweep("entity/project/sweep_id")
runs = sorted(sweep.runs, key=lambda run: run.summary.get("val_acc", 0), reverse=True)
best_run = runs[0]
for artifact in best_run.logged_artifacts():
    artifact_path = artifact.download()
    print(artifact_path)
```

各 artifact はローカルパスにダウンロードされ、そのパスがスクリプトによってコンソールに出力されます。

***

<Badge stroke shape="pill" color="orange" size="md">[Artifacts](/ja/support/models/tags/artifacts)</Badge>
