Machine Learning & Artificial Intelligence: Crash Course Computer Science #34

Machine Learning & Artificial Intelligence: Crash Course Computer Science #34

CrashCourse

0:02 Hi, I’m Carrie Anne, and welcome to Crash Course Computer Science!

0:05 As we’ve touched on many times in this series,

0:09 computers are incredible at storing, organizing,

0:11 fetching and processing huge volumes of data.

0:13 That’s perfect for things like e-commerce

0:15 websites with millions of items for sale,

0:17 and for storing billions of health records for quick access by doctors.

0:20 But what if we want to use computers not just to fetch and display data,

0:24 but to actually make decisions about data?

0:26 This is the essence of machine learning– algorithms

0:29 that give computers the ability to learn from data,

0:31 and then make predictions and decisions.

0:34 Computer programs with this ability are extremely useful

0:36 in answering questions like Is an email spam?

0:39 Does a person’s heart have arrhythmia?

0:41 What video should youtube recommend after this one?

0:43 While useful, we probably wouldn’t describe these programs as “intelligent”

0:46 in the same way we think of human intelligence.

0:48 So, even though the terms are often interchanged,

0:50 most computer scientists would say that machine learning is a set of techniques

0:54 that sits inside the even more ambitious

0:56 goal of Artificial Intelligence, or AI for short.

0:59 INTRO Machine Learning and AI algorithms tend to be pretty sophisticated.

1:12 So rather than wading into the mechanics of how they work,

1:14 we're going to focus on what the algorithms do conceptually.

1:17 Let’s start with a simple example:

1:19 deciding if a moth is a Luna Moth or an Emperor Moth.

1:23 This decision process is called classification,

1:24 and an algorithm that does it is called a classifier.

1:28 Although there are techniques that can use

1:29 raw data for training– like photos and sounds–

1:31 many algorithms reduce the complexity of real world

1:34 objects and phenomena into what are called features.

1:37 Features are values that usefully characterize the things we wish to classify.

1:41 For our moth example, we’re going to use two features: “wingspan” and “mass”.

1:45 In order to train our machine learning classifier to make good predictions,

1:48 we’re going to need training data.

1:50 To get that, we’d send an entomologist out into a forest

1:53 to collect data for both luna and emperor moths.

1:56 These experts can recognize different moths,

1:58 so they not only record the feature values,

2:00 but also label that data with the actual moth species.

2:03 This is called labeled data.

2:05 Because we only have two features,

2:06 it’s easy to visualize this data in a scatterplot.

2:09 Here, I’ve plotted data for 100 Emperor Moths in red and 100 Luna Moths in blue.

2:14 We can see that the species make two groupings, but….

2:17 there’s some overlap in the middle… so it’s

2:19 not entirely obvious how to best separate the two.

2:22 That’s what machine learning algorithms do– find optimal separations!

2:26 I’m just going to eyeball it and say anything less than

2:29 45 millimeters in wingspan is likely to be an Emperor Moth.

2:31 We can add another division that says additionally mass must be

2:35 less than .75 in order for our guess to be Emperor Moth.

2:38 These lines that chop up the decision space are called decision boundaries.

2:42 If we look closely at our data, we can see that 86 emperor moths would

2:46 correctly end up inside the emperor decision region,

2:48 but 14 would end up incorrectly in luna moth territory.

2:52 On the other hand, 82 luna moths would be correct,

2:55 with 18 falling onto the wrong side.

2:57 A table, like this, showing where a classifier gets

2:59 things right and wrong is called a confusion matrix...

3:02 which probably should have also been the title

3:03 of the last two movies in the Matrix Trilogy!

3:06 Notice that there’s no way for us to draw lines that give us 100% accuracy.

3:10 If we lower our wingspan decision boundary,

3:12 we misclassify more Emperor moths as Lunas.

3:15 If we raise it, we misclassify more Luna moths.

3:17 The job of machine learning algorithms, at a high level,

3:20 is to maximize correct classifications while

3:22 minimizing errors On our training data,

3:25 we get 168 moths correct, and 32 moths wrong,

3:28 for an average classification accuracy of 84%.

3:31 Now, using these decision boundaries,

3:32 if we go out into the forest and encounter an unknown moth,

3:35 we can measure its features and plot it onto our decision space.

3:39 This is unlabeled data.

3:40 Our decision boundaries offer a guess as to what species the moth is.

3:44 In this case, we’d predict it’s a Luna Moth.

