Monday, November 16, 2020

Machine Learning Introduction

When I start a new subject, I usually begin at a high level before getting into the nitty gritty of the subject. I know as Software Engineers, we are often eager to dive under the hood and get straight to coding but we'll start with a bird's eye view.  Let's begin with defining what Machine Learning (ML) is. First, let's clear up the confusion surrounding the interchangeable use of the terms Artificial Intelligence and Machine Learning, the drivers behind the rise of ML implementation, and the types of Machine Learning

The terms Artificial Intelligence (AI) and Machine Learning are thrown around as if they were the same thing. There really isn't a formal definition of AI or at least a consensus on one. Most data scientist, ML engineers, and academics will agree that ML is a subset of AI. Thus, all ML is AI but not all AI is ML. The big thing Machine Learning algorithms lack is Artificial General Intelligence (AGI). AGI is the idea that if a computer could read a bunch of high school textbooks and, without knowing anything about tests or essay questions, it could apply that data to pass an SAT. There are several theoretical tests like the Turing Test (If you're not familiar with Alan Turing, please stop everything you're doing and read about this great mind). Turing posed a thought experiment where a computer and person were each behind a curtain. If someone conversing with them is unable to discern between the computer and the person, then that computer has attained AIG. Steve Wozniak said if a machine could go into an average home and figure out how to make a cup of coffee (find the machine and the coffee, add water, locate a cup, and work the coffee machine) it could be defined as AIG. From a human point of view, these tasks aren't particularly difficult; from a software engineering perspective, these tasks are impossibly complex. Currently, there are no machines that are capable of passing these, or any similar, tests. Now that we know the difference between AI and ML, lets dive deeper into Machine Learning.

Machine Learning is a set of learning algorithms that can be further divided into three subsets - Reinforcement Learning, Supervised, and Unsupervised. 

Reinforcement Learning takes signals as input, chooses an action based on those signals, and then tries to improve the choice of action based on the reward or punishment that results from that action. Imagine a rat running a maze; a signal is seeing a place to go right or left. Go right, get a treat, go left, get a shock. The next time the mouse is presented with a right/left decision, it will use prior experience to go right. OpenAI has some great resources on Reinforcement training that even include video games upon which your model can be trained. Reinforcement training was used by Google to create their AlphaGO model that beat a top GO master. There is a great article in Nature that documents the development of this game paying AI.

Supervised Learning is probably the most common of all the ML types. It involves the use of labeled data. For example, we want to predict the price for which a house will sell. Suppose we have a spreadsheet that contains housing price data and it contains columns named: "Total Square Feet," "Number of bedrooms, " "Number of bathrooms," and "Selling Price." The first three columns are referred to as Features and the last as the Label. Providing that the spreadsheet is sufficiently large, we can use it to train one of many ML algorithms to predict the selling price for a house not on the spreadsheet. The Supervised name comes from the idea that we have a large set of examples in which we know the outcome that we are trying to predict. We use that labeled data to train an algorithm. There are so many different applications of Supervised Learning that it has become the most used subset of ML. Our labeled data could be a collection of pictures of cats and dogs. In reality, the pictures are m X n matrices of pixel data and the feature set. The label would be the corresponding Cat or Dog identifier. Supervised Learning will be the main focus of upcoming posts.

Unsupervised Learning is used on data that has features but lacks labels. Perhaps we have a bunch of data about customers who have purchased something from our website. Normal demographic data (location, age, income bracket) are so varied among our customers that we are having a tough time marketing to them. We could use a Clustering algorithm to identify different groups that comprise our customer base. Unsupervised learning is also a rapidly expanding area of not only academic research, but also real world ML implementations.
 
Hopefully, this clears up any confusion surrounding the difference between Artificial Intelligence and Machine Learning as well as the types of Machine Learning that are currently being researched and implemented.


Saturday, May 23, 2020

Deep Learning Monkey Introduction

