Reader small image

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

Product typeBook
Published inMay 2019
Reading LevelIntermediate
PublisherPackt
ISBN-139781838550356
Edition1st Edition
Languages
Right arrow
Authors (2):
Michael Bironneau
Michael Bironneau
author image
Michael Bironneau

Michael Bironneau is an award-winning mathematician and experienced software engineer. He holds a PhD in mathematics from Loughborough University and has worked in several data science and software development roles. He is currently technical director of the energy AI technology company, Open Energi.
Read more about Michael Bironneau

Toby Coleman
Toby Coleman
author image
Toby Coleman

Toby Coleman is an experienced data science and machine learning practitioner. Following degrees from Cambridge University and Imperial College London, he has worked on the application of data science techniques in the banking and energy sectors. Recently, he held the position of innovation director at cleantech SME Open Energi, and currently provides machine learning consultancy to start-up businesses.
Read more about Toby Coleman

View More author details
Right arrow

Why write ML applications in Go?

There are libraries for other languages, especially Python, that are more complete than Go ML libraries and have benefited from years, if not decades, of research from the worlds brightest brains. Some Go programmers make the transition to Go in search of better performance, but because ML libraries are typically written in C and exposed to Python through their bindings, they do not suffer the same performance problems as interpreted Python programs. Deep learning frameworks such as TensorFlow and Caffe have very limited, if any, bindings to Go. Even with these issues in mind, Go is still an excellent, if not the best, language to develop an application containing ML components.

The advantages of Go

For researchers attempting to improve state-of-the-art algorithms in an academic environment, Go may not be the best choice. However, for a start-up with a product concept and fast-dwindling cash reserves, completing the development of the product in a maintainable and reliable way within a short space of time is essential, and this is where the Go language shines.

Go (or Golang) originates from Google, where its design began in 2007[10]. Its stated objectives were to create an efficient, compiled programming language that feels lightweight and pleasant[11]. Go benefits from a number of features that are designed to boost productivity and reliability of production applications:

  • Easy to learn and on-board new developers
  • Fast build time
  • Good performance at run-time
  • Great concurrency support
  • Excellent standard library
  • Type safety
  • Easy-to-read, standardized code with gofmt
  • Forced error handling to minimize unforeseen exceptions
  • Explicit, clear dependency management
  • Easy to adapt architecture as projects grow

All these reasons make Go an excellent language for building production systems, particularly web applications. The 2018 Stack Overflow developer survey reveals that while only 7% of professional developers use Go as their main language, it is 5th on the most loved list and also commands very high salaries relative to other languages, recognizing the business value that Go programmers add[12].

Go's mature ecosystem

Some of the worlds most successful technology companies use Go as the main language of their production systems and actively contribute to its development, such as Cloudflare[13], Google, Uber[14], Dailymotion[15], and Medium[16]. This means that there is now an extensive ecosystem of tools and libraries to help a development team create a reliable, maintainable application in Go. Even Docker, the worlds leading container technology, is written in Go.

At the time of writing, there are 1,774 repositories on GitHub written in the Go language that have over 500 stars, traditionally considered a good proxy measure of quality and support. In comparison, Python has 3,811 and Java 3,943. Considering that Go is several decades younger and allows for faster production-ready development, the relatively large number of well-supported repositories written in the Go language constitutes a glowing endorsement from the open source community.

Go has a number of stable and well-supported open source ML libraries. The most popular Go ML library by number of GitHub stars and contributors is GoLearn[17]. It is also the most recently updated. Other Go ML libraries include GoML and Gorgonia, a deep learning library whose API resembles TensorFlow.

Transfer knowledge and models created in other languages

Data scientists will often explore different methods to tackle an ML problem in a different language, such as Python, and produce a model that can solve the problem outside any application. The plumbing, such as getting data in and out of the model, serving this to a customer, persisting outputs or inputs, logging errors, or monitoring latencies, is not part of this deliverable and is outside the normal scope of work for a data scientist. As a result, taking the model from concept to a Go production application requires a polyglot approach such as a microservice.

Most of the code examples in this book use ML algorithms or bindings to libraries such as OpenCV that are also available in languages such as Python. This will enable you to take a data scientists prototype Python code and turn it into a production Go application in no time.

However, there are Go bindings for deep learning frameworks such as TensorFlow and Caffe. Moreover, for more basic algorithms such as decision trees, the same algorithms have also been implemented in Go libraries and will produce the same results if they are configured in the same way. Together, these considerations imply that it is possible to fully integrate data science products into a Go application without sacrificing accuracy, speed, or forcing a data scientist to work with tools they are uncomfortable with.

Previous PageNext Page
You have been reading a chapter from
Machine Learning with Go Quick Start Guide
Published in: May 2019Publisher: PacktISBN-13: 9781838550356
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.
undefined
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 $15.99/month. Cancel anytime

Authors (2)

author image
Michael Bironneau

Michael Bironneau is an award-winning mathematician and experienced software engineer. He holds a PhD in mathematics from Loughborough University and has worked in several data science and software development roles. He is currently technical director of the energy AI technology company, Open Energi.
Read more about Michael Bironneau

author image
Toby Coleman

Toby Coleman is an experienced data science and machine learning practitioner. Following degrees from Cambridge University and Imperial College London, he has worked on the application of data science techniques in the banking and energy sectors. Recently, he held the position of innovation director at cleantech SME Open Energi, and currently provides machine learning consultancy to start-up businesses.
Read more about Toby Coleman