Machine Learning for Beginners

Forsk Technologies
Forsk Coding School
20 min readFeb 20, 2019

We write this post for beginners who are new to the exciting world of machine learning. This post will give you an end to end understanding of this domain.

The content has been curated from multiple sources and presented in a lucid form to make a clear understanding of the machine learning domain.

Chapter 01
Let’s Understand Where Machine Learning is Used in The Real World

We would like to put it in such a way that a person with non-machine learning (ML) background will also understand. We will explain a few real-life applications people are using without knowing this is ML.

1. Have you ever shopped online? While checking for a product, did you notice it recommends product similar to what you are looking for? Or did you see “the person bought this product also bought this” combination of products? How are they doing this recommendation? This is machine learning.

2. Did you ever get a call from any bank or finance company asking you to take a loan or an insurance policy? Do they call everyone? No, they call only selected customers who they think will purchase their product. How do they select? This is target marketing and can be applied using Clustering. This is machine learning.

3. Do you go to a supermarket for groceries or something? Ever noticed chips are placed near cold drinks? Why? Whoever buys a cold drink will most likely buy chips. How did they get to know this relation? This is association rule mining (market basket analysis). This is machine learning.

4. Companies like Google, Microsoft are using machine learning for a long time in most of their products. Data analytics companies use machine-learning concepts daily. Machine learning is one of those fields, which is going to have a wide impact on our future.

5. There is one practical example of Quora. You like to read on topics like computer science, technology & psychology for example. Among lots of other topics, which you follow, these three are the topics for which you will open all the questions and answers for sure. Sometimes you will go on a particular topic or particular person’s profile and read a lot of stuff from there, you do it on a regular basis because you like it. Right? Meanwhile databases on Quora stores patterns for your search query and your browsing interests. Now, next time when you open Quora, you will get content based on those patterns. Meaning Quora will show you content from the topic or from the person that you like to read most i.e computer science, technology, and psychology. All of this has happened because of machine learning. Quora analyzed patterns based on your browsing history & made its machine (database) learn, what to show on your news feed. That is Machine Learning!

6. Google search- The Machine Learning algorithm goes through your previous search data to give you the best search results on Google. So, if you searched for an actor like Robert Downy Junior on Google, it will also take you to pages on Iron Man, or other movies he has worked on.

7. Stock Predictions- Machine learning algorithms are used to analyze old stock data and predict future values.

8. Machine learning is widely used in the field of robotics. Recently there was a robot named ‘Sophia’ introduced which could actually behave like humans.

Let’s understand the human philosophy behind machine learning:

Two tasks we do all the time, both consciously and subconsciously, is to categorize what we perceive through our senses (e.g. hot or cold paper cup, hot or cold ceramic mug) to predict the future based on our past experience and perform new actions where prediction and categorization often occur in tandem (e.g. we continue to increase the pressure holding a paper cup until we feel its just right and stop well before we crush it. If it was a ceramic mug it would be a quick grip — no concern of crushing). The action is driven by some form of reward (e.g. the taste of a drink).

We do both these tasks — categorization and prediction for

• the simple mundane operation of holding a cup
• and for conscious long term planning of our future based on the choices we have.

Animals including insects do the same two tasks all the time — a bee decides based on certain factors where and when to seek honey. A little bird prepares for winter by storing seeds in different places and remembers to eat them in sequence, oldest first, to avoid spoiling.

If we were to crudely visualize categorization and predictions, they look like two sides of the same coin as the figure below shows.

  • In the case of categorization, a line is drawn separating the data points — cats and dogs.
  • In the case of prediction, a line is drawn through the given data points and often used to estimate if it would continue to grow/fall as seen in the below image.

Categorization Task

  • While we don’t draw lines inside our brains separating cats and dogs (the placement of cats and dogs in the above picture was arbitrary and purely for illustrative purposes) we are doing something very similar.
  • Needless to say, the way we separate cats and dogs is much more complex than the red curve above.
  • We factor in so many features such a shape of a head, size of body, tail etc to categorize a cat/dog. There are cases where we might find it not so easy to separate a cat and a dog — for example if a dog is small and furry. So it is not always a “clear cut” categorization into dogs and cats.
  • As children, once we have categorized cats and dogs based on their features, we can categorize a cat or dog we have never seen before — the boundary, which is symbolically represented by the red curve above helps us place the dog or cat in the right category.