Welcome to my blog, I'm a Software Engineer who has developed a passion for Machine Learning. This field is exciting and has been capturing the imagination of developers. I began with spending a lot of time completing various courseware classes and in a later posting, I will give my thought on the specific ones of which I've tried.  In addition to online learning, I continue to spend copious amounts of time on blogs and there are countless ones out there.  Which begs the question - Why do we possibly need another one?  While the bulk of online resources and books that I have read on the subject are great and very informative, they seem devoid of the issues that Software Engineers deal with on a daily basis.  I'd like this blog to be a study in Machine Learning from the perspective of a Software Engineer.  I think this has value to the Machine Learning community on the whole.  Software Engineers tend to think about problems before solutions, they think about and write clean code that is well organized and maintainable and lastly they think about how the software will be deployed, configured, and scaled. 

I think it's fair to say that most people have been deluged by reporting about AI or Machine Learning (I'll discuss the difference in the following post). Paradoxically, the sheer volume of media on the subject has probably generated more confusion about the subject.  It reminds of the time I was working for a DoD contractor making frameworks for courseware.  The Courseware Manager called me into his office and asked earnestly "Do we need the Cloud?" It was obvious that he really didn't know what the "Cloud" was but had heard the term from somewhere.  I think there are a lot of medium and small business in the same place as my old manager.  To his credit, he let me explain the term as it applied or didn't apply to our projects and we moved on quickly.  I wonder if the medium/small businesses have a similar approach to that of my manager or how many spend a lot of resources on projects that will have little return.  This is where a Software Engineer's approach really comes in handy.  Typically, SEs are presented with or identify a problem and then they look for a technical solution.  While I have no illusions that Software Engineers don't make mistakes in offering up solutions but I do think the approach is correct and I think most instructive material doesn't emphasize this enough.  So I'll spend more than a few postings focusing on why and not so much as the how.

Many of the online resources and some books include code examples that aren't very well structured.  I think this is mainly due to the context in which the code examples are supplied.  The examples are generated with the aim of teaching some aspect of Machine Learning and not application architecture.  It does lend itself to the mindset that all ML is done in PyCharm with scripts that include little or no classes, methods, or unit tests and riddled with literals.  I'd like to explore how we can implement Machine Learning in well structured code using industry best practices.

Lastly, I see a shocking lack of subject material in the Machine Learning community that deals with much of what comprises Software Engineers daily tasks.  I feel like so much of the material is being generated by people who are not currently working as developers.  Machine Learning as functional code is pretty new.  Ten years ago, most of the work being done in Machine Learning was being carried out at elite Computer Science departments or companies with very large R&D budgets.  It has come a long way from there but outside of large companies, implementation can be fairly haphazard compared to their other software projects.  In addition, roles aren't well defined.  I've read descriptions of a Data Scientist job that really was nothing more than a Business Analyst.  I think there is a lot of confusion about what is Machine Learning and what is statistical inference.  Ultimately, most of this confusion arises from how new the implementation of Machine Learning.  What does seem clear is that there is very little material about ML as it pertains to Software Engineering best practices.  I want to explore how do deploy and maintain Machine Learning tools in Continuous Integration/Continuous Deployment environments.  I say tools because because I also include data pipelines in this.  How do we handle scalability for our projects. How can we verify very large data sets and not bring platforms with them.  I suspect there will be a lot more subjects that I currently discuss here. And I'm sure it's going to provide for lively discussion as well.

So, again welcome to my blog. There are so many great resources for Machine Learning and my intent is for this blog to join that community. I certainly don't wish to demean other blogs, books, videos, etc... I just think there is a definite need to look at Machine Learning through the lens of a Software Engineer. Your comments and feedback will always be welcome,

Thanks and Happy Learning,
Greg
 

Supervised Learning Introduction

In the last post, I discussed the distinction between Artificial Intelligence(AI) and Machine Learning (ML). I also wrote about the main cat...