Machine Learning Algorithm
Machine Learning Algorithm
Outline
• Concept
• Definition
• Types
• Application
• Bias and Variance
• Overfitting and underfitting
Why Machine Learning
Consider how you would write a spam filter using traditional
programming techniques (Figure 1-1):
1. First you would look at what spam typically looks
like. You might notice that some words or phrases (such as
“4U,” “credit card,” “free,” and “amazing”) tend to come up a
lot in the subject. Perhaps you would also notice a few other
patterns in the sender’s name, the email’s body, and so on.
2. You would write a detection algorithm for each of
the patterns that you noticed, and your program would flag
emails as spam if a number of these patterns are detected.
3. You would test your program, and repeat steps 1
and 2 until it is good enough.
Since the problem is not trivial, your program will likely become a long list of complex rules — pretty hard to
maintain. In contrast, a spam filter based on Machine Learning techniques automatically learns which words and
phrases are good predictors of spam by detecting unusually frequent patterns of words in the spam examples
compared to the ham examples (Figure 1-2). The program is much shorter, easier to maintain, and most likely more
accurate
Why Machine Learning?
Moreover, if spammers notice that all their emails containing
“4U” are blocked, they might start writing “For U” instead. A
spam filter using traditional programming techniques would
need to be updated to flag “For U” emails. If spammers keep
working around your spam filter, you will need to keep writing
new rules forever.
Output Program
Models
Learner Resoner
Yet another important unsupervised task is anomaly detection — for example, detecting unusual credit card
transactions to prevent fraud, catching manufacturing defects, or automatically removing outliers from a
dataset before feeding it to another learning algorithm.
Another common unsupervised task is association rule learning, in which the goal is to dig into large amounts
of data and discover interesting relations between attributes. For example, suppose you own a supermarket.
Running an association rule on your sales logs may reveal that people who purchase barbecue sauce and
potato chips also tend to buy steak. Thus, you may want to place these items close to each other.
Semi Supervised Learning Algorithm
Some algorithms can deal with partially labeled training data, usually a lot of unlabeled data and a little bit of labeled data.
This is called semisupervised learning (Figure 1-11). Some photo-hosting services, such as Google Photos, are good examples
of this. Once you upload all your family photos to the service, it automatically recognizes that the same person A shows up in
photos 1, 5, and 11, while another person B shows up in photos 2, 5, and 7. This is the unsupervised part of the algorithm
(clustering). Now all the system needs is for you to tell it who these people are. Just one label per person, 4 and it is able to
name everyone in every photo, which is useful for searching photos
Semi Supervised
Most semi supervised learning algorithms are
combinations of unsupervised and supervised
algorithms. For example, deep belief networks (DBNs)
are based on unsupervised components called
restricted Boltzmann machines (RBMs) stacked on
top of one another. RBMs are trained sequentially in
an unsupervised manner, and then the whole system
is fine-tuned using supervised learning techniques.
Reinforcement Learning
Reinforcement Learning is a very different beast. The learning system, called an agent in this context, can observe the
environment, select and perform actions, and get rewards in return (or penalties in the form of negative rewards, as
in Figure 1-12). It must then learn by itself what is the best strategy, called a policy, to get the most reward over time.
A policy defines what action the agent should choose when it is in a given situation.
Machine learning model
Data set is divided into training and testing part in 80:20 ot 70:30 ratio. Training data with (xi,yi) is fed
into model for training. Once model is trained its performance is evaluated using test data. Xi of test
data is given to trained model and predicted output y’ is obtained. Model is tuned to reduced the
difference between y and y’