Prediction task

  • Similarly, if we were to guess where the curve (figure above on the right) is heading based on given data points, we would say it is most likely to grow despite it being a bumpy trajectory.
  • The curve is also a prediction for fitting a new dot that is within the range of the existing data points — that is, how close a new dot will be to the curve.
  • So the red dots in the figure above (right) are examples of both cases — dots within and beyond given data points — the curve attempts to predict both of them (with small errors in the case of some red dots).

In summary, these tasks, categorization, and prediction boil down to drawing curvy lines.

At its core, machine learning is not a difficult concept to grasp. In fact, the vast majority of machine learning algorithms are concerned with just one simple task: drawing lines. In particular, machine learning is all about drawing lines through data.

Chapter 02

Let’s Now Define What is Machine Learning

With a humble background in machine learning, I will define this term now!

“Machine Learning is a way of making a machine learn, very much similar to how humans learn.”

In a nutshell, Machine Learning uses mathematical algorithms to learn and analyze data to make predictions and/or take decisions in the future.

Understanding Machine Learning With Example?

How many of you have noticed that once you visit an e-commerce website such as Amazon and browse through certain products, you will immediately start seeing the same product all over your social media feed? Whether it is Facebook, Instagram, YouTube or even Twitter, such ads play a psychological trick on you and convince you to purchase that product.

If you look at it, a machine has convinced you to make a decision without any human being involved.

“Machine Learning along with Artificial Intelligence will shape almost all the industries in the upcoming decades.”

Watch the YouTube tutorial on Machine Learning here (courtesy Simplilearn):

What is Artificial Intelligence(AI)?

Now that you know what Machine Learning is about, let us talk a bit about Artificial Intelligence.

Artificial Intelligence is the super-set of Machine Learning. The following diagram will depict how Artificial Intelligence, Machine Learning, and Deep Learning are related.

More Examples

Machine Learning is present in every other activity we do in our day-to-day life. From your smart house ACs that change temperature as per your body heat and pulse, to your smartphone which personalizes your newsfeed based on your interests to the Uber you booked to go to work, Machine Learning has completely encompassed our lives.

How does Machine Learning work?

Machine Learning is an application of Artificial intelligence (AI) that provides systems the ability to automatically learn and improve from experience without being explicitly programmed.

Figure: Machine Learning uses AI to learn, predict and improve

Any process in Machine Learning involves the following steps.

1. We will first input the data.

2. Analyze the data using a Machine Learning model involving an algorithm.

3. Find patterns in the data and train the model.

4. Make predictions/ take decisions based on this trained model on new data.

5. Store the feedback of the prediction/ decision to be reinforced at a later stage.

Types of Machine Learning

The following are the most popular types of Machine Learning and its algorithms used in the industry along with their applications.

Machine Learning can be classified into 3 types:

  1. Supervised Learning: — Systems are able to predict future outcomes based on past data. — Requires both an input and an output to be given to the model for it to be trained.
  2. Unsupervised Learning — Systems are able to identify hidden patterns from the input data provided. — By making the data more readable and organized, the patterns, similarities or anomalies become more evident.
  3. Reinforcement Learning — Systems are given no training. — It learns on the basis of the reward/ punishment it received for performing its last action. — It helps to increase the efficiency of a tool/ function or a program.

Real Life Use Case: Applications of Machine Learning in Facebook

Machine Learning is extensively used in Facebook:

Uber completely runs on Machine Learning!

Watch the video to understand machine learning in detail (courtesy machine learning):

What can you do with machine learning?

You can create a program, which can see an image and says a sentence about it (Although, that is a task requiring lots and lots of data): To get deeper details around machine learning projects, please watch the two videos below.

How we’re teaching computers to understand pictures

You can make a program that plays Mario game:

What Does a Machine Learning Scientist do?

• Carrying out machine learning experiments using a programming language and machine learning libraries.

• Implementing machine-learning solutions into production.

• Enhancing solutions for scalability and performance.

• Making sure there is a great data flow between backend systems and database.

• Deploying custom ML code.

• Analyzing data and producing use cases.

Understand everything through a nice visualization now:

What is the difference between machine learning, data analysis, data mining, data science, and AI?

Here is a brief description of each of these terms:

Data Science: Refers to the umbrella of techniques where you are trying to extract information and insights from data. This includes MIS reporting on the lowest level to building predictive models on a higher level.

Data Mining: refers to the science of collecting all the past data and then searching for patterns in this data. You look for consistent patterns and/or relationships between variables. Once you find these insights, you validate the findings by applying the detected patterns to new subsets of data. The ultimate goal of data mining is prediction — and predictive data mining is the most common type of data mining and one that has the most direct business applications.

