Search icon CANCEL
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Machine Learning with Go Quick Start Guide

You're reading from  Machine Learning with Go Quick Start Guide

Product type Book
Published in May 2019
Publisher Packt
ISBN-13 9781838550356
Pages 168 pages
Edition 1st Edition
Languages
Authors (2):
Michael Bironneau Michael Bironneau
Profile icon Michael Bironneau
Toby Coleman Toby Coleman
Profile icon Toby Coleman
View More author details

Example – invoking a Python model using os/exec

To get started with polyglot ML applications, we will revisit the logistic regression example from Chapter 3, Supervised Learning. We will assume that, instead of Go, the model was written in Python and that we wish to invoke it from our Go application. To do this, we will use command-line arguments to pass inputs to the model and read the model's prediction from standard output (STDOUT).

To exchange data between Python and Go, we will use strings formatted using JavaScript Object Notation (JSON). This choice is arbitrary of course[6], and we could have chosen any one of the other formats for which the Go and Python standard libraries have support, such as XML, or invented our own. JSON has the advantage that it takes very little effort to use in both languages.

The process we will follow to communicate with the Python...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime}