Deploying ML model on Heroku using Heroku CLI — Part 2

Gaurav Patil
4 min readJul 10, 2022

--

Photo by Clément Hélardot on Unsplash

Missed previous tutorial — Click here.

Step 7 :

Install heroku CLI(Command Line Interface).

Check version of heroku by running following command in VS code terminal just to make sure if heroku CLI has been installed.

heroku --version

If heroku CLI(Command Line Interface) is installed in your machine, it will show it’s version like (version may vary) :

Step 8 :

Run following command in VS code terminal :

heroku login

You will automatically be directed to your browser, just hit log in there.

Step 9 :

Now run following git command in VS code terminal :

git init

This will create the empty git repository (collection of all the code files) in your machine where we will add all the files and this repository will be shared with heroku so that heroku can run our code on it’s platform.

Step 10 :

Now run following command in VS code terminal :

( `song-popularity-model` is app name, it has to be accurate otherwise it will throw error.)

heroku git:remote -a song-popularity-model 

Now that we have created an empty repository, we need to connect it with heroku remote server where our app `song-popularity-model` is created.

Step 11 :

Check in terminal :

git status

Red color indicates that files in that folder have not been added in the repository.

Step 12 :

To add all the files in a repository, run following command :

git add .

Remember dot in the end which says all the files in the folder to be added in the repository.

Now again we can check if those files are added in the repository or not by checking git status

Green color indicates files are added from the folder to the repository.

Step 13 :

git commit -am “first commit message”

In Git, a commit is a snapshot of your repo at a specific point in time. It also allows us to write message to let others know what changes one has made in the repository.

Step 14 :

git push heroku master

Using this command we push entire git repository to the heroku server.

Step 15 :

Click on the link thus obtained in the terminal.

You can see the webpage as shown below. Fill some random values for the features and hit submit button.

You can see the prediction by Machine Learning model below :

Congratulations !!!

You have deployed the model on Heroku successfully !!!

--

--

Gaurav Patil
Gaurav Patil

Written by Gaurav Patil

Machine Learning Engineer drawing insights from mathematics.

No responses yet