UNIT 1 PART 4
Different forms of data, Key tasks of ML, Chosing right algorithm, Steps in
developing ML application
……………………………………………………………………………………
Key Terminologies -
Example of building a bird classification system.
➢ This sort of system is an interesting topic often associated with machine
learning called expert systems.
➢ In table 1.1 are some values for four parts of various birds that we decided
to measure.
➢ We chose to measure weight, wingspan, whether it has webbed feet, and
the color of its back.
➢ The four things we’ve measured are called features; these are also called
attributes.
➢ Each of the rows in table 1.1 is an instance made up of features.
➢ The first two features in table 1.1 are numeric and can take on decimal
values. The third feature (webbed feet) is binary: it can only be 1 or 0. The
fourth feature (back color) is an enumeration over the color palette we’re
using.
➢ Examples for “examples” and “features” : Cancer detection
➢ Consider the problem of developing an algorithm for detecting cancer.
➢ In this study we note the following.
• The units of observation are the patients.
• The examples are members of a sample of cancer patients.
• The following attributes of the patients may be chosen as the
features:
gender
age
blood pressure
the findings of the pathology report after a biopsy
➢ Pet selection
➢ Suppose we want to predict the type of pet a person will choose.
• The units are the persons.
• The examples are members of a sample of persons who own pets.
➢ EXAMPLE - Spam e-mail
➢ Let it be required to build a learning algorithm to identify spam e-mail.
• The unit of observation could be an e-mail messages.
• The examples would be specific messages.
• The features might consist of the words used in the messages.
➢ Examples and features are generally collected in a “matrix format”. Fig.
1.2 shows such a data set.
……………………………………………………………………………
Different forms of data
1. Numeric Feature : If a feature represents a characteristic measured in
numbers, it is called a numeric feature.
2. Categorical or nominal : A categorical feature is an attribute that can take
on one of a limited, and usually fixed, number of possible values on the
basis of some qualitative property. A categorical feature is also called a
nominal feature.
3. Ordinal data : This denotes a nominal variable with categories falling in an
ordered list. Examples include clothing sizes such as small, medium, and
large, or a measurement of customer satisfaction on a scale from “not at all
happy” to “very happy.”
4. Examples In the data given in Fig.1.2, the features “year”, “price” and
“mileage” are numeric and the features “model”, “ color” and
“transmission” are categorical.
………………………………………………………………………………….
How to choose the right algorithm
➢ With all the different algorithms in table 1.2, how can you choose which
one to use?
1. First, you need to consider your goal. What are you trying to get out of this?
(Do you want a probability that it might rain tomorrow, or do you want to
find groups of voters with similar interests?) What data do you have or can
you collect?
➢ If you’re trying to predict or forecast a target value, then you need to look
into supervised learning. If not, then unsupervised learning is the place you
want to be.
➢ If you’ve chosen supervised learning, what’s your target value? Is it a
discrete value like Yes/No, 1/2/3, A/B/C, or Red/Yellow/Black? If so, then
you want to look into classification.
➢ If the target value can take on a number of values, say any value from 0.00
to 100.00, or -999 to 999, or +to -, then you need to look into regression.
➢ If you’re not trying to predict a target value, then you need to look into
unsupervised learning.
➢ Are you trying to fit your data into some discrete groups? If so and that’s
all you need, you should look into clustering.
➢ Do you need to have some numerical estimate of how strong the fit is into
each group? If you answer yes, then you probably should look into a
density estimation algorithm.
2. The second thing you need to consider is your data.
o You should spend some time getting to know your data, and the
more you know about it, the better you’ll be able to build a
successful application.
o Things to know about your data are these: Are the features nominal
or continuous? Are there missing values in the features? If there are
missing values, why are there missing values? Are there outliers in
the data? Are you looking for a needle in a haystack, something that
happens very infrequently?
o All of these features about your data can help you narrow the
algorithm selection process.
o With the algorithm narrowed, there’s no single answer to what the
best algorithm is or what will give you the best results. You’re going
to have to try different algorithms and see how they perform. There
are other machine learning techniques that you can use to improve
the performance of a machine learning algorithm. The relative
performance of two algorithms may change after you process the
input data.
o The point is that finding the best algorithm is an iterative process of
trial and error.
o Many of the algorithms are different, but there are some common
steps you need to take with all of these algorithms when building a
machine learning application.
………………………………………………………………………………….
Steps in developing a machine learning application
1 Collect data.
You could collect the samples by scraping a website and extracting data, or you
could get information from an RSS feed or an API. You could have a device
collect wind speed measurements and send them to you, or blood glucose levels,
or anything you can measure. The number of options is endless. To save some
time and effort, you could use publicly available data.
2 Prepare the input data.
Once you have this data, you need to make sure it’s in a useable format. Eg:
Python List. You may need to do some algorithm-specific formatting here. Some
algorithms need features in a special format, some algorithms can deal with target
variables and features as strings, and some need them to be integers.
3 Analyze the input data.
This is looking at the data from the previous task. This could be as simple as
looking at the data you’ve parsed in a text editor to make sure steps 1 and 2 are
actually working and you don’t have a bunch of empty values.
You can also look at the data to see if you can recognize any patterns or if there’s
anything obvious, such as a few data points that are vastly different from the rest
of the set. Plotting data in one, two, or three dimensions can also help.
But most of the time you’ll have more than three features, and you can’t easily
plot the data across all features at one time. You could, however, use some
advanced methods we’ll talk about later to distill multiple dimensions down to
two or three so you can visualize the data.
4. If you’re working with a production system and you know what the data should
look like, or you trust its source, you can skip this step. This step takes human
involvement, and for an automated system you don’t want human involvement.
The value of this step is that it makes you understand you don’t have garbage
coming in.
5. Train the algorithm.
This is where the machine learning takes place. This step and the next step are
where the “core” algorithms lie, depending on the algorithm.
You feed the algorithm good clean data from the first two steps and extract
knowledge or information. This knowledge you often store in a format that’s
readily useable by a machine for the next two steps.
In the case of unsupervised learning, there’s no training step because you don’t
have a target value. Everything is used in the next step.
6 Test the algorithm.
This is where the information learned in the previous step is put to use. When
you’re evaluating an algorithm, you’ll test it to see how well it does. In the case
of supervised learning, you have some known values you can use to evaluate the
algorithm. In unsupervised learning, you may have to use some other metrics to
evaluate the success. In either case, if you’re not satisfied, you can go back to step
4, change some things, and try testing again. Often the collection or preparation
of the data may have been the problem, and you’ll have to go back to step 1.
7 Use it.
Here you make a real program to do some task, and once again you see if all the
previous steps worked as you expected. You might encounter some new
data and have to revisit steps 1–5.
Now we’ll talk about a language to implement machine learning applications. We
need a language that’s understandable by a wide range of people. We also need a
language that has libraries written for a number of tasks, especially matrix math
operations. We also would like a language with an active developer community.
Python is the best choice for these reasons.