Data Analysis: This is a loosely used term. People running reporting also say that they are analyzing data and so do predictive modelers. I would just take this as any attempt to make sense of data can be called as data analysis.

Machine Learning — Is the science of creating algorithms and program, which learn on their own. Once designed, they do not need a human to become better. Some of the common applications of machine learning include the following: Web Search, spam filters, recommender systems, ad placement, credit scoring, fraud detection, stock trading, computer vision, and drug design. An easy way to understand is this — it is humanly impossible to create models for every possible search or spam, so you make the machine intelligent enough to learn by itself. When you automate the later part of data mining — it is known as machine learning.

Chapter 03

Let’s Define The Framework to Develop a Machine Learning Application (Project)

Tools and Technologies used in Machine Learning

There are several tools/packages that recently became very popular. With no doubt the “scikit-learn: machine learning in Python is the best one.

Besides Python, The R Project for Statistical Computing provides a great collection of tools for harnessing the Big Data.

Machine Learning Framework to Develop Projects

There is a lot written about the process of applied machine learning. We follow a 6-step process for classification and regression type problems, the common problem types at the heart of most machine learning problems. The process is as follows:

1. Problem Definition: Understand and clearly describe the problem that is being solved.

2. Analyze Data: Understand the information available that will be used to develop a model.

3. Prepare Data: Discover and expose the structure in the dataset.

4. Evaluate Algorithms: Develop a robust test harness and baseline accuracy from which to improve and spot check algorithms.

5. Improve Results: Leverage results to develop more accurate models.

6. Present Results: Describe the problem and solution so that third parties can understand it.

The above 6 steps can be summarized in the below image.

Figure: Applied Machine Learning Process Overview

By following the above-structured process on each problem you work through, you enforce a minimum level of rigor and dramatically increase the likelihood of getting good (or more likely excellent) results.

Use the Weka Machine Learning Workbench

The software platform for beginners to learn when getting started is the Weka Machine Learning Workbench.

I think the decision to use Weka when getting started is a complete no-brainer because:

It provides a simple graphical user interface that encapsulates the process of applied machine learning outlined above.

  • It facilitates algorithm and dataset exploration as well as rigors experiment design and analysis.
  • It is a free and open source, licensed under the GNU GPL.
  • It is cross-platform and runs on Windows, Mac OS X and Linux (requires a Java virtual machine).
  • It contains state-of-the-art algorithms with an impressive abundance of Decision Trees, Rule-Based Algorithms and Ensemble methods, as well as others.
Weka Explorer Interface with the Iris dataset loaded

You can see for yourself how easy the platform is to use, there are a lot of Weka tutorials, such as:

· How to run your first classifier

· How to design and run your first experiment

· How to tune an algorithm rigorously in a designed experiment

· How to use ensemble methods in Weka

Additionally, if you get right into Weka, you can run algorithms from the command line and integrate algorithms into your application via the application programming interface. It is an extensible platform and you can quickly and easily implement your own algorithms to the interface and use them in the GUI.

Chapter 04
Let’s Discuss the Most Basic Algorithm To be Used in Machine Learning — Regression

Linear Regression is the most basic algorithm in machine learning to start with. Although this is basic one but quite popular among data scientists.

Linear Regression is a mathematical approach to compute the value of a particular variable based on other variable(s).

Many of you might be familiar with the equation Y = mX + c, which is the equation for a straight line, where:

· Y is the Dependent Variable

· X is the Independent Variable

Now, to estimate this Y variable with respect to X variable, you need to know the two parameters ‘m’ and ‘c’. With Linear Regression, you estimate these parameters ‘m’ and ‘c’, such that if you are given an X, you can easily predict Y for it.

Below, is the clear picture of what I intended to explain:

Now, as an output of the above equation, you will get a line like:

This line is commonly known as the Regression Line. The Regression Line is not created in one iteration. Actually, the so called ’m’ and ‘c’ values are computed multiple times before arriving at this Regression Line.

Now, I want you to focus on the keyword ‘Regression’. Regression, in general means, something done forcefully.

The Regression line found out as a result of ‘m’ and ‘’c estimation is actually from the method known as LSE(Least Squares Estimation), which minimizes the sum of the squares of the residuals obtained as a result of every single equation.

Hence, the Regression Line is also known as the Best Fit Line.

