Use Neptune API to Iog your first experiment¶
This guide will show you how to:
Connect Neptune to your script and create the first experiment
Log metrics to Neptune and explore them in the UI
By the end of it, you will run your first experiment and see it in Neptune!
Before you start¶
Make sure you meet the following prerequisites before starting:
Have Python 3.x installed
You can run this how-to on Google Colab with zero setup.
Just click on the
Open in Colab button on the top of the page.
Step 1 - Install neptune-client¶
Go to the command line of your operating system and run the installation command:
pip install neptune-client
If you are using R or any other language go read this.
Step 2 - Create a quickstart.py¶
Create a python script called quickstart.py and copy the code below to it:
# Connect your script to Neptune import neptune neptune.init(project_qualified_name='shared/onboarding', api_token='ANONYMOUS', ) # Create experiment neptune.create_experiment() # Log metrics to experiment from time import sleep neptune.log_metric('single_metric', 0.62) for i in range(100): sleep(0.2) # to see logging live neptune.log_metric('random_training_metric', i * 0.6) neptune.log_metric('other_random_training_metric', i * 0.4)
Instead of logging data to the public project ‘shared/onboarding’ as an anonymous user ‘neptuner’ you can log it to your own project.
Get your Neptune API token
Pass the token to
Pass your username to the
project_qualified_nameargument of the
/sandboxat the end, the
sandboxproject that was automatically created for you.
neptune.init(project_qualified_name='funky_steve/sandbox', api_token='eyJhcGlfYW908fsdf23f940jiri0bn3085gh03riv03irn', )
Step 3 - Run your script and explore results¶
Now that you have your script ready you can run it and see results in Neptune.
Run your script from the terminal or Jupyter notebook
Click on the link in the terminal or notebook or go directly to the Neptune app.
See metrics you logged in Logs, Charts, and hardware consumption in the Monitoring sections of the Neptune UI:
You’ve learned how to:
Connect Neptune to your python script and create an experiment
Log metrics to Neptune
Explore your metrics in
See hardware consumption during the experiment run
Now that you know how to create experiments and log metrics you can learn: