Training a Model from the CLI

Training a Model from the CLI

In this tutorial, we'll cover how to train a simple model from the Gradient CLI.

In this tutorial we’ll cover how to train a model from the command line interface. This tutorial assumes that you’ve already installed the Gradient CLI, obtained an API key, created a Project, and launched a Jupyter notebook; if not, then feel free to check out those tutorials before starting. 

Models are trained using Gradient Experiments. We’ll submit our dataset and Python code to the Experiment in order to train the model.

For this tutorial we’ll use a simple dataset which includes a person’s years of job experience, and their salary. We also have a file named “train dot py” which contains the code for generating the model by applying linear regression to the dataset. We’ll access these files from a GitHub repository. 

Let’s start by going to our Project on the Gradient console and copying our Project ID. Then, from the CLI, type 

  • gradient experiments run singlenode
  • the name of the task you’re running, which in our case is “train”
  • the project ID that we copied before
  • the container that we want to use
  • the machine we want to run this on
  • the command to run the file, as well as the input data and output directory, which is where the trained pickled model will be stored
  • and finally, our workspace, which in this case is our GitHub repository with the salary data and the train file.  

Now we’ll run the command, and we can see that our experiment has been created and is running. Our code outputs some useful metrics, and completes successfully. The experiment generated a Python pickle file of our trained model that was stored at the location we specified in the command, which was the “salary” directory under storage.

We can also check out past experiments from the Gradient console.

And that’s all there is to training a model from the Gradient CLI.

  • 00:04 In this tutorial we'll cover how to train a model from thecommand line interface
  • 00:13 This tutorial assumes that you've already installedthe gradient CL I obtained an API key, created a project and launched a Jupyter notebook. If not, then feel free to checkout those tutorials before starting
  • 00:26 Models are trained using gradient experiments. We'll submit our dataset and Python code to the experiment in order to train the model for this tutorial
  • 00:36 We'll use a simple data set which includes a person's years of job experience and their salary we also have a file named train dot py which contains the code for generating the model by applying linear regression to the dataset. We'll access these files from a GitHub repository
  • 00:53 Let's start by going to our project on the gradient console and copying our project ID then from the CLI type gradient experiments run singlenode the name of the task you're running which in our case is train the project ID that we copied before, the container that we want to use, the Machine we want to run this on the command to run the file and finally our workspace which in this case is our github repository with the salary data and the Train fil
  • 01:24 Now we'll run the command and we can see that our experiment has been created and is running our code outputs some useful metrics and completes successfully
  • 01:33 We can also check out past experiments from the gradient console and that's all there is to training a model from the gradient CLI

Key takeaways

  • Train a linear regression model hosted on GitHub
  • Use the CLI to launch experiments
  • Monitor the training accuracy in the web interface
  • Save a model after training is complete

Similar videos