Although, this is a classic Statistical technique but nowadays, it is being used with Machine Learning, wherein you have a set of X and Y values and you build a Linear Regression model using those X and Y values, such that if you supply the model with a different set of X values, it automatically predicts Y for them.

Machine Learning Algorithms Mind Map

There are lots of machine learning algorithms used to train the models and make predictions using these models. Most of the machine learning algorithms can be summarized in the below image.

1. Supervised Machine Learning

The majority of practical machine learning uses supervised learning.

Supervised learning is where you have input variables (x) and an output variable (Y) and you use an algorithm to learn the mapping function from the input to the output.

Y = f(X)

The goal is to approximate the mapping function so well that when you have new input data (x) that you can predict the output variables (Y) for that data.

It is called supervised learning because the process of an algorithm learning from the training dataset can be thought of as a teacher supervising the learning process. We know the correct answers, the algorithm iteratively makes predictions on the training data and is corrected by the teacher. Learning stops when the algorithm achieves an acceptable level of performance.

Supervised learning problems can be further grouped into regression and classification problems.

  • Classification: A classification problem is when the output variable is a category, such as “red” or “blue” or “disease” and “no disease”. Below are the major algorithms for classification.

Logistic Regression

kNN

SVM

Decision Tree Classifier

Random Forest Classifier

  • Regression: A regression problem is when the output variable is a real value, such as “dollars” or “weight”. There are below algorithms under this category.

Linear Regression

Multiple Regression

Polynomial Regression

Decision Tree Regressor

Random Forest Regressor

SVR

2. Unsupervised Machine Learning

Unsupervised learning is where you only have input data (X) and no corresponding output variables.

The goal of unsupervised learning is to model the underlying structure or distribution in the data in order to learn more about the data. These are called unsupervised learning because unlike supervised learning above there is no correct answers and there is no teacher. Algorithms are left to their own devices to discover and present the interesting structure in the data.

Unsupervised learning problems can be further grouped into clustering and association problems.

  • Clustering: A clustering problem is where you want to discover the inherent groupings in the data, such as grouping customers by purchasing behavior. Kmeans++ is the most used algorithm for the clustering.
  • Association: An association rule learning problem is where you want to discover rules that describe large portions of your data, such as people that buy X also tend to buy Y. Apriori algorithm for association rule learning problems.

Chapter 05
How to Practice Machine Learning Projects

There are lots of online platforms where you can start working on projects and get expert into this domain.

1. https://www.hackerrank.com/

2. https://www.hackerearth.com/

3. https://www.kaggle.com/

The best method to pick up essential machine learning skills fast is to practice building your skills with small easy to understand datasets. This technique helps you build your processes using interesting real-world data that are small enough for you to look at in excel or WEKA. In this article, you will learn of a high-quality database with plenty of datasets and some tips to help you focus your time on what matters to you!

Why practice with datasets?

Following online tutorials will keep you trapped in a dependent mindset that will limit your growth because you’re not learning HOW to solve any problem. Your learning how to apply a specific solution to a particular type of problem. It’s the equivalent of overfitting, which we all know leads to poor real-world performance.

If you’re interested in becoming a machine learning engineer, you need to make sure you can generalize to real data. Challenge your self every day and attack problems using a defined process.

Practicing your skills using datasets is the best way to do this.

Where do I get datasets?

Luckily for everyone, there is a fantastic repository of machine learning problems that you can access for free.

UCI Machine Learning Repository

The Center for machine learning and intelligent systems at the University of California, Irvine built the UCI machine learning repository. For 30 years it has been the place to go for machine learning researchers and machine learning students that need datasets to practice. You can download all of the available datasets on their webpage. They also lists all of the details about it including any publications that have used it, which is really useful when you want to learn researchers attacked the problem. The datasets can be downloaded in a few different ways as well (CSV/TXT).

There are only two downsides to the UCI datasets.

  • The other downside is that they are small so that you won’t get much experience in large-scale projects, but that shouldn’t matter because you guys are new at this! Start small!
  • The most significant downside is that these datasets are cleaned and pre-processed. Cleaning and pre-processing are essential parts of the machine learning process that you will face in your career. Not spending time practicing this skill will hurt you later down the road.

Practicing in a Targeted way