3:46 This simple approach, of dividing the decision space up into boxes,

3:49 can be represented by what’s called a decision tree,

3:52 which would look like this pictorially or could

3:54 be written in code using If-Statements, like this.

3:56 A machine learning algorithm that produces decision trees needs to choose

4:00 what features to divide on…and then for each of those features,

4:03 what values to use for the division.

4:05 Decision Trees are just one basic example of a machine learning technique.

4:09 There are hundreds of algorithms in computer science literature today.

4:12 And more are being published all the time.

4:14 A few algorithms even use many decision

4:16 trees working together to make a prediction.

4:19 Computer scientists smugly call those Forests…

4:20 because they contain lots of trees.

4:22 There are also non-tree-based approaches, like Support Vector Machines,

4:26 which essentially slice up the decision space using arbitrary lines.

4:30 And these don’t have to be straight lines;

4:31 they can be polynomials or some other fancy mathematical function.

4:35 Like before, it’s the machine learning algorithm's job to figure

4:37 out the best lines to provide the most accurate decision boundaries.

4:40 So far, my examples have only had two features,

4:42 which is easy enough for a human to figure out.

4:46 If we add a third feature, let’s say, length of antennae,

4:49 then our 2D lines become 3D planes,

4:51 creating decision boundaries in three dimensions.

4:53 These planes don’t have to be straight either.

4:56 Plus, a truly useful classifier would contend with many different moth species.

5:00 Now I think you’d agree this is getting too complicated to figure out by hand…

5:03 But even this is a very basic

5:05 example– just three features and five moth species.

5:08 We can still show it in this 3D scatter plot.

5:10 Unfortunately, there’s no good way to visualize four features at once,

5:14 or twenty features, let alone hundreds or even thousands of features.

5:17 But that’s what many real-world machine learning problems face.

5:21 Can YOU imagine trying to figure out the equation

5:23 for a hyperplane rippling through a thousand-dimensional decision space?

5:26 Probably not, but computers,

5:27 with clever machine learning algorithms can… and they do,

5:30 all day long, on computers at places like Google,

5:33 Facebook, Microsoft and Amazon.

5:35 Techniques like Decision Trees and Support Vector Machines

5:37 are strongly rooted in the field of statistics,

5:39 which has dealt with making confident decisions,

5:42 using data, long before computers ever existed.

5:44 There’s a very large class

5:46 of widely used statistical machine learning techniques,

5:48 but there are also some approaches with no origins in statistics.

5:52 Most notable are artificial neural networks,

5:55 which were inspired by neurons in our brains!

5:57 For a primer of biological neurons, check out our three-part overview here,

6:01 but basically neurons are cells that process

6:04 and transmit messages using electrical and chemical signals.

6:07 They take one or more inputs from other cells,

6:09 process those signals, and then emit their own signal.

6:12 These form into huge interconnected networks

6:15 that are able to process complex information.

6:17 Just like your brain watching this youtube video.

6:20 Artificial Neurons are very similar.

6:21 Each takes a series of inputs, combines them, and emits a signal.

6:25 Rather than being electrical or chemical signals,

6:27 artificial neurons take numbers in, and spit numbers out.

6:30 They are organized into layers that are connected by links,

6:33 forming a network of neurons, hence the name.

6:35 Let’s return to our moth example to see

6:37 how neural nets can be used for classification.

6:40 Our first layer– the input layer– provides

6:42 data from a single moth needing classification.

6:44 Again, we’ll use mass and wingspan.

6:47 At the other end, we have an output layer,

6:49 with two neurons: one for Emperor Moth and another for Luna Moth.

6:52 The most excited neuron will be our classification decision.

6:55 In between, we have a hidden layer, that transforms our inputs into outputs,

6:59 and does the hard work of classification.

7:01 To see how this is done, let’s zoom into one neuron in the hidden layer.

7:05 The first thing a neuron does is multiply

7:07 each of its inputs by a specific weight,

7:09 let’s say 2.8 for its first input, and .1 for it’s second input.

7:12 Then, it sums these weighted inputs together,

7:14 which is in this case, is a grand total of 9.74.

7:18 The neuron then applies a bias to this result- in other words,

7:21 it adds or subtracts a fixed value, for example,

7:24 minus six, for a new value of 3.74.

7:27 These bias and inputs weights are initially set

7:29 to random values when a neural network is created.

7:32 Then, an algorithm goes in, and starts tweaking

7:34 all those values to train the neural network,

7:36 using labeled data for training and testing.

7:39 This happens over many interactions,

7:40 gradually improving accuracy– a process very much like human learning.

7:44 Finally, neurons have an activation function, also called a transfer function,

7:48 that gets applied to the output,

7:50 performing a final mathematical modification to the result.

7:53 For example, limiting the value to a range from negative one and positive one,

7:57 or setting any negative values to 0.

8:00 We’ll use a linear transfer function that passes the value through unchanged,

8:04 so 3.74 stays as 3.74.

8:07 So for our example neuron,

8:09 given the inputs .55 and 82, the output would be 3.74.

8:13 This is just one neuron, but this process of weighting, summing,

8:17 biasing and applying an activation function is

8:19 computed for all neurons in a layer,

8:21 and the values propagate forward in the network, one layer at a time.

8:24 In this example, the output neuron

8:26 with the highest value is our decision: Luna Moth.

8:29 Importantly, the hidden layer doesn’t have to be

8:31 just one layer… it can be many layers deep.

8:34 This is where the term deep learning comes from.

8:36 Training these more complicated networks takes a lot more computation and data.

8:40 Despite the fact that neural networks were invented over fifty years ago,

8:44 deep neural nets have only been practical very recently,

8:47 thanks to powerful processors, but even more so, wicked fast GPUs.

8:51 So, thank you gamers for being so demanding about silky smooth framerates!

8:55 A couple of years ago,

8:56 Google and Facebook demonstrated deep neural nets that could find faces

8:59 in photos as well as humans– and humans are really good at this!

9:03 It was a huge milestone.

9:05 Now deep neural nets are driving cars,

9:08 translating human speech, diagnosing medical conditions and much more.

9:11 These algorithms are very sophisticated,

9:12 but it’s less clear if they should be described as “intelligent”.

9:15 They can really only do one thing like classify moths,

9:19 find faces, or translate languages.

9:21 This type of AI is called Weak AI or Narrow AI.

9:23 It’s only intelligent at specific tasks.

9:25 But that doesn’t mean it’s not useful;

9:27 I mean medical devices that can make diagnoses,

9:30 and cars that can drive themselves are amazing!

9:32 But do we need those computers to compose music

9:34 and look up delicious recipes in their free time?

9:37 Probably not.

9:38 Although that would be kinda cool.

9:39 Truly general-purpose AI, one as smart and well-rounded as a human,

9:43 is called Strong AI.

9:45 No one has demonstrated anything

9:46 close to human-level artificial intelligence yet.

9:49 Some argue it’s impossible, but many people point to the explosion

9:52 of digitized knowledge– like Wikipedia articles,

9:54 web pages, and Youtube videos– as the perfect kindling for Strong AI.

9:58 Although you can only watch a maximum of 24 hours of youtube a day,

10:01 a computer can watch millions of hours.

10:04 For example, IBM’s Watson consults and synthesizes

10:07 information from 200 million pages of content,

10:10 including the full text of Wikipedia.

10:11 While not a Strong AI, Watson is pretty smart,

10:14 and it crushed its human competition in Jeopardy way back in 2011.

10:18 Not only can AIs gobble up huge volumes of information,

10:21 but they can also learn over time, often much faster than humans.

10:25 In 2016, Google debuted AlphaGo,

10:26 a Narrow AI that plays the fiendishly complicated board game Go.

10:31 One of the ways it got so good and able to beat the very best human players,

10:34 was by playing clones of itself millions and millions of times.

10:37 It learned what worked and what didn’t,

10:39 and along the way, discovered successful strategies all by itself.

10:42 This is called Reinforcement Learning, and it’s a super powerful approach.

10:45 In fact, it’s very similar to how humans learn.

10:48 People don’t just magically acquire the ability to walk...

10:51 it takes thousands of hours of trial and error to figure it out.

10:54 Computers are now on the cusp of learning by trial and error,

10:57 and for many narrow problems, reinforcement learning is already widely used.

11:00 What will be interesting to see,

11:01 is if these types of learning techniques can be applied more broadly,

11:04 to create human-like, Strong AIs that learn much like how kids learn,

11:08 but at super accelerated rates.

11:10 If that happens, there are some pretty big changes

11:13 in store for humanity– a topic we’ll revisit later.

11:16 Thanks for watching.

11:17 See you next week.

Study with Looplines Download Captions Watch on YouTube