Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Machine Learning with Go Quick Start Guide

You're reading from   Machine Learning with Go Quick Start Guide Hands-on techniques for building supervised and unsupervised machine learning workflows

Arrow left icon
Product type Paperback
Published in May 2019
Publisher Packt
ISBN-13 9781838550356
Length 168 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Michael Bironneau Michael Bironneau
Author Profile Icon Michael Bironneau
Michael Bironneau
Toby Coleman Toby Coleman
Author Profile Icon Toby Coleman
Toby Coleman
Arrow right icon
View More author details
Toc

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 $19.99/month. Cancel anytime
Banner background image