How do you go about practicing in a targeted way when there are so many datasets? An aspiring machine learning engineer would do best to figure out what their goals are and pick a dataset that would best get them to that goal. I’ve developed some questions you can ask your self to help narrow down the number of datasets.

  • What kind of problem are you looking to solve?
  • Regression, Classification, Regression, Clustering?
  • What sized dataset is it? Tens of data points or millions
  • How many features does the dataset have?
  • What Type of Features?
  • What domain is this dataset from?

Figure out what type of datasets you want to focus on to match up with your broader goals. Once you have this, you should be able to filter through the huge number of datasets that are available on the platform.

Example Problems

Don’t worry if your not sure exactly what your trying to learn. Its much better not to get stuck trying to find the perfect study plan. I’ve made a list of some datasets that you might find interesting. There a few types of problems here so give them all a shot.

Regression: http://archive.ics.uci.edu/ml/datasets/Wine+Quality

Clustering: https://archive.ics.uci.edu/ml/datasets/Bag+of+Words

Classification: http://archive.ics.uci.edu/ml/datasets/Wine

Health Classification:https://archive.ics.uci.edu/ml/datasets/Breast+Cancer+Wisconsin+%28Original%29

Online Courses and Videos

Thankfully, in 2019 there are a number of excellent online resources that can help you get up and running with Machine Learning in no time.

Andrew Ng’s Coursera course is the standard here, and does an excellent job of explaining the math and theory behind traditional Machine Learning

• For a more practical and code-based approach, try Machine Learning Mastery’s guide

• For Deep Learning, the fast.ai course

Offline Classes (Physical Classroom Teaching)

You can join Forsk Technologies Jaipur physical classes bootcamp.

Forsk Technologies is based out of Jaipur and works with universities to prepare students for skill-based hiring using data and technologies. Currently focused on IoT, Machine Learning, Deep Learning, Cloud, Big Data, Fullstack and Mobile.

You can join our upcoming summer program in 2019.

Books

Hands-on Machine Learning with Scikit-Learn and Tensorflow (O’Reilly) — “Through a series of recent breakthroughs, deep learning has boosted the entire field of machine learning. Now, even programmers who know close to nothing about this technology can use simple, efficient tools to implement programs capable of learning from data. This practical book shows you how.

Real World Machine Learning (Manning) — “Real-World Machine Learning is a practical guide designed to teach working developers the art of ML project execution. Without overdosing you on academic theory and complex mathematics, it introduces the day-to-day practice of machine learning, preparing you to successfully build and deploy powerful ML systems”.

Programming Collective Intelligence (O’Reilly) — “Want to tap the power behind search rankings, product recommendations, social bookmarking, and online matchmaking? This fascinating book demonstrates how you can build Web 2.0 applications to mine the enormous amount of data created by people on the Internet. With the sophisticated algorithms in this book, you can write smart programs to access interesting datasets from other web sites, collect data from users of your own applications, and analyze and understand the data once you’ve found it.

An Introduction to Statistical Learning (Springer Texts in Statistics) — “An Introduction to Statistical Learning provides an accessible overview of the field of statistical learning, an essential toolset for making sense of the vast and complex data sets that have emerged in fields ranging from biology to finance to marketing to astrophysics in the past twenty years. This book presents some of the most important modeling and prediction techniques, along with relevant applications.

Tutorials

Your First Machine Learning Project in Python Step-By-Step (Jason Brownlee) — “Do you want to do machine learning using Python, but you’re having trouble getting started? In this post, you will complete your first machine-learning project using Python. If you are a machine learning beginner and looking to finally get started using Python, this tutorial was designed for you.”

Python Machine Learning: Scikit-Learn Tutorial (Datacamp) — “Machine learning is a branch in computer science that studies the design of algorithms that can learn. Typical tasks are concept learning, function learning or “predictive modeling”, clustering and finding predictive patterns. These tasks are learned through available data that were observed through experiences or instructions, for example.

Machine Learning in Python: A Tutorial (Dataquest) — “In this tutorial, we’ll guide you through the basic principles of machine learning, and how to get started with machine learning with Python. Luckily for us, Python has an amazing ecosystem of libraries that make machine learning easy to get started with. We’ll be using the excellent Scikit-learn, Pandas, and Matplotlib libraries in this tutorial.

Machine Learning in R for Beginners (Datacamp) — “This small tutorial is meant to introduce you to the basics of machine learning in R: more specifically, it will show you how to use R to work with the well-known machine learning algorithm called “KNN” or k-nearest neighbors.

--

--

Forsk Technologies
Forsk Coding School

Training and Consultation in Python, Data Engineering, ML, DL, AI and IoT.