WEBVTT

00:00:00.000 --> 00:00:00.958 align:middle line:90%


00:00:00.958 --> 00:00:02.395 align:middle line:90%
[SQUEAKING]

00:00:02.395 --> 00:00:04.311 align:middle line:90%
[RUSTLING]

00:00:04.311 --> 00:00:06.706 align:middle line:90%
[CLICKING]

00:00:06.706 --> 00:00:09.365 align:middle line:90%


00:00:09.365 --> 00:00:10.740 align:middle line:84%
MICHAEL SCOTT
ASATO CUTHBERT: OK.

00:00:10.740 --> 00:00:14.640 align:middle line:84%
Let's get started right on time,
both to set a good precedent,

00:00:14.640 --> 00:00:18.270 align:middle line:84%
and there's quite
a bit to do today.

00:00:18.270 --> 00:00:20.150 align:middle line:84%
Oh, I will put that
back down for one

00:00:20.150 --> 00:00:21.800 align:middle line:84%
second so that those
who just got in

00:00:21.800 --> 00:00:24.520 align:middle line:90%
can see the agenda for today.

00:00:24.520 --> 00:00:28.400 align:middle line:90%


00:00:28.400 --> 00:00:31.020 align:middle line:84%
First two things will just
be like a minute or two,

00:00:31.020 --> 00:00:35.360 align:middle line:84%
and then we'll spend the rest
of the time on what everybody

00:00:35.360 --> 00:00:38.390 align:middle line:84%
thinks is the coolest
thing in the world

00:00:38.390 --> 00:00:41.030 align:middle line:84%
these days in computation,
artificial intelligence

00:00:41.030 --> 00:00:42.530 align:middle line:90%
and machine learning.

00:00:42.530 --> 00:00:44.720 align:middle line:90%
But this is not a class in that.

00:00:44.720 --> 00:00:48.150 align:middle line:84%
We'll spend most of our
time on feature extraction,

00:00:48.150 --> 00:00:52.293 align:middle line:84%
the necessary evil
before doing great things

00:00:52.293 --> 00:00:53.960 align:middle line:84%
with artificial
intelligence and machine

00:00:53.960 --> 00:00:57.530 align:middle line:84%
learning when you're dealing
with data that's not already

00:00:57.530 --> 00:00:58.880 align:middle line:90%
numbers.

00:00:58.880 --> 00:01:04.010 align:middle line:84%
I want to do a really quick
discussion on something

00:01:04.010 --> 00:01:06.180 align:middle line:90%
on problem set 7/8.

00:01:06.180 --> 00:01:08.130 align:middle line:84%
I'm still listening
to the compositions.

00:01:08.130 --> 00:01:10.730 align:middle line:84%
Some of them are
really, really cool.

00:01:10.730 --> 00:01:14.280 align:middle line:84%
Just, they're all great,
that I've heard so far.

00:01:14.280 --> 00:01:17.060 align:middle line:90%
But some really went into it.

00:01:17.060 --> 00:01:21.200 align:middle line:84%
But there was one thing
that, among people

00:01:21.200 --> 00:01:23.960 align:middle line:84%
who attempted every
problem, ended up

00:01:23.960 --> 00:01:26.690 align:middle line:90%
being a consistent error.

00:01:26.690 --> 00:01:28.250 align:middle line:90%
Actually, two things.

00:01:28.250 --> 00:01:34.673 align:middle line:84%
One that a lot of people
missed here was in--

00:01:34.673 --> 00:01:36.590 align:middle line:84%
let's say you were in C
major, because that'll

00:01:36.590 --> 00:01:38.670 align:middle line:90%
make life easier.

00:01:38.670 --> 00:01:46.010 align:middle line:84%
I gave some chords
that were like this.

00:01:46.010 --> 00:01:50.030 align:middle line:84%
And what do we call
this in C major?

00:01:50.030 --> 00:01:52.110 align:middle line:84%
What's the sca--
in Roman numeral.

00:01:52.110 --> 00:01:55.222 align:middle line:84%
We're doing the Roman numeral
exercise for a second.

00:01:55.222 --> 00:01:56.953 align:middle line:90%
What scale degree?

00:01:56.953 --> 00:01:57.660 align:middle line:90%
STUDENT: A ii.

00:01:57.660 --> 00:01:58.480 align:middle line:84%
MICHAEL SCOTT
ASATO CUTHBERT: ii?

00:01:58.480 --> 00:01:58.980 align:middle line:90%
Good.

00:01:58.980 --> 00:02:01.417 align:middle line:84%
And what is the
quality of the chord?

00:02:01.417 --> 00:02:02.250 align:middle line:90%
STUDENT: Diminished.

00:02:02.250 --> 00:02:04.250 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: Diminished, great.

00:02:04.250 --> 00:02:07.443 align:middle line:84%
So you don't have your problem
set back for two reasons.

00:02:07.443 --> 00:02:09.610 align:middle line:84%
One, there are a couple
more songs I'm listening to.

00:02:09.610 --> 00:02:13.103 align:middle line:84%
And also-- so how would
we write ii diminished?

00:02:13.103 --> 00:02:13.770 align:middle line:90%
STUDENT: Circle.

00:02:13.770 --> 00:02:15.853 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT:
With a circle, yeah.

00:02:15.853 --> 00:02:25.320 align:middle line:84%
And then I noticed that my thing
said, or if it's vii diminished,

00:02:25.320 --> 00:02:26.980 align:middle line:90%
write this.

00:02:26.980 --> 00:02:31.150 align:middle line:84%
And I did not say, in general,
if it's diminished, write this.

00:02:31.150 --> 00:02:33.930 align:middle line:84%
So I think that some
people seem to write

00:02:33.930 --> 00:02:39.070 align:middle line:84%
specific code for making sure
that it only happened on vii.

00:02:39.070 --> 00:02:42.870 align:middle line:84%
But ii diminished
happens quite often.

00:02:42.870 --> 00:02:45.190 align:middle line:90%
How does it happen in C major?

00:02:45.190 --> 00:02:49.770 align:middle line:84%
You're borrowing from C
minor for a little bit.

00:02:49.770 --> 00:02:55.020 align:middle line:84%
So these borrowed chords,
either flat and natural.

00:02:55.020 --> 00:03:00.348 align:middle line:84%
And then you end up with
that D-F-A flat chord.

00:03:00.348 --> 00:03:02.640 align:middle line:84%
So that's where that comes
in, but I want to make sure.

00:03:02.640 --> 00:03:04.560 align:middle line:84%
I'm going to go
back because there

00:03:04.560 --> 00:03:06.170 align:middle line:84%
was an ambiguity in
the instructions,

00:03:06.170 --> 00:03:09.960 align:middle line:84%
and I want to make sure that
everybody gets the little point

00:03:09.960 --> 00:03:13.360 align:middle line:84%
back who made that,
who didn't put that in.

00:03:13.360 --> 00:03:16.810 align:middle line:84%
So that was one of the
two systematic issues,

00:03:16.810 --> 00:03:18.820 align:middle line:84%
and that came from
an ambiguity for me.

00:03:18.820 --> 00:03:26.780 align:middle line:84%
Here is the other one that came
up a lot that I want to address.

00:03:26.780 --> 00:03:27.280 align:middle line:90%
Oh, yeah.

00:03:27.280 --> 00:03:29.610 align:middle line:90%
So we just went from C major.

00:03:29.610 --> 00:03:31.650 align:middle line:90%
[PLAYS PIANO]

00:03:31.650 --> 00:03:32.550 align:middle line:90%
And we played--

00:03:32.550 --> 00:03:33.630 align:middle line:90%
[PLAYS PIANO]

00:03:33.630 --> 00:03:36.750 align:middle line:90%
--that ii diminished sound.

00:03:36.750 --> 00:03:40.490 align:middle line:90%
Then what about this sound?

00:03:40.490 --> 00:03:42.990 align:middle line:90%
[PLAYS PIANO]

00:03:42.990 --> 00:03:45.990 align:middle line:90%


00:03:45.990 --> 00:03:50.430 align:middle line:84%
Anyone identify
that chord by ear?

00:03:50.430 --> 00:03:51.918 align:middle line:90%
Or just the-- what's that?

00:03:51.918 --> 00:03:52.710 align:middle line:90%
STUDENT: Augmented.

00:03:52.710 --> 00:03:54.668 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: Augmented, great.

00:03:54.668 --> 00:03:56.050 align:middle line:90%
[PLAYS PIANO]

00:03:56.050 --> 00:03:56.550 align:middle line:90%
Good.

00:03:56.550 --> 00:04:03.160 align:middle line:84%
I was in, doing that
borrowing from minor thing.

00:04:03.160 --> 00:04:07.590 align:middle line:84%
And I left my blue pen, which
probably shows up better.

00:04:07.590 --> 00:04:10.310 align:middle line:84%
I was borrowing from minor and
I started on the third scale

00:04:10.310 --> 00:04:10.810 align:middle line:90%
degree.

00:04:10.810 --> 00:04:13.420 align:middle line:84%
And so this was not part of
your Roman numeral thing,

00:04:13.420 --> 00:04:16.270 align:middle line:84%
but it came on the
roots question.

00:04:16.270 --> 00:04:18.959 align:middle line:90%


00:04:18.959 --> 00:04:23.975 align:middle line:90%
What is the root of that chord?

00:04:23.975 --> 00:04:25.350 align:middle line:84%
STUDENT: It could
be any of them.

00:04:25.350 --> 00:04:26.450 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: No, it cannot.

00:04:26.450 --> 00:04:28.060 align:middle line:90%
Ah, we'll get to that.

00:04:28.060 --> 00:04:29.860 align:middle line:90%
That's where something happens.

00:04:29.860 --> 00:04:30.888 align:middle line:90%
Yep, exactly.

00:04:30.888 --> 00:04:31.930 align:middle line:90%
It's a great, great idea.

00:04:31.930 --> 00:04:32.745 align:middle line:90%
John?

00:04:32.745 --> 00:04:33.090 align:middle line:90%
STUDENT: E flat.

00:04:33.090 --> 00:04:34.632 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: E flat.

00:04:34.632 --> 00:04:38.020 align:middle line:84%
Now, we'll get to
it in just a second.

00:04:38.020 --> 00:04:46.100 align:middle line:90%
What is the root of that chord?

00:04:46.100 --> 00:04:49.200 align:middle line:90%


00:04:49.200 --> 00:04:50.404 align:middle line:90%
STUDENT: G.

00:04:50.404 --> 00:04:56.020 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT: G.
And let's see if I can make one.

00:04:56.020 --> 00:04:57.555 align:middle line:90%
We'll go back to our E flat.

00:04:57.555 --> 00:05:02.320 align:middle line:90%


00:05:02.320 --> 00:05:06.123 align:middle line:90%
What is the root of that one?

00:05:06.123 --> 00:05:06.790 align:middle line:90%
STUDENT: C flat.

00:05:06.790 --> 00:05:08.332 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: C flat.

00:05:08.332 --> 00:05:09.730 align:middle line:90%
Now, why is it?

00:05:09.730 --> 00:05:13.010 align:middle line:84%
And so, just so we all
have it in our ears again--

00:05:13.010 --> 00:05:15.485 align:middle line:90%
[PLAYS PIANO]

00:05:15.485 --> 00:05:17.470 align:middle line:90%


00:05:17.470 --> 00:05:20.750 align:middle line:84%
Three chords, three
exact same sound.

00:05:20.750 --> 00:05:23.410 align:middle line:84%
But roots, the
concept of root is

00:05:23.410 --> 00:05:27.640 align:middle line:84%
something that comes
from a triadic, sort

00:05:27.640 --> 00:05:30.170 align:middle line:90%
of a spelling-enabled thing.

00:05:30.170 --> 00:05:32.900 align:middle line:90%
So where do we find the root?

00:05:32.900 --> 00:05:35.780 align:middle line:84%
We talked about the
algorithm last time.

00:05:35.780 --> 00:05:37.100 align:middle line:90%
What do we want to find?

00:05:37.100 --> 00:05:38.583 align:middle line:90%
A bunch of stacked--

00:05:38.583 --> 00:05:39.250 align:middle line:90%
STUDENT: Thirds.

00:05:39.250 --> 00:05:40.100 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: Thirds.

00:05:40.100 --> 00:05:40.820 align:middle line:90%
Good, I heard it.

00:05:40.820 --> 00:05:41.690 align:middle line:90%
So stacked thirds.

00:05:41.690 --> 00:05:44.140 align:middle line:84%
So here, we have a third,
followed by a third,

00:05:44.140 --> 00:05:45.550 align:middle line:84%
or a third and a
fifth, depending

00:05:45.550 --> 00:05:46.760 align:middle line:90%
on how you're counting.

00:05:46.760 --> 00:05:48.517 align:middle line:90%
But here, what's this interval?

00:05:48.517 --> 00:05:49.350 align:middle line:90%
STUDENT: Diminished.

00:05:49.350 --> 00:05:49.900 align:middle line:90%
STUDENT: Diminished iv.

00:05:49.900 --> 00:05:50.410 align:middle line:90%
STUDENT: Diminished iv.

00:05:50.410 --> 00:05:51.290 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: Diminished iv.

00:05:51.290 --> 00:05:52.735 align:middle line:90%
Yeah, a iv of some sort.

00:05:52.735 --> 00:05:58.750 align:middle line:84%
So we have to move it up
the octave in order to get

00:05:58.750 --> 00:06:01.990 align:middle line:90%
our stacked iii's.

00:06:01.990 --> 00:06:08.470 align:middle line:84%
And here, we can move them both
up an octave in order to get

00:06:08.470 --> 00:06:09.380 align:middle line:90%
our stacked iii's.

00:06:09.380 --> 00:06:11.050 align:middle line:90%
So the diminished--

00:06:11.050 --> 00:06:14.230 align:middle line:84%
The augmented triad
is one of the places

00:06:14.230 --> 00:06:20.150 align:middle line:84%
where the concept of root has
everything to do with spelling.

00:06:20.150 --> 00:06:24.340 align:middle line:84%
There's one other very common
chord where the concept of root

00:06:24.340 --> 00:06:26.410 align:middle line:84%
has everything to
do with spelling.

00:06:26.410 --> 00:06:31.810 align:middle line:84%
You saw a big smile,
and it's not a triad.

00:06:31.810 --> 00:06:32.430 align:middle line:90%
Go ahead.

00:06:32.430 --> 00:06:33.430 align:middle line:90%
STUDENT: Diminished vii?

00:06:33.430 --> 00:06:35.470 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT:
Diminished vii chord, yeah.

00:06:35.470 --> 00:06:37.245 align:middle line:84%
Here, I'll just keep
it in the light.

00:06:37.245 --> 00:06:38.120 align:middle line:90%
Assuming that's good.

00:06:38.120 --> 00:06:40.070 align:middle line:90%
So yeah, diminished vii chord.

00:06:40.070 --> 00:06:42.370 align:middle line:90%
Let's say we're in C minor.

00:06:42.370 --> 00:06:48.670 align:middle line:84%
We're going to start on
B. Would somebody shout

00:06:48.670 --> 00:06:50.750 align:middle line:90%
out the next note?

00:06:50.750 --> 00:06:51.250 align:middle line:90%
STUDENT: D.

00:06:51.250 --> 00:06:53.240 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: D. Keep going.

00:06:53.240 --> 00:06:53.740 align:middle line:90%
STUDENT: F.

00:06:53.740 --> 00:06:55.630 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: F. And then?

00:06:55.630 --> 00:06:56.320 align:middle line:90%
STUDENT: A flat.

00:06:56.320 --> 00:06:58.112 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: A flat, yeah.

00:06:58.112 --> 00:07:02.140 align:middle line:84%
So vii, then we have
vii with a root on B.

00:07:02.140 --> 00:07:07.000 align:middle line:84%
But we can change this
to move it up an octave

00:07:07.000 --> 00:07:08.796 align:middle line:90%
and flip the enharmonic.

00:07:08.796 --> 00:07:12.610 align:middle line:90%


00:07:12.610 --> 00:07:21.100 align:middle line:84%
And suddenly, we have iii, iii,
iii, and our root becomes D.

00:07:21.100 --> 00:07:22.940 align:middle line:84%
We've got a lot more
to get through today,

00:07:22.940 --> 00:07:26.440 align:middle line:84%
so I will leave it to a test
to prove to yourself that we

00:07:26.440 --> 00:07:30.940 align:middle line:84%
can keep doing this somehow, and
get all, every one of the four

00:07:30.940 --> 00:07:37.420 align:middle line:84%
notes, as a diminished--
as having its own,

00:07:37.420 --> 00:07:38.810 align:middle line:90%
that note as a root.

00:07:38.810 --> 00:07:41.440 align:middle line:84%
So each of the chord factors,
depending on how you spell.

00:07:41.440 --> 00:07:43.190 align:middle line:84%
And that's one of the
reasons, by the way,

00:07:43.190 --> 00:07:45.490 align:middle line:84%
this gets away from the
computational side, but maybe

00:07:45.490 --> 00:07:48.080 align:middle line:84%
a cool computational
compositional tool.

00:07:48.080 --> 00:07:51.260 align:middle line:84%
One of the reasons why a
diminished vii chord is often

00:07:51.260 --> 00:07:55.290 align:middle line:84%
a very useful way to
modulate to remote keys,

00:07:55.290 --> 00:07:57.980 align:middle line:84%
because you just sort of start
emphasizing a different note

00:07:57.980 --> 00:07:59.005 align:middle line:90%
as your root.

00:07:59.005 --> 00:08:02.021 align:middle line:90%


00:08:02.021 --> 00:08:05.545 align:middle line:84%
Any questions on this,
or on other things?

00:08:05.545 --> 00:08:08.390 align:middle line:84%
We're all eager to get
to feature extraction?

00:08:08.390 --> 00:08:16.490 align:middle line:84%
On this, there should be a
notebook that says, under today,

00:08:16.490 --> 00:08:21.350 align:middle line:90%
2023-ai-template-blank.

00:08:21.350 --> 00:08:22.250 align:middle line:90%
That one.

00:08:22.250 --> 00:08:23.130 align:middle line:90%
Is it?

00:08:23.130 --> 00:08:23.630 align:middle line:90%
STUDENT: Yep, it's there.

00:08:23.630 --> 00:08:24.210 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: It's there.

00:08:24.210 --> 00:08:24.950 align:middle line:90%
Good, good, good.

00:08:24.950 --> 00:08:28.580 align:middle line:84%
So feel free to download that
and put that where you are,

00:08:28.580 --> 00:08:30.990 align:middle line:90%
and run it.

00:08:30.990 --> 00:08:32.549 align:middle line:90%
It will install.

00:08:32.549 --> 00:08:35.120 align:middle line:84%
If your hard drive is
almost completely full,

00:08:35.120 --> 00:08:40.610 align:middle line:84%
it will install a learning
toolkit called Orange, which

00:08:40.610 --> 00:08:43.039 align:middle line:84%
also installs another
machine learning toolkit

00:08:43.039 --> 00:08:46.710 align:middle line:84%
called scikit-learn, and I think
they might be a little bit big.

00:08:46.710 --> 00:08:47.850 align:middle line:90%
Might be-- whatever.

00:08:47.850 --> 00:08:53.300 align:middle line:84%
So make sure to run all
first, and that will get you

00:08:53.300 --> 00:08:56.660 align:middle line:90%
in a pretty decent shape.

00:08:56.660 --> 00:08:58.700 align:middle line:90%
I'm going to get started on--

00:08:58.700 --> 00:09:02.990 align:middle line:84%
what we're talking
about today is something

00:09:02.990 --> 00:09:04.800 align:middle line:90%
called feature extraction.

00:09:04.800 --> 00:09:08.480 align:middle line:84%
And so feature extraction
is a conversion of elements,

00:09:08.480 --> 00:09:14.820 align:middle line:84%
in this case, musical elements,
into single numbers or lists,

00:09:14.820 --> 00:09:18.110 align:middle line:84%
arrays, vectors, tensors,
whatever you want to call them,

00:09:18.110 --> 00:09:19.730 align:middle line:90%
of numbers.

00:09:19.730 --> 00:09:23.130 align:middle line:84%
It is the most boring thing
I will teach in the class.

00:09:23.130 --> 00:09:25.877 align:middle line:84%
And please don't correct me
if you're like, Cuthbert,

00:09:25.877 --> 00:09:27.960 align:middle line:84%
there's plenty of other
boring things you've done.

00:09:27.960 --> 00:09:31.560 align:middle line:84%
But no, it's really one of the
most boring things in the world.

00:09:31.560 --> 00:09:34.550 align:middle line:90%
And here's a reason to hate it.

00:09:34.550 --> 00:09:37.620 align:middle line:84%
It really sucks the
lifeblood out of music.

00:09:37.620 --> 00:09:39.530 align:middle line:84%
Everything that you
love about music

00:09:39.530 --> 00:09:42.690 align:middle line:84%
is going to be converted
into a few numbers.

00:09:42.690 --> 00:09:44.720 align:middle line:90%
It is-- sucks the life out.

00:09:44.720 --> 00:09:47.130 align:middle line:90%
It is the zombie of music world.

00:09:47.130 --> 00:09:48.270 align:middle line:90%
Adam's very excited.

00:09:48.270 --> 00:09:49.850 align:middle line:90%
Yes, zombie invasion!

00:09:49.850 --> 00:09:52.920 align:middle line:84%
But there's a lot
of amazing things,

00:09:52.920 --> 00:09:56.370 align:middle line:84%
we know, happening in artificial
intelligence, machine learning,

00:09:56.370 --> 00:09:58.770 align:middle line:84%
deep learning, algorithms,
all these things.

00:09:58.770 --> 00:10:03.120 align:middle line:84%
And as far as I know, they
all have one thing in common.

00:10:03.120 --> 00:10:06.210 align:middle line:84%
And that is, they
work on collections,

00:10:06.210 --> 00:10:09.740 align:middle line:90%
big collections of numbers.

00:10:09.740 --> 00:10:12.710 align:middle line:84%
There's some ways
that you can work

00:10:12.710 --> 00:10:17.210 align:middle line:84%
with images that, effectively,
are kind of like two-

00:10:17.210 --> 00:10:18.960 align:middle line:84%
or multi-dimensional
arrays of numbers.

00:10:18.960 --> 00:10:21.030 align:middle line:84%
But basically, they're
all going to be numbers.

00:10:21.030 --> 00:10:29.210 align:middle line:84%
So when I put some music
notation on the board,

00:10:29.210 --> 00:10:31.110 align:middle line:84%
we're not going to be
able to work with that,

00:10:31.110 --> 00:10:32.910 align:middle line:84%
even an image of
it, even a JPEG,

00:10:32.910 --> 00:10:35.550 align:middle line:84%
unless we convert it to pixels
and convert it to numbers.

00:10:35.550 --> 00:10:38.090 align:middle line:84%
When you hear a
sound, [VOCALIZING]

00:10:38.090 --> 00:10:39.560 align:middle line:84%
something like
that, you're going

00:10:39.560 --> 00:10:45.060 align:middle line:84%
to have to convert that
into numbers in some ways.

00:10:45.060 --> 00:10:49.250 align:middle line:84%
So we're going to be just
working on converting things

00:10:49.250 --> 00:10:49.750 align:middle line:90%
to numbers.

00:10:49.750 --> 00:10:54.470 align:middle line:90%
So it's pretty simple, and--

00:10:54.470 --> 00:10:58.650 align:middle line:84%
but how to do it,
and what to extract,

00:10:58.650 --> 00:11:00.270 align:middle line:84%
and how to make
your extractions,

00:11:00.270 --> 00:11:04.180 align:middle line:84%
is the deep art
that takes a while.

00:11:04.180 --> 00:11:08.070 align:middle line:84%
Now, I'll get to a little
bit later some of the things

00:11:08.070 --> 00:11:09.540 align:middle line:84%
that people are
doing today, where

00:11:09.540 --> 00:11:11.680 align:middle line:90%
feature extraction is less--

00:11:11.680 --> 00:11:14.710 align:middle line:84%
or careful feature
extraction is less important.

00:11:14.710 --> 00:11:18.160 align:middle line:84%
And I'll tell you what those
things tend to have in common,

00:11:18.160 --> 00:11:22.890 align:middle line:84%
and that is, they work
on much bigger data sets

00:11:22.890 --> 00:11:24.850 align:middle line:90%
than what we have.

00:11:24.850 --> 00:11:27.850 align:middle line:84%
So we're going to
get started on this.

00:11:27.850 --> 00:11:29.890 align:middle line:90%
Yep, that's my template here.

00:11:29.890 --> 00:11:32.980 align:middle line:84%
And we're going to
start with, why not?

00:11:32.980 --> 00:11:36.400 align:middle line:84%
We always start with our
favorite Bach chorale.

00:11:36.400 --> 00:11:37.590 align:middle line:90%
What's the number?

00:11:37.590 --> 00:11:38.576 align:middle line:90%
STUDENT: 66.6.

00:11:38.576 --> 00:11:40.800 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: 66.6.

00:11:40.800 --> 00:11:46.050 align:middle line:90%
Conjure up the bwv66.6.

00:11:46.050 --> 00:11:47.915 align:middle line:84%
I'm going to show
it, get it back.

00:11:47.915 --> 00:11:59.640 align:middle line:90%


00:11:59.640 --> 00:12:04.440 align:middle line:90%
OK, great.

00:12:04.440 --> 00:12:08.140 align:middle line:84%
So we're going to do some
manual feature extraction first.

00:12:08.140 --> 00:12:10.720 align:middle line:84%
We're going to convert
this into numbers.

00:12:10.720 --> 00:12:14.130 align:middle line:84%
I'm going to extract two things
from this, number of parts

00:12:14.130 --> 00:12:18.930 align:middle line:84%
and initial number
of beats per measure.

00:12:18.930 --> 00:12:22.243 align:middle line:90%
So let's just do our--

00:12:22.243 --> 00:12:24.160 align:middle line:84%
You don't have to type
this if you don't want.

00:12:24.160 --> 00:12:25.860 align:middle line:90%
numParts equals 4.

00:12:25.860 --> 00:12:27.100 align:middle line:90%
Time signature.

00:12:27.100 --> 00:12:29.140 align:middle line:90%
Numerator equals 4.

00:12:29.140 --> 00:12:32.670 align:middle line:84%
There, I have done manual
feature extraction,

00:12:32.670 --> 00:12:36.900 align:middle line:84%
and describing the
piece as two numbers.

00:12:36.900 --> 00:12:40.740 align:middle line:84%
They seem to look like 4-4,
but I didn't ever just extract

00:12:40.740 --> 00:12:41.500 align:middle line:90%
the denominator.

00:12:41.500 --> 00:12:43.625 align:middle line:84%
That just happens to be
coincidence they're both 4.

00:12:43.625 --> 00:12:47.860 align:middle line:84%
So I don't know if we'd even
call this feature extraction.

00:12:47.860 --> 00:12:49.810 align:middle line:90%
But you can see, it's pretty--

00:12:49.810 --> 00:12:52.990 align:middle line:84%
we were not talking about
very, very much here.

00:12:52.990 --> 00:12:59.110 align:middle line:84%
So I'm going to define an
automatic feature extractor.

00:12:59.110 --> 00:13:01.380 align:middle line:90%
So we'll call it extract_meter.

00:13:01.380 --> 00:13:03.870 align:middle line:84%
And extract_meter,
you can save time

00:13:03.870 --> 00:13:05.560 align:middle line:84%
by not putting
these annotations.

00:13:05.560 --> 00:13:07.720 align:middle line:84%
It takes in some
sort of a stream.

00:13:07.720 --> 00:13:11.440 align:middle line:84%
I'm calling it score,
even though it's not.

00:13:11.440 --> 00:13:14.350 align:middle line:90%
And it returns two integers.

00:13:14.350 --> 00:13:18.600 align:middle line:84%
What do you think the two
integers are going to be,

00:13:18.600 --> 00:13:21.108 align:middle line:90%
if you're extracting the meter?

00:13:21.108 --> 00:13:21.900 align:middle line:90%
STUDENT: Numerator.

00:13:21.900 --> 00:13:23.110 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT:
Numerator and denominator,

00:13:23.110 --> 00:13:23.610 align:middle line:90%
great.

00:13:23.610 --> 00:13:24.120 align:middle line:90%
Super.

00:13:24.120 --> 00:13:27.150 align:middle line:84%
So we can say, all the
meters in the piece

00:13:27.150 --> 00:13:32.970 align:middle line:84%
equals the score meter,
TimeSignature, recurse.

00:13:32.970 --> 00:13:38.790 align:middle line:84%
And the first one, we'll just
get the first one. first_meter,

00:13:38.790 --> 00:13:43.480 align:middle line:90%
all_meters 0.

00:13:43.480 --> 00:13:48.850 align:middle line:84%
And we'll return
first_meter's numerator

00:13:48.850 --> 00:13:52.130 align:middle line:90%
and first_meter's denominator.

00:13:52.130 --> 00:13:53.840 align:middle line:84%
I know I don't need
the parentheses,

00:13:53.840 --> 00:13:56.970 align:middle line:84%
but I just kind of
got used to that.

00:13:56.970 --> 00:13:59.590 align:middle line:90%


00:13:59.590 --> 00:14:04.930 align:middle line:84%
So I'll let people
get caught up.

00:14:04.930 --> 00:14:08.140 align:middle line:84%
Now, by the way, how
many time signatures

00:14:08.140 --> 00:14:10.300 align:middle line:90%
does this little chorale have?

00:14:10.300 --> 00:14:13.110 align:middle line:84%
Are we going overkill by
getting the first one?

00:14:13.110 --> 00:14:17.830 align:middle line:90%


00:14:17.830 --> 00:14:19.510 align:middle line:90%
Do you want to take a guess?

00:14:19.510 --> 00:14:21.365 align:middle line:90%
You all know it by now.

00:14:21.365 --> 00:14:21.865 align:middle line:90%
1?

00:14:21.865 --> 00:14:24.550 align:middle line:90%


00:14:24.550 --> 00:14:27.770 align:middle line:84%
It actually has 4, the
way music 21 counts.

00:14:27.770 --> 00:14:29.420 align:middle line:90%
1, 2, 3, 4.

00:14:29.420 --> 00:14:30.410 align:middle line:90%
They're all the same.

00:14:30.410 --> 00:14:33.070 align:middle line:84%
But this is an error
I make quite a bit

00:14:33.070 --> 00:14:36.170 align:middle line:84%
often, that each of the parts
has its own time signature.

00:14:36.170 --> 00:14:39.077 align:middle line:84%
So this is something
to be careful on.

00:14:39.077 --> 00:14:40.577 align:middle line:84%
And now, we'll get
to the first sort

00:14:40.577 --> 00:14:46.070 align:middle line:84%
of ethical dilemma of feature
extraction and machine learning,

00:14:46.070 --> 00:14:48.370 align:middle line:90%
of which there will be many.

00:14:48.370 --> 00:14:50.230 align:middle line:90%
And quite a number today.

00:14:50.230 --> 00:14:55.210 align:middle line:84%
What happens if a score doesn't
have any time signatures?

00:14:55.210 --> 00:14:56.330 align:middle line:90%
Do we want this?

00:14:56.330 --> 00:14:59.950 align:middle line:90%
Will this crash, first off?

00:14:59.950 --> 00:15:01.810 align:middle line:84%
And if you think
it will crash, tell

00:15:01.810 --> 00:15:06.895 align:middle line:84%
me what the error that's
probably going to be returned.

00:15:06.895 --> 00:15:08.270 align:middle line:84%
STUDENT: List
index out of range.

00:15:08.270 --> 00:15:08.890 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: List index

00:15:08.890 --> 00:15:10.400 align:middle line:90%
out of range, or index error.

00:15:10.400 --> 00:15:12.500 align:middle line:90%
Yep, that we're trying to get 0.

00:15:12.500 --> 00:15:20.270 align:middle line:84%
So we can say something
like, if not all_meters.

00:15:20.270 --> 00:15:22.700 align:middle line:84%
Now, so here's the
ethical dilemma.

00:15:22.700 --> 00:15:26.870 align:middle line:84%
I'm going to return 0
comma 0 as a special value.

00:15:26.870 --> 00:15:31.190 align:middle line:84%
That's also an integer, tuple
of two integers, that says,

00:15:31.190 --> 00:15:35.260 align:middle line:84%
I have no time
signature because I've

00:15:35.260 --> 00:15:37.640 align:middle line:84%
raised as a medieval
musicologist,

00:15:37.640 --> 00:15:39.460 align:middle line:84%
so I have Gregorian
chant lying around,

00:15:39.460 --> 00:15:42.320 align:middle line:84%
and other meterless
time signature pieces.

00:15:42.320 --> 00:15:46.820 align:middle line:84%
But the other reason
is that we sometimes,

00:15:46.820 --> 00:15:50.630 align:middle line:84%
in case of an error or
an out-of-bound value,

00:15:50.630 --> 00:15:53.960 align:middle line:84%
we return some sort of,
we call it the sentinel,

00:15:53.960 --> 00:15:57.340 align:middle line:84%
some kind of special
meaning number that says

00:15:57.340 --> 00:15:59.740 align:middle line:90%
some sort of an error happened.

00:15:59.740 --> 00:16:00.340 align:middle line:90%
Why?

00:16:00.340 --> 00:16:04.635 align:middle line:84%
Because you're going to someday
have a gigantic data set.

00:16:04.635 --> 00:16:06.760 align:middle line:84%
Maybe you're going to be
doing this up in the cloud

00:16:06.760 --> 00:16:10.093 align:middle line:84%
somewhere or something,
and you're going to have--

00:16:10.093 --> 00:16:13.060 align:middle line:90%


00:16:13.060 --> 00:16:15.680 align:middle line:84%
you're going to be
letting it run overnight,

00:16:15.680 --> 00:16:18.020 align:middle line:84%
consuming a huge amount
of processor money.

00:16:18.020 --> 00:16:21.460 align:middle line:84%
And eventually, there's going to
be some bad data in there that's

00:16:21.460 --> 00:16:23.500 align:middle line:90%
going to crash your system.

00:16:23.500 --> 00:16:28.030 align:middle line:84%
And you want to be like, OK, I
just let this run for 47 hours,

00:16:28.030 --> 00:16:30.493 align:middle line:84%
and now I have to
start all over again.

00:16:30.493 --> 00:16:32.410 align:middle line:84%
Because, of course, I
didn't save intermediary

00:16:32.410 --> 00:16:35.610 align:middle line:84%
values, because I'm a
theoretical person, not

00:16:35.610 --> 00:16:37.120 align:middle line:90%
a practical programmer.

00:16:37.120 --> 00:16:39.340 align:middle line:90%
But always save.

00:16:39.340 --> 00:16:41.460 align:middle line:84%
Write to disk every
once in a while.

00:16:41.460 --> 00:16:45.840 align:middle line:84%
But so this type of
thing helps to save you

00:16:45.840 --> 00:16:47.440 align:middle line:90%
from a little bit of bad data.

00:16:47.440 --> 00:16:51.780 align:middle line:84%
What it also does, though, is it
can swallow up systematic errors

00:16:51.780 --> 00:16:52.658 align:middle line:90%
in your thought.

00:16:52.658 --> 00:16:53.700 align:middle line:90%
You know what I'm saying?

00:16:53.700 --> 00:16:57.450 align:middle line:90%
That you didn't realize that--

00:16:57.450 --> 00:16:59.280 align:middle line:84%
the one that I
always get is, I'm

00:16:59.280 --> 00:17:01.170 align:middle line:84%
looking at the
pitch of everything

00:17:01.170 --> 00:17:03.310 align:middle line:84%
in the piece, pitch of
everything in there.

00:17:03.310 --> 00:17:07.540 align:middle line:84%
And then I forget that these
structures called chords exist,

00:17:07.540 --> 00:17:09.790 align:middle line:84%
which don't just have a
pitch, they have multiple.

00:17:09.790 --> 00:17:14.220 align:middle line:84%
And so I could end up silently
throwing out all of my data

00:17:14.220 --> 00:17:18.390 align:middle line:84%
about chords, rather than
realizing I have a mental model

00:17:18.390 --> 00:17:19.270 align:middle line:90%
problem in there.

00:17:19.270 --> 00:17:21.630 align:middle line:84%
And this is some
of the things that

00:17:21.630 --> 00:17:25.560 align:middle line:84%
can lead to AI that
doesn't include all of us,

00:17:25.560 --> 00:17:28.050 align:middle line:84%
that programmers
forget that women exist

00:17:28.050 --> 00:17:29.650 align:middle line:90%
or that non-white people exist.

00:17:29.650 --> 00:17:32.800 align:middle line:84%
And therefore, oh, that's
data that's out of bounds.

00:17:32.800 --> 00:17:35.540 align:middle line:84%
So we'll go with a
default response,

00:17:35.540 --> 00:17:39.560 align:middle line:84%
rather than learning how to
deal with facial recognition

00:17:39.560 --> 00:17:40.560 align:middle line:90%
on things like that.

00:17:40.560 --> 00:17:44.000 align:middle line:90%
So here, it's not such a big--

00:17:44.000 --> 00:17:46.760 align:middle line:84%
I don't think that
we're going to have

00:17:46.760 --> 00:17:50.450 align:middle line:84%
a problem with systematically
discriminating against Gregorian

00:17:50.450 --> 00:17:51.120 align:middle line:90%
chant.

00:17:51.120 --> 00:17:54.500 align:middle line:84%
But it's these
kinds of issues that

00:17:54.500 --> 00:17:58.700 align:middle line:84%
lead to so many of the
other ethical issues

00:17:58.700 --> 00:18:02.390 align:middle line:90%
in artificial intelligence.

00:18:02.390 --> 00:18:04.110 align:middle line:84%
With that aside,
we've all caught up.

00:18:04.110 --> 00:18:06.320 align:middle line:90%
Let's see, did I, somebody--

00:18:06.320 --> 00:18:10.280 align:middle line:84%
and everybody just save me time
when I type something wrong.

00:18:10.280 --> 00:18:10.920 align:middle line:90%
Check it.

00:18:10.920 --> 00:18:12.480 align:middle line:90%
But let's see if that works.

00:18:12.480 --> 00:18:13.340 align:middle line:90%
Whew.

00:18:13.340 --> 00:18:15.290 align:middle line:90%
extract_meter(bach).

00:18:15.290 --> 00:18:22.230 align:middle line:84%
We have our first, our first
automatic feature extractor.

00:18:22.230 --> 00:18:25.456 align:middle line:84%
Is this topic, so far,
as boring as I promised?

00:18:25.456 --> 00:18:26.300 align:middle line:90%
STUDENT: No.

00:18:26.300 --> 00:18:28.592 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT:
No OK, Somebody likes it.

00:18:28.592 --> 00:18:29.700 align:middle line:90%
Yeah, it's pretty good.

00:18:29.700 --> 00:18:31.470 align:middle line:84%
But let's go with
something else.

00:18:31.470 --> 00:18:33.820 align:middle line:84%
And we're going to start
with another ethical dilemma.

00:18:33.820 --> 00:18:38.140 align:middle line:84%
We're going to be working with
Ryan's Mammoth Collection.

00:18:38.140 --> 00:18:42.030 align:middle line:84%
And I think, if you
type "blooming,"

00:18:42.030 --> 00:18:44.800 align:middle line:84%
you should get something
that's not an error.

00:18:44.800 --> 00:18:45.737 align:middle line:90%
Do you?

00:18:45.737 --> 00:18:47.820 align:middle line:84%
Because you've already--
if you've run everything,

00:18:47.820 --> 00:18:54.180 align:middle line:84%
you've already run corpus,
parse, BloomingMeadowsJig.

00:18:54.180 --> 00:18:56.670 align:middle line:90%
And let's see that.

00:18:56.670 --> 00:19:01.750 align:middle line:84%
So apologies we didn't get
to the jig composition yet.

00:19:01.750 --> 00:19:04.210 align:middle line:84%
I do plan to pick
that up next week,

00:19:04.210 --> 00:19:06.870 align:middle line:84%
but I figure that there's
some other things that people

00:19:06.870 --> 00:19:09.480 align:middle line:84%
need for their final
projects, more importantly

00:19:09.480 --> 00:19:11.550 align:middle line:90%
than working with that.

00:19:11.550 --> 00:19:15.120 align:middle line:84%
So you all see
something like this,

00:19:15.120 --> 00:19:18.190 align:middle line:84%
but we're going to be back on
jigs again today for a bit.

00:19:18.190 --> 00:19:20.010 align:middle line:84%
Now, Ryan's Mammoth
Collection is

00:19:20.010 --> 00:19:22.060 align:middle line:84%
a little bit of an
ethical dilemma,

00:19:22.060 --> 00:19:23.440 align:middle line:90%
and I'm trying to replace it.

00:19:23.440 --> 00:19:30.660 align:middle line:84%
It is a collection of, I think,
something like 1.079 fiddle

00:19:30.660 --> 00:19:34.020 align:middle line:90%
tunes from the 19th century.

00:19:34.020 --> 00:19:37.200 align:middle line:84%
And that has a bunch
of jigs, hornpipes,

00:19:37.200 --> 00:19:40.950 align:middle line:84%
things that if you
take Joe Maurer's Sea

00:19:40.950 --> 00:19:45.250 align:middle line:84%
Shanties and English Folk Music
class and all those things,

00:19:45.250 --> 00:19:48.570 align:middle line:90%
you can learn more about them.

00:19:48.570 --> 00:19:54.120 align:middle line:84%
It also is a large collection
of musical experiences of 19th

00:19:54.120 --> 00:20:00.390 align:middle line:84%
century African-Americans
that has been parodied and/or

00:20:00.390 --> 00:20:03.720 align:middle line:84%
appropriated into
white minstrel shows.

00:20:03.720 --> 00:20:10.770 align:middle line:84%
So I've tried to remove
things that are offensive,

00:20:10.770 --> 00:20:13.890 align:middle line:84%
on first sight, from
the collection, titles

00:20:13.890 --> 00:20:15.130 align:middle line:90%
and things like that.

00:20:15.130 --> 00:20:19.080 align:middle line:84%
But the deeper history,
a lot of these songs,

00:20:19.080 --> 00:20:21.700 align:middle line:84%
has to do with a lot
of appropriation.

00:20:21.700 --> 00:20:24.990 align:middle line:84%
So I'm hoping to be
able to get a collection

00:20:24.990 --> 00:20:29.580 align:middle line:84%
to replace it at some point,
because it's not exactly

00:20:29.580 --> 00:20:31.360 align:middle line:84%
everything that I
want to do with it.

00:20:31.360 --> 00:20:34.890 align:middle line:84%
But anyhow, so we have-- for
going through, we have the one

00:20:34.890 --> 00:20:37.020 align:middle line:90%
jig, Blooming Meadows jig.

00:20:37.020 --> 00:20:44.220 align:middle line:84%
And I gave you just a
contrast, a reel, R-E-E-L,

00:20:44.220 --> 00:20:47.798 align:middle line:84%
and you should already have the
reel, I think, already loaded.

00:20:47.798 --> 00:20:49.090 align:middle line:90%
So you don't need to type this.

00:20:49.090 --> 00:20:51.750 align:middle line:84%
It's called the
"7th Regiment Reel."

00:20:51.750 --> 00:20:54.785 align:middle line:90%
And hopefully, I got that.

00:20:54.785 --> 00:20:58.020 align:middle line:90%


00:20:58.020 --> 00:20:59.696 align:middle line:84%
And it looks a
little bit different.

00:20:59.696 --> 00:21:04.380 align:middle line:90%


00:21:04.380 --> 00:21:06.420 align:middle line:84%
So what we're going
to do today is

00:21:06.420 --> 00:21:09.210 align:middle line:84%
try to build a system that
can tell the difference

00:21:09.210 --> 00:21:11.250 align:middle line:90%
between a jig and a reel.

00:21:11.250 --> 00:21:13.470 align:middle line:90%
Or a jig and--

00:21:13.470 --> 00:21:16.800 align:middle line:84%
try to fit it into the
remaining 52 minutes

00:21:16.800 --> 00:21:18.820 align:middle line:90%
between a jig and a not-jig.

00:21:18.820 --> 00:21:23.500 align:middle line:84%
The whole, all of music is
divided into jigs and not jigs.

00:21:23.500 --> 00:21:26.050 align:middle line:90%
It's great.

00:21:26.050 --> 00:21:29.790 align:middle line:90%
So we we'll be looking--

00:21:29.790 --> 00:21:31.583 align:middle line:84%
how would you define
the difference?

00:21:31.583 --> 00:21:33.000 align:middle line:84%
You can look down
at your own so I

00:21:33.000 --> 00:21:35.550 align:middle line:84%
don't have to keep
scrolling back and forth.

00:21:35.550 --> 00:21:39.180 align:middle line:84%
Just, if you're somebody
who didn't know,

00:21:39.180 --> 00:21:45.022 align:middle line:84%
hadn't encountered a reel or
a jig before, what is the--

00:21:45.022 --> 00:21:48.850 align:middle line:84%
what would you say is
an obvious difference?

00:21:48.850 --> 00:21:49.350 align:middle line:90%
Matthew?

00:21:49.350 --> 00:21:50.430 align:middle line:90%
Do you--

00:21:50.430 --> 00:21:51.545 align:middle line:90%
STUDENT: 2/4 versus 6/8?

00:21:51.545 --> 00:21:52.660 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: 2/4 versus 6/8.

00:21:52.660 --> 00:21:53.370 align:middle line:90%
Good.

00:21:53.370 --> 00:21:56.382 align:middle line:90%
Another signature?

00:21:56.382 --> 00:21:58.090 align:middle line:84%
STUDENT: It's the
essential one, I think.

00:21:58.090 --> 00:21:59.010 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: What's that?

00:21:59.010 --> 00:22:01.210 align:middle line:84%
STUDENT: It's the essential
one, the time signature.

00:22:01.210 --> 00:22:02.650 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT:
The same one, time signature?

00:22:02.650 --> 00:22:03.150 align:middle line:90%
Good.

00:22:03.150 --> 00:22:03.940 align:middle line:90%
Yeah.

00:22:03.940 --> 00:22:06.870 align:middle line:84%
STUDENT: So the [INAUDIBLE]
seems more syncopated.

00:22:06.870 --> 00:22:08.110 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT:
Which one seems more syncopated?

00:22:08.110 --> 00:22:08.710 align:middle line:90%
STUDENT: The jig.

00:22:08.710 --> 00:22:09.630 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT:
The jig, a little bit more

00:22:09.630 --> 00:22:10.270 align:middle line:90%
syncopated?

00:22:10.270 --> 00:22:12.660 align:middle line:84%
Especially things--
there's always

00:22:12.660 --> 00:22:16.560 align:middle line:84%
things like this that are
not, technically, rhythmically

00:22:16.560 --> 00:22:19.270 align:middle line:84%
syncopated, but kind
of feel a little bit.

00:22:19.270 --> 00:22:21.490 align:middle line:90%
Mm-hmm.

00:22:21.490 --> 00:22:21.990 align:middle line:90%
Good.

00:22:21.990 --> 00:22:23.430 align:middle line:90%
Anything else?

00:22:23.430 --> 00:22:24.363 align:middle line:90%
Yeah, Marlon.

00:22:24.363 --> 00:22:25.155 align:middle line:90%
[NOTIFICATION TONE]

00:22:25.155 --> 00:22:25.710 align:middle line:90%
STUDENT: [INAUDIBLE]

00:22:25.710 --> 00:22:27.040 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: What's that?

00:22:27.040 --> 00:22:28.390 align:middle line:84%
STUDENT: I said 16th
versus eighth notes.

00:22:28.390 --> 00:22:29.930 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT:
16th versus eighth notes.

00:22:29.930 --> 00:22:30.440 align:middle line:90%
Thank you.

00:22:30.440 --> 00:22:32.023 align:middle line:84%
I'm going to put
that in, and I'm also

00:22:32.023 --> 00:22:37.030 align:middle line:84%
going to disable my, my what do
you call it, my notifications.

00:22:37.030 --> 00:22:40.150 align:middle line:84%
Supposed to happen
automatically.

00:22:40.150 --> 00:22:41.050 align:middle line:90%
OK, yeah.

00:22:41.050 --> 00:22:42.410 align:middle line:90%
16th versus eighth notes.

00:22:42.410 --> 00:22:46.730 align:middle line:84%
We're actually going to
possibly use that as something.

00:22:46.730 --> 00:22:49.960 align:middle line:84%
So we're going to try
to have a system that

00:22:49.960 --> 00:22:51.580 align:middle line:90%
can do the difference.

00:22:51.580 --> 00:22:55.480 align:middle line:84%
You should have--
if you type ryan,

00:22:55.480 --> 00:22:56.930 align:middle line:90%
you should be getting something.

00:22:56.930 --> 00:23:00.340 align:middle line:84%
I'm going to really
quickly just cut and paste

00:23:00.340 --> 00:23:03.560 align:middle line:84%
what I did to get to
ryan and explain it.

00:23:03.560 --> 00:23:05.990 align:middle line:84%
I first created
something called ryanM,

00:23:05.990 --> 00:23:09.410 align:middle line:84%
where I find everything in
Ryan's Mammoth Collection.

00:23:09.410 --> 00:23:13.990 align:middle line:84%
And then what I've
done is, here's

00:23:13.990 --> 00:23:16.640 align:middle line:84%
another cut and
paste, 1059, I think,

00:23:16.640 --> 00:23:20.830 align:middle line:84%
yep, is that I've gone
through everything in there.

00:23:20.830 --> 00:23:22.720 align:middle line:84%
And said, first off,
I only want to look

00:23:22.720 --> 00:23:24.340 align:middle line:90%
at the first 500 of them.

00:23:24.340 --> 00:23:29.590 align:middle line:84%
And then, I'm looking, without
parsing, if the name of the file

00:23:29.590 --> 00:23:33.490 align:middle line:90%
has jig in it.

00:23:33.490 --> 00:23:36.830 align:middle line:84%
If it doesn't have jig in it,
and if you're over file 100,

00:23:36.830 --> 00:23:37.400 align:middle line:90%
continue.

00:23:37.400 --> 00:23:39.730 align:middle line:90%
So why did I do all this stuff?

00:23:39.730 --> 00:23:44.360 align:middle line:84%
Just so that I can get something
that is approximately 50/50 jig,

00:23:44.360 --> 00:23:45.850 align:middle line:90%
not jig.

00:23:45.850 --> 00:23:49.090 align:middle line:90%
So we end up with about 200.

00:23:49.090 --> 00:23:54.680 align:middle line:84%
Here, we can-- we end
up with 212 pieces,

00:23:54.680 --> 00:23:58.490 align:middle line:84%
and I happen to know that
59% of them are jigs.

00:23:58.490 --> 00:24:00.620 align:middle line:90%
So that's pretty good.

00:24:00.620 --> 00:24:03.860 align:middle line:84%
These are all what we
call metadata entries,

00:24:03.860 --> 00:24:06.730 align:middle line:90%
so they haven't been parsed yet.

00:24:06.730 --> 00:24:08.630 align:middle line:90%
OK, great.

00:24:08.630 --> 00:24:10.630 align:middle line:90%
Everybody with me?

00:24:10.630 --> 00:24:11.740 align:middle line:90%
There.

00:24:11.740 --> 00:24:12.430 align:middle line:90%
Great.

00:24:12.430 --> 00:24:18.190 align:middle line:84%
I'm going to define a
helper function that is--

00:24:18.190 --> 00:24:20.740 align:middle line:84%
how many ethical dilemmas
are we doing today?

00:24:20.740 --> 00:24:23.830 align:middle line:84%
This one's ethical, but this
one's sort of a research thing

00:24:23.830 --> 00:24:29.260 align:middle line:84%
called is_jig, which
determines if something

00:24:29.260 --> 00:24:35.110 align:middle line:84%
is a jig by looking
at the file name

00:24:35.110 --> 00:24:40.600 align:middle line:84%
and lowercasing it, and seeing
if the word jig is in that.

00:24:40.600 --> 00:24:47.200 align:middle line:84%
I've done this with rags before,
ragtime, a really great piano

00:24:47.200 --> 00:24:48.580 align:middle line:90%
genre.

00:24:48.580 --> 00:24:50.720 align:middle line:84%
Scott Joplin, the
most famous person.

00:24:50.720 --> 00:24:53.960 align:middle line:84%
And a lot of rags have
"rag" in the title.

00:24:53.960 --> 00:24:56.210 align:middle line:90%
"Maple Leaf Rag," and so on.

00:24:56.210 --> 00:25:00.278 align:middle line:84%
But then, there's "The
Entertainer," [VOCALIZING]

00:25:00.278 --> 00:25:00.778 align:middle line:90%


00:25:00.778 --> 00:25:03.140 align:middle line:84%
--which doesn't have the
word "rag" in the title.

00:25:03.140 --> 00:25:11.150 align:middle line:84%
So we're possibly having what
we call a bad ground truth.

00:25:11.150 --> 00:25:14.140 align:middle line:84%
The ground truth
is the definition

00:25:14.140 --> 00:25:17.510 align:middle line:90%
that is correct beforehand.

00:25:17.510 --> 00:25:20.420 align:middle line:90%
And so, is this song a jig?

00:25:20.420 --> 00:25:21.740 align:middle line:90%
Is this not a jig?

00:25:21.740 --> 00:25:24.990 align:middle line:84%
This is probably not the
greatest ground truth there.

00:25:24.990 --> 00:25:27.170 align:middle line:84%
The other thing that
will come up a lot

00:25:27.170 --> 00:25:31.460 align:middle line:84%
is that there is some
pieces that will be

00:25:31.460 --> 00:25:34.170 align:middle line:90%
very hard to tell if they are.

00:25:34.170 --> 00:25:36.620 align:middle line:84%
And two different,
intelligent people

00:25:36.620 --> 00:25:38.760 align:middle line:84%
could disagree on
something that's a jig.

00:25:38.760 --> 00:25:41.820 align:middle line:84%
This comes up a lot in
genre classification,

00:25:41.820 --> 00:25:45.110 align:middle line:84%
where people can't really
decide, is this country

00:25:45.110 --> 00:25:47.160 align:middle line:90%
or is this rock?

00:25:47.160 --> 00:25:48.930 align:middle line:90%
Is this funk?

00:25:48.930 --> 00:25:50.490 align:middle line:90%
Is this hip-hop?

00:25:50.490 --> 00:25:52.080 align:middle line:90%
Is this romantic?

00:25:52.080 --> 00:25:54.890 align:middle line:90%
Is this classical?

00:25:54.890 --> 00:25:58.850 align:middle line:84%
So somebody once
told me, when they

00:25:58.850 --> 00:26:02.340 align:middle line:84%
realized I came from a music
history training, musicology,

00:26:02.340 --> 00:26:04.790 align:middle line:84%
they said, the worst part
about musicologists getting

00:26:04.790 --> 00:26:08.810 align:middle line:84%
into this field is that they
give us really crappy ground

00:26:08.810 --> 00:26:10.105 align:middle line:90%
truths.

00:26:10.105 --> 00:26:12.900 align:middle line:84%
You all won't say what
the right answer is.

00:26:12.900 --> 00:26:16.950 align:middle line:84%
And that's, I hope, an
ambiguity we like as humans.

00:26:16.950 --> 00:26:21.830 align:middle line:84%
But anyhow, so we'll
have our is_jig.

00:26:21.830 --> 00:26:26.730 align:middle line:84%
We'll actually see,
is_jig(blooming).

00:26:26.730 --> 00:26:28.830 align:middle line:84%
I think that was the
one that is a jig.

00:26:28.830 --> 00:26:30.420 align:middle line:90%
And what was the other one?

00:26:30.420 --> 00:26:32.360 align:middle line:90%
A reel.

00:26:32.360 --> 00:26:35.120 align:middle line:90%
OK.

00:26:35.120 --> 00:26:41.480 align:middle line:84%
So with our garbage in, garbage
out, terrible ground truth, we--

00:26:41.480 --> 00:26:43.380 align:middle line:90%
seems to be working OK.

00:26:43.380 --> 00:26:47.340 align:middle line:84%
And I happen to know, 127 of
the things in there is jigs.

00:26:47.340 --> 00:26:49.650 align:middle line:84%
So let's get out second
feature extractor.

00:26:49.650 --> 00:26:51.240 align:middle line:84%
This one's going
to be pretty easy.

00:26:51.240 --> 00:26:53.940 align:middle line:84%
We'll just get the number
of sharps in the piece.

00:26:53.940 --> 00:26:57.380 align:middle line:84%
We started working
on jigs in G, so we

00:26:57.380 --> 00:27:00.300 align:middle line:84%
happen to know that there
are a whole bunch of them.

00:27:00.300 --> 00:27:01.500 align:middle line:90%
So maybe we'll do this.

00:27:01.500 --> 00:27:08.050 align:middle line:84%
And here, we can just do,
again, a try, return the scores

00:27:08.050 --> 00:27:12.890 align:middle line:84%
key.KeySignature,
the number of sharps.

00:27:12.890 --> 00:27:15.177 align:middle line:84%
If it's two flats, what's
it going to return?

00:27:15.177 --> 00:27:16.010 align:middle line:90%
STUDENT: Negative 2.

00:27:16.010 --> 00:27:17.420 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: Negative 2, yep.

00:27:17.420 --> 00:27:18.210 align:middle line:90%
Great.

00:27:18.210 --> 00:27:21.140 align:middle line:84%
And if there's no
key signature--

00:27:21.140 --> 00:27:23.820 align:middle line:84%
this one's actually not a
terrible assumption, right?

00:27:23.820 --> 00:27:25.670 align:middle line:84%
Something without
a key signature

00:27:25.670 --> 00:27:29.197 align:middle line:84%
probably has a key signature
of no sharps or flats.

00:27:29.197 --> 00:27:30.030 align:middle line:90%
I don't know, maybe.

00:27:30.030 --> 00:27:32.600 align:middle line:84%
Maybe we should, in this
case, analyze the key

00:27:32.600 --> 00:27:34.770 align:middle line:90%
and do something like that.

00:27:34.770 --> 00:27:37.140 align:middle line:84%
But good enough for
just a little bit.

00:27:37.140 --> 00:27:38.930 align:middle line:90%
So let's see.

00:27:38.930 --> 00:27:43.400 align:middle line:84%
The blooming, hopefully
this will return 1.

00:27:43.400 --> 00:27:45.710 align:middle line:90%
Oops.

00:27:45.710 --> 00:27:47.610 align:middle line:90%
Oh, I know what I did.

00:27:47.610 --> 00:27:50.600 align:middle line:84%
This is why you should never
do something like this.

00:27:50.600 --> 00:27:56.970 align:middle line:84%
Except IndexError, we said, and
we didn't get an index error.

00:27:56.970 --> 00:27:57.990 align:middle line:90%
What did we get?

00:27:57.990 --> 00:27:59.640 align:middle line:90%
We got an AttributeError?

00:27:59.640 --> 00:28:01.520 align:middle line:84%
Yep, there is no
sharps, because I

00:28:01.520 --> 00:28:05.850 align:middle line:84%
forgot to say that we want the
first key signatures sharps.

00:28:05.850 --> 00:28:09.650 align:middle line:84%
You can also do the
dot 0 or bracket 0,

00:28:09.650 --> 00:28:10.860 align:middle line:90%
however you'd like that.

00:28:10.860 --> 00:28:14.570 align:middle line:84%
And so let me try
the get_sharps again.

00:28:14.570 --> 00:28:15.690 align:middle line:90%
Getting 1.

00:28:15.690 --> 00:28:18.700 align:middle line:90%
And what's the answer for Bach?

00:28:18.700 --> 00:28:19.200 align:middle line:90%
STUDENT: 3.

00:28:19.200 --> 00:28:20.620 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: 3, good.

00:28:20.620 --> 00:28:22.830 align:middle line:84%
You can either do that by
hand or make sure [INAUDIBLE].

00:28:22.830 --> 00:28:23.330 align:middle line:90%
Great.

00:28:23.330 --> 00:28:26.280 align:middle line:84%
And we'll define one
more feature extractor

00:28:26.280 --> 00:28:28.380 align:middle line:90%
so that we can--

00:28:28.380 --> 00:28:30.510 align:middle line:90%
oops.

00:28:30.510 --> 00:28:33.000 align:middle line:84%
We're actually making
good time this--

00:28:33.000 --> 00:28:38.370 align:middle line:84%
we'll do eighth_fraction
based on the observation

00:28:38.370 --> 00:28:42.460 align:middle line:84%
that there's more eighth notes
in one piece than the other.

00:28:42.460 --> 00:28:45.370 align:middle line:90%
So we'll take in a stream.Score.

00:28:45.370 --> 00:28:47.170 align:middle line:84%
And this time, we'll
return a float.

00:28:47.170 --> 00:28:50.680 align:middle line:84%
So usually, you
can return an int,

00:28:50.680 --> 00:28:53.310 align:middle line:84%
which we call a continuous--
a discrete vari--

00:28:53.310 --> 00:28:56.740 align:middle line:84%
answer or a float, which
is a continuous variable.

00:28:56.740 --> 00:28:58.150 align:middle line:90%
So let's just do this.

00:28:58.150 --> 00:28:59.983 align:middle line:84%
We'll get the number
of notes in the piece.

00:28:59.983 --> 00:29:00.900 align:middle line:90%
Actually, you do this.

00:29:00.900 --> 00:29:03.900 align:middle line:84%
You give me-- go ahead and try
coding this for a little bit,

00:29:03.900 --> 00:29:06.280 align:middle line:84%
because we are a couple
minutes ahead of time.

00:29:06.280 --> 00:29:09.708 align:middle line:90%
How do we get the returns?

00:29:09.708 --> 00:29:11.250 align:middle line:84%
The fra-- you don't
need to put this.

00:29:11.250 --> 00:29:18.530 align:middle line:84%
Returns the fraction of notes in
a score that are eighth notes.

00:29:18.530 --> 00:29:23.100 align:middle line:90%


00:29:23.100 --> 00:29:25.410 align:middle line:90%
OK, you can keep doing yours.

00:29:25.410 --> 00:29:28.770 align:middle line:84%
If you're stuck, I'm
going to give what I do.

00:29:28.770 --> 00:29:29.720 align:middle line:90%
Sign like--

00:29:29.720 --> 00:29:32.084 align:middle line:90%
[TYPING]

00:29:32.084 --> 00:29:46.470 align:middle line:90%


00:29:46.470 --> 00:29:49.020 align:middle line:84%
Not the most efficient
use of iterators.

00:29:49.020 --> 00:29:49.865 align:middle line:90%
I've done two.

00:29:49.865 --> 00:29:52.300 align:middle line:90%
[TYPING]

00:29:52.300 --> 00:30:09.130 align:middle line:90%


00:30:09.130 --> 00:30:10.830 align:middle line:90%
STUDENT: You're missing an H.

00:30:10.830 --> 00:30:11.700 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: I'm--

00:30:11.700 --> 00:30:12.520 align:middle line:90%
where am I missing it?

00:30:12.520 --> 00:30:13.920 align:middle line:84%
It's somewhere in
eighths, right?

00:30:13.920 --> 00:30:14.773 align:middle line:90%
STUDENT: Yeah.

00:30:14.773 --> 00:30:15.196 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: Where's--

00:30:15.196 --> 00:30:16.042 align:middle line:90%
STUDENT: So second to last.

00:30:16.042 --> 00:30:17.295 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: Ah, eighth.

00:30:17.295 --> 00:30:18.630 align:middle line:90%
That's-- yep, eighths.

00:30:18.630 --> 00:30:20.400 align:middle line:90%
Thank you.

00:30:20.400 --> 00:30:21.365 align:middle line:90%
Appreciate that.

00:30:21.365 --> 00:30:30.060 align:middle line:90%


00:30:30.060 --> 00:30:35.940 align:middle line:84%
And go ahead and run your num
eighths on Blooming, on Reel,

00:30:35.940 --> 00:30:36.990 align:middle line:90%
and on Bach.

00:30:36.990 --> 00:30:41.340 align:middle line:84%
And use your Spidey
sense to figure out

00:30:41.340 --> 00:30:46.090 align:middle line:84%
if your numbers are
pretty meaningful.

00:30:46.090 --> 00:30:50.070 align:middle line:84%
If there's anything I
can get from this class

00:30:50.070 --> 00:30:52.440 align:middle line:84%
to just use in all of your
programming things is,

00:30:52.440 --> 00:30:58.470 align:middle line:84%
always use your intuition
to see if something

00:30:58.470 --> 00:31:04.510 align:middle line:84%
like that, something
is working right.

00:31:04.510 --> 00:31:05.620 align:middle line:90%
Ooh, wow.

00:31:05.620 --> 00:31:08.130 align:middle line:90%
Look at that.

00:31:08.130 --> 00:31:10.920 align:middle line:90%
The reel is incredibly low.

00:31:10.920 --> 00:31:12.880 align:middle line:90%
Oops.

00:31:12.880 --> 00:31:14.990 align:middle line:84%
Now I have too many
eighth fracti--

00:31:14.990 --> 00:31:17.395 align:middle line:84%
I should have done it eighths
fraction, but whatever.

00:31:17.395 --> 00:31:17.895 align:middle line:90%
I'm--

00:31:17.895 --> 00:31:22.360 align:middle line:90%


00:31:22.360 --> 00:31:24.700 align:middle line:84%
That actually feels
too low for that reel.

00:31:24.700 --> 00:31:25.910 align:middle line:90%
Only 8%.

00:31:25.910 --> 00:31:30.190 align:middle line:84%
But I guess there's
a lot of 16th notes.

00:31:30.190 --> 00:31:33.180 align:middle line:84%
OK, give me a snap if
you're ready to move on.

00:31:33.180 --> 00:31:33.880 align:middle line:90%
[SNAPPING]

00:31:33.880 --> 00:31:36.350 align:middle line:90%
OK, hearing some snaps, not all.

00:31:36.350 --> 00:31:38.730 align:middle line:84%
We'll give another
10 seconds or so.

00:31:38.730 --> 00:31:42.304 align:middle line:90%


00:31:42.304 --> 00:31:48.160 align:middle line:84%
So so far, we have the
first one that seems really

00:31:48.160 --> 00:31:50.990 align:middle line:84%
to give, at least
in this one piece,

00:31:50.990 --> 00:31:57.140 align:middle line:84%
a big distinction among
the three types of things.

00:31:57.140 --> 00:32:01.090 align:middle line:90%


00:32:01.090 --> 00:32:06.070 align:middle line:84%
OK, now I'm going to wade into
something that people don't

00:32:06.070 --> 00:32:08.950 align:middle line:84%
always say, is this
a feature extractor

00:32:08.950 --> 00:32:10.760 align:middle line:84%
because it returns a
number or something?

00:32:10.760 --> 00:32:12.800 align:middle line:84%
Or is, when you put
them all together,

00:32:12.800 --> 00:32:14.390 align:middle line:90%
is that the feature extractor?

00:32:14.390 --> 00:32:17.205 align:middle line:84%
I'm not sure, but
I'll use this term.

00:32:17.205 --> 00:32:18.580 align:middle line:84%
So the feature
extractor is going

00:32:18.580 --> 00:32:22.070 align:middle line:84%
to run all of our different
little feature extractors.

00:32:22.070 --> 00:32:24.700 align:middle line:84%
And in this case,
I'm going to say,

00:32:24.700 --> 00:32:27.090 align:middle line:84%
it's going to
return a tuple of--

00:32:27.090 --> 00:32:29.210 align:middle line:84%
and I'll tell you what
these are in a bit.

00:32:29.210 --> 00:32:31.120 align:middle line:84%
But here, I'll
write this out here.

00:32:31.120 --> 00:32:37.320 align:middle line:84%
A string, two ints, a
float, an int, and an int.

00:32:37.320 --> 00:32:40.720 align:middle line:90%


00:32:40.720 --> 00:32:43.210 align:middle line:90%
And what are these going to be?

00:32:43.210 --> 00:32:46.690 align:middle line:84%
They're going to be
the file name, which

00:32:46.690 --> 00:32:50.270 align:middle line:84%
is pure metadata, just so that
we can look at things later.

00:32:50.270 --> 00:32:53.620 align:middle line:84%
They're going to be the
numerator and the denominator

00:32:53.620 --> 00:32:58.238 align:middle line:84%
of the piece using our function
we wrote, extract meter.

00:32:58.238 --> 00:33:00.280 align:middle line:84%
They're going to be--
what's the only thing we've

00:33:00.280 --> 00:33:02.523 align:middle line:84%
written that returns
a float as the answer?

00:33:02.523 --> 00:33:03.190 align:middle line:90%
STUDENT: Eighth.

00:33:03.190 --> 00:33:04.070 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: What's that?

00:33:04.070 --> 00:33:04.660 align:middle line:90%
STUDENT: Proportion of eighth.

00:33:04.660 --> 00:33:05.980 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT:
Eighth, yeah, eighth fraction,

00:33:05.980 --> 00:33:08.470 align:middle line:84%
eighth proportion, whatever
we are going to call it,

00:33:08.470 --> 00:33:12.970 align:middle line:84%
the number of sharps, and then
that last one we'll get to.

00:33:12.970 --> 00:33:16.510 align:middle line:84%
That's going to be
the ground truth.

00:33:16.510 --> 00:33:19.420 align:middle line:84%
And it's doing too
much JSON there.

00:33:19.420 --> 00:33:19.930 align:middle line:90%
Stop

00:33:19.930 --> 00:33:21.860 align:middle line:90%
Doing trailing commas.

00:33:21.860 --> 00:33:26.170 align:middle line:84%
So the file name, you get
this from a score's metadata

00:33:26.170 --> 00:33:28.460 align:middle line:84%
object, which we haven't
really talked about,

00:33:28.460 --> 00:33:32.420 align:middle line:90%
it's file path split.

00:33:32.420 --> 00:33:33.880 align:middle line:84%
I'm just going to
get the last bit

00:33:33.880 --> 00:33:37.500 align:middle line:84%
so I'm not showing my entire
directory tree to everything.

00:33:37.500 --> 00:33:40.090 align:middle line:84%
So I'll just get the last
thing after the slash.

00:33:40.090 --> 00:33:42.980 align:middle line:84%
Those of you who know
Python's path library,

00:33:42.980 --> 00:33:46.540 align:middle line:90%
you can probably do better.

00:33:46.540 --> 00:33:50.170 align:middle line:84%
The numerator and
the denominator

00:33:50.170 --> 00:33:56.650 align:middle line:84%
will extract meter
from the score.

00:33:56.650 --> 00:34:04.120 align:middle line:84%
The eighths we'll say is the
eighth fraction of the score.

00:34:04.120 --> 00:34:07.580 align:middle line:90%
Sharps feature is get sharps.

00:34:07.580 --> 00:34:09.239 align:middle line:84%
You can call them
whatever you'd like.

00:34:09.239 --> 00:34:17.090 align:middle line:84%
And then the ground truth,
is it a jig or is it not?

00:34:17.090 --> 00:34:19.290 align:middle line:90%
But it has to be a number.

00:34:19.290 --> 00:34:24.469 align:middle line:90%
So we'll say integer of is jig.

00:34:24.469 --> 00:34:32.480 align:middle line:84%
You could also say, if you like
this Python, 1 if jig, else 0.

00:34:32.480 --> 00:34:34.520 align:middle line:84%
Sometimes explicit's
a little bit nicer

00:34:34.520 --> 00:34:36.449 align:middle line:90%
to see what that's going to be.

00:34:36.449 --> 00:34:40.949 align:middle line:84%
And then we want to return
all that file name numerator,

00:34:40.949 --> 00:34:44.630 align:middle line:90%
denominator, eighths--

00:34:44.630 --> 00:34:45.929 align:middle line:90%
I should do quarters.

00:34:45.929 --> 00:34:47.090 align:middle line:90%
I can spell quarter--

00:34:47.090 --> 00:34:50.400 align:middle line:90%
feature, and ground truth.

00:34:50.400 --> 00:34:55.110 align:middle line:84%
I'll let everybody get caught
up while I debug my own system.

00:34:55.110 --> 00:34:58.740 align:middle line:84%
Whoa, some fast
typists in this class.

00:34:58.740 --> 00:35:01.440 align:middle line:90%
Feature extractor on bach.

00:35:01.440 --> 00:35:03.110 align:middle line:90%
Let me just see--

00:35:03.110 --> 00:35:09.125 align:middle line:90%
feature extractor on blooming.

00:35:09.125 --> 00:35:09.625 align:middle line:90%
OK.

00:35:09.625 --> 00:35:15.830 align:middle line:90%


00:35:15.830 --> 00:35:17.337 align:middle line:90%
ABC file extension, yep.

00:35:17.337 --> 00:35:18.170 align:middle line:90%
STUDENT: [INAUDIBLE]

00:35:18.170 --> 00:35:19.628 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: Yeah.

00:35:19.628 --> 00:35:22.140 align:middle line:84%
A lot of these are all
written as ABC files.

00:35:22.140 --> 00:35:24.500 align:middle line:84%
We didn't really cover-- no,
we didn't cover ABC files

00:35:24.500 --> 00:35:29.480 align:middle line:84%
because they're tiny bit
more complex than the easiest

00:35:29.480 --> 00:35:33.740 align:middle line:84%
to encode handwritten
things but not complex

00:35:33.740 --> 00:35:38.240 align:middle line:84%
enough as like
musicxml or something.

00:35:38.240 --> 00:35:41.850 align:middle line:84%
OK, so blooming metals
jig, it's in 6/8.

00:35:41.850 --> 00:35:45.930 align:middle line:84%
77% of its notes
are eighth notes.

00:35:45.930 --> 00:35:46.880 align:middle line:90%
It's in one sharp.

00:35:46.880 --> 00:35:50.366 align:middle line:84%
And that last one
indicates what again?

00:35:50.366 --> 00:35:51.320 align:middle line:90%
STUDENT: Jig.

00:35:51.320 --> 00:35:54.170 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT:
Yep, so the one indicates jig,

00:35:54.170 --> 00:35:54.720 align:middle line:90%
right?

00:35:54.720 --> 00:35:55.370 align:middle line:90%
Great.

00:35:55.370 --> 00:36:00.980 align:middle line:84%
OK, so what I'm
going to do right now

00:36:00.980 --> 00:36:03.870 align:middle line:84%
is I'm just going to
run this for a second.

00:36:03.870 --> 00:36:06.530 align:middle line:90%
So how would I get everything?

00:36:06.530 --> 00:36:10.160 align:middle line:90%
So we can do metadata.

00:36:10.160 --> 00:36:13.460 align:middle line:84%
I'm just doing this so we
can see how we do this.

00:36:13.460 --> 00:36:19.860 align:middle line:84%
In the Ryan thing, piece
equals metadata_entry.parse.

00:36:19.860 --> 00:36:26.750 align:middle line:84%
And then we'll print the
feature extractor on the piece.

00:36:26.750 --> 00:36:29.720 align:middle line:90%
Let me just try to see.

00:36:29.720 --> 00:36:32.090 align:middle line:90%
Yep.

00:36:32.090 --> 00:36:34.760 align:middle line:84%
Because of the way
I did it, you'll

00:36:34.760 --> 00:36:37.710 align:middle line:84%
see that at first,
there's not too many jigs.

00:36:37.710 --> 00:36:43.940 align:middle line:90%
And then later on, there's jigs.

00:36:43.940 --> 00:36:50.940 align:middle line:84%
OK, now, if you scroll back
up to the top of your-- sorry,

00:36:50.940 --> 00:36:54.150 align:middle line:84%
I'm going to have to get my
blank template for a second.

00:36:54.150 --> 00:36:56.330 align:middle line:90%
Oops, that's way smaller.

00:36:56.330 --> 00:36:59.700 align:middle line:84%
There should be, on the
top of your template

00:36:59.700 --> 00:37:02.540 align:middle line:84%
if you downloaded it,
something called write_ryan.

00:37:02.540 --> 00:37:06.390 align:middle line:84%
And you just need
to change your path

00:37:06.390 --> 00:37:11.080 align:middle line:84%
to someplace that you're going
to be able to remember it.

00:37:11.080 --> 00:37:14.880 align:middle line:84%
So change that, unless
you've created a Cuthbert

00:37:14.880 --> 00:37:17.670 align:middle line:84%
user because it makes it
easier for you to cut and paste

00:37:17.670 --> 00:37:18.825 align:middle line:90%
my code.

00:37:18.825 --> 00:37:20.200 align:middle line:84%
You probably want
to change that.

00:37:20.200 --> 00:37:23.070 align:middle line:84%
And then you can run
this while I explain

00:37:23.070 --> 00:37:24.320 align:middle line:90%
a little bit what it is.

00:37:24.320 --> 00:37:27.245 align:middle line:90%


00:37:27.245 --> 00:37:31.065 align:middle line:84%
Is write_ryan working for
people when you get that?

00:37:31.065 --> 00:37:31.565 align:middle line:90%
OK.

00:37:31.565 --> 00:37:34.930 align:middle line:90%


00:37:34.930 --> 00:37:35.430 align:middle line:90%
Great.

00:37:35.430 --> 00:37:38.310 align:middle line:90%


00:37:38.310 --> 00:37:45.185 align:middle line:84%
So I'm going to have
my own version here.

00:37:45.185 --> 00:37:55.140 align:middle line:90%


00:37:55.140 --> 00:37:56.227 align:middle line:90%
STUDENT: [INAUDIBLE]

00:37:56.227 --> 00:37:58.560 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT:
The write_ryan( ) command.

00:37:58.560 --> 00:38:03.910 align:middle line:84%
W-- you don't have to do any of
this, but it'll be kind of fun

00:38:03.910 --> 00:38:13.665 align:middle line:84%
because then you'll have
write_ryan and start.

00:38:13.665 --> 00:38:16.300 align:middle line:90%


00:38:16.300 --> 00:38:18.940 align:middle line:84%
OK, I've seen more
people waiting

00:38:18.940 --> 00:38:22.430 align:middle line:84%
than typing for a little bit,
so I'll just explain what we do.

00:38:22.430 --> 00:38:24.710 align:middle line:84%
Some of these things,
if you work with files,

00:38:24.710 --> 00:38:27.460 align:middle line:84%
you probably know
them pretty well.

00:38:27.460 --> 00:38:29.960 align:middle line:84%
This is really not necessarily
the best way to do this,

00:38:29.960 --> 00:38:31.940 align:middle line:90%
but I'm going to open two files.

00:38:31.940 --> 00:38:33.760 align:middle line:84%
One of them is the
file that we're

00:38:33.760 --> 00:38:37.040 align:middle line:84%
going to use to
train our classifier,

00:38:37.040 --> 00:38:40.300 align:middle line:84%
the thing that is going to try
to learn if something is a jig

00:38:40.300 --> 00:38:41.060 align:middle line:90%
or not.

00:38:41.060 --> 00:38:44.080 align:middle line:84%
The other one is
the file we're going

00:38:44.080 --> 00:38:49.430 align:middle line:84%
to do to try to test
whether it can do it or not.

00:38:49.430 --> 00:38:52.840 align:middle line:84%
We're going to
hope that we don't

00:38:52.840 --> 00:38:55.190 align:middle line:90%
put the same data into both.

00:38:55.190 --> 00:38:58.130 align:middle line:84%
So we're going to try to put
some data in the testing,

00:38:58.130 --> 00:38:59.283 align:middle line:90%
some data in the training.

00:38:59.283 --> 00:39:00.700 align:middle line:84%
There's a number
of different ways

00:39:00.700 --> 00:39:03.130 align:middle line:90%
you can do this type of work.

00:39:03.130 --> 00:39:08.030 align:middle line:84%
Sometimes you put 90% in the
training and 10% in the testing.

00:39:08.030 --> 00:39:10.900 align:middle line:84%
Sometimes you put 50/50, which
is what we're going to do.

00:39:10.900 --> 00:39:15.310 align:middle line:84%
Some of it has to do with
how much data you have.

00:39:15.310 --> 00:39:17.450 align:middle line:90%
So what I'm going to do--

00:39:17.450 --> 00:39:18.700 align:middle line:90%
maybe it'll be easier to see--

00:39:18.700 --> 00:39:21.610 align:middle line:84%
I'm just going to separate--
.tab means everything's going

00:39:21.610 --> 00:39:22.970 align:middle line:90%
to be separated by tabs.

00:39:22.970 --> 00:39:26.440 align:middle line:84%
So I'm going to first
put a header line that

00:39:26.440 --> 00:39:28.550 align:middle line:90%
says the names of the columns.

00:39:28.550 --> 00:39:29.930 align:middle line:90%
These are just for us to read.

00:39:29.930 --> 00:39:32.680 align:middle line:84%
So we have a file name,
numerator, denominator, eighths,

00:39:32.680 --> 00:39:34.760 align:middle line:90%
sharp, and isjig.

00:39:34.760 --> 00:39:37.280 align:middle line:84%
And so we're going to
write that to the top of it

00:39:37.280 --> 00:39:41.410 align:middle line:84%
because a lot of the classifiers
that work on tab data

00:39:41.410 --> 00:39:43.760 align:middle line:84%
expect this to be
the first line.

00:39:43.760 --> 00:39:47.320 align:middle line:84%
Now, we're going to hope that
when running this system,

00:39:47.320 --> 00:39:49.610 align:middle line:84%
that it doesn't peek
at the file name.

00:39:49.610 --> 00:39:53.590 align:middle line:84%
And we'll see because obviously,
file name would give it away.

00:39:53.590 --> 00:39:57.020 align:middle line:84%
And then so the descriptions,
what kind of data is this?

00:39:57.020 --> 00:39:58.700 align:middle line:90%
The file name's a string.

00:39:58.700 --> 00:40:00.190 align:middle line:84%
Then we have
discrete, as we said

00:40:00.190 --> 00:40:03.200 align:middle line:84%
for an integer, discrete,
continuous discrete, discrete.

00:40:03.200 --> 00:40:09.800 align:middle line:84%
So we'll write that out again
to each of the two files.

00:40:09.800 --> 00:40:13.060 align:middle line:84%
And then we have
third line, which

00:40:13.060 --> 00:40:15.350 align:middle line:84%
is mostly blank for
all these things.

00:40:15.350 --> 00:40:18.340 align:middle line:84%
And the first one
just says metadata.

00:40:18.340 --> 00:40:21.020 align:middle line:84%
That is to say, don't
peek at the file name--

00:40:21.020 --> 00:40:24.110 align:middle line:84%
do not use the file name
to try to classify this--

00:40:24.110 --> 00:40:27.860 align:middle line:84%
then normal information
and then the class,

00:40:27.860 --> 00:40:30.640 align:middle line:84%
the thing that we're
trying to figure out.

00:40:30.640 --> 00:40:34.960 align:middle line:84%
And we really, really hope that
the artificial intelligence

00:40:34.960 --> 00:40:39.260 align:middle line:84%
thing does not peek at the
class when it's trying to look.

00:40:39.260 --> 00:40:42.670 align:middle line:84%
You can really quickly
create an incredible AI thing

00:40:42.670 --> 00:40:44.057 align:middle line:90%
if you would allow it to peek.

00:40:44.057 --> 00:40:45.140 align:middle line:90%
And so we'll put that out.

00:40:45.140 --> 00:40:46.340 align:middle line:90%
So that's just all headers.

00:40:46.340 --> 00:40:48.965 align:middle line:84%
And that's why I didn't want to
spend too much time writing it.

00:40:48.965 --> 00:40:50.540 align:middle line:90%
Then what are we going to do?

00:40:50.540 --> 00:40:52.790 align:middle line:84%
Same thing we were
saying before,

00:40:52.790 --> 00:40:55.880 align:middle line:84%
we're just going to get
each piece into there.

00:40:55.880 --> 00:40:58.600 align:middle line:84%
I've done enumerate for a
reason so I can keep track

00:40:58.600 --> 00:41:00.670 align:middle line:90%
of what the piece number is.

00:41:00.670 --> 00:41:06.770 align:middle line:84%
And then we can extract the
piece, all the features from it.

00:41:06.770 --> 00:41:09.820 align:middle line:84%
And then we'll just
write them out.

00:41:09.820 --> 00:41:11.990 align:middle line:84%
In this case, we're going
to write them as a string

00:41:11.990 --> 00:41:15.175 align:middle line:84%
because we can only write
strings out to a text file.

00:41:15.175 --> 00:41:19.660 align:middle line:84%
Write each of the features
out, tab separated.

00:41:19.660 --> 00:41:21.470 align:middle line:84%
Actually, we'll get
ready to write it.

00:41:21.470 --> 00:41:22.850 align:middle line:90%
We'll just put it into a string.

00:41:22.850 --> 00:41:25.450 align:middle line:84%
And then every other
one, we're going

00:41:25.450 --> 00:41:28.160 align:middle line:84%
to write to training and
test, training and test.

00:41:28.160 --> 00:41:29.920 align:middle line:84%
Probably, another
way to do it would

00:41:29.920 --> 00:41:33.400 align:middle line:84%
be to flip a coin each time and
use a random number so you can

00:41:33.400 --> 00:41:35.330 align:middle line:90%
see if things are going there.

00:41:35.330 --> 00:41:38.390 align:middle line:84%
I'm not an expert on
this type of work.

00:41:38.390 --> 00:41:41.750 align:middle line:90%
But that's how that works.

00:41:41.750 --> 00:41:44.328 align:middle line:90%
And I don't think--

00:41:44.328 --> 00:41:46.120 align:middle line:84%
Yeah, I don't think
I'm going to run it now

00:41:46.120 --> 00:41:48.412 align:middle line:84%
because I should have been
running it during this time.

00:41:48.412 --> 00:41:49.070 align:middle line:90%
You know what?

00:41:49.070 --> 00:41:53.770 align:middle line:84%
I'm just going to put train
data x and test data x

00:41:53.770 --> 00:41:59.720 align:middle line:84%
so that while it's running, I
have access to our baked one.

00:41:59.720 --> 00:42:04.820 align:middle line:84%
So actually we can look
at it, magic features.

00:42:04.820 --> 00:42:12.070 align:middle line:84%
So we switch out of Python and
look at the shell for a second--

00:42:12.070 --> 00:42:15.520 align:middle line:84%
train data-- wherever
you put your thing.

00:42:15.520 --> 00:42:21.730 align:middle line:84%
And I can see that
I've written out--

00:42:21.730 --> 00:42:24.065 align:middle line:84%
it's kind of weird that
the tabs don't show up.

00:42:24.065 --> 00:42:26.440 align:middle line:84%
You would love to have something
that would automatically

00:42:26.440 --> 00:42:26.940 align:middle line:90%
put it out.

00:42:26.940 --> 00:42:29.920 align:middle line:84%
But we have the file name,
all our headers, description

00:42:29.920 --> 00:42:32.630 align:middle line:90%
of the data, the metadata here.

00:42:32.630 --> 00:42:38.180 align:middle line:84%
And then yeah, we have all of
our information written out.

00:42:38.180 --> 00:42:40.160 align:middle line:90%
So that's pretty good.

00:42:40.160 --> 00:42:42.910 align:middle line:90%
Oh that did finish, great.

00:42:42.910 --> 00:42:45.370 align:middle line:90%
OK.

00:42:45.370 --> 00:42:47.960 align:middle line:84%
So now we've done our
feature extraction.

00:42:47.960 --> 00:42:50.770 align:middle line:84%
The feature extraction
part of the lecture

00:42:50.770 --> 00:42:53.200 align:middle line:90%
is done for a little bit.

00:42:53.200 --> 00:42:55.413 align:middle line:84%
This is a small
number of features.

00:42:55.413 --> 00:42:57.080 align:middle line:84%
But I think that
they're going to end up

00:42:57.080 --> 00:42:59.810 align:middle line:84%
being halfway decent
features because we

00:42:59.810 --> 00:43:01.620 align:middle line:90%
thought about them a bit.

00:43:01.620 --> 00:43:04.340 align:middle line:84%
And when the data is small,
you want to think more

00:43:04.340 --> 00:43:05.190 align:middle line:90%
about your features.

00:43:05.190 --> 00:43:08.040 align:middle line:84%
So you installed
something called Orange 3.

00:43:08.040 --> 00:43:09.830 align:middle line:90%
But it's a little bit weird.

00:43:09.830 --> 00:43:12.210 align:middle line:90%
It comes as capital Orange.

00:43:12.210 --> 00:43:13.410 align:middle line:90%
I just I don't know why.

00:43:13.410 --> 00:43:15.630 align:middle line:90%
I don't like things capital.

00:43:15.630 --> 00:43:19.610 align:middle line:84%
So I always import orange
as lowercase orange.

00:43:19.610 --> 00:43:21.530 align:middle line:90%
Great.

00:43:21.530 --> 00:43:23.750 align:middle line:84%
We're going to load
our training data

00:43:23.750 --> 00:43:28.280 align:middle line:84%
and our test data, so
first training data,

00:43:28.280 --> 00:43:29.600 align:middle line:90%
orange.data.table.

00:43:29.600 --> 00:43:32.840 align:middle line:90%


00:43:32.840 --> 00:43:35.630 align:middle line:84%
A lot of these things are
going to be very similar

00:43:35.630 --> 00:43:40.520 align:middle line:84%
in a super modern
artificial intelligence

00:43:40.520 --> 00:43:45.380 align:middle line:84%
framework like
PyTorch or TensorFlow

00:43:45.380 --> 00:43:46.340 align:middle line:90%
or something like this.

00:43:46.340 --> 00:43:51.170 align:middle line:84%
Similar idea, you want to
load data in as a table.

00:43:51.170 --> 00:43:55.080 align:middle line:84%
If it's too big to load
on your all at once,

00:43:55.080 --> 00:43:58.170 align:middle line:84%
then there's special
techniques and stuff like that.

00:43:58.170 --> 00:44:00.630 align:middle line:84%
But we'll load the
training data in.

00:44:00.630 --> 00:44:04.480 align:middle line:84%
And now when we look at it, it
just looks a little bit nicer.

00:44:04.480 --> 00:44:08.150 align:middle line:90%


00:44:08.150 --> 00:44:11.570 align:middle line:90%
Actually, where's our first--

00:44:11.570 --> 00:44:13.250 align:middle line:90%
I don't know--

00:44:13.250 --> 00:44:16.170 align:middle line:90%
45 to 50?

00:44:16.170 --> 00:44:16.830 align:middle line:90%
Does that work?

00:44:16.830 --> 00:44:17.570 align:middle line:90%
Yeah.

00:44:17.570 --> 00:44:20.030 align:middle line:84%
OK, so that might be
a little bit better

00:44:20.030 --> 00:44:24.050 align:middle line:84%
because we can see
we have our features

00:44:24.050 --> 00:44:28.830 align:middle line:90%
here two for 12% and 3 sharps.

00:44:28.830 --> 00:44:34.580 align:middle line:84%
And this one happens
to be a jig, so there.

00:44:34.580 --> 00:44:37.950 align:middle line:84%
And so the afterward
is what the class is.

00:44:37.950 --> 00:44:40.710 align:middle line:84%
Great, and we'll do the exact
same thing with the test data.

00:44:40.710 --> 00:44:42.450 align:middle line:84%
And we'll call it
variable test data.

00:44:42.450 --> 00:44:44.300 align:middle line:84%
So I'm just going
to copy and paste.

00:44:44.300 --> 00:44:46.070 align:middle line:84%
And hopefully, the
test data looks

00:44:46.070 --> 00:44:47.530 align:middle line:90%
a lot like the training data.

00:44:47.530 --> 00:44:52.880 align:middle line:90%


00:44:52.880 --> 00:44:54.860 align:middle line:84%
STUDENT: Should we
change the file path?

00:44:54.860 --> 00:44:56.735 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: Oh, yeah, yeah.

00:44:56.735 --> 00:44:59.160 align:middle line:84%
It looks a lot like
the training data

00:44:59.160 --> 00:45:01.130 align:middle line:84%
if we don't change
the file path.

00:45:01.130 --> 00:45:02.460 align:middle line:90%
You see how well it is.

00:45:02.460 --> 00:45:08.030 align:middle line:84%
OK, so now we're
going to create some,

00:45:08.030 --> 00:45:10.280 align:middle line:84%
we'll call learners,
classifiers, things

00:45:10.280 --> 00:45:14.040 align:middle line:90%
that can classify the data.

00:45:14.040 --> 00:45:17.300 align:middle line:84%
Here's the first
one and I think,

00:45:17.300 --> 00:45:21.090 align:middle line:84%
in some ways, the most important
classifier that you'll ever use.

00:45:21.090 --> 00:45:24.120 align:middle line:84%
And that is-- why did I
switch into camelcase?

00:45:24.120 --> 00:45:26.060 align:middle line:84%
OK, I guess I'm
in camelcase now--

00:45:26.060 --> 00:45:28.917 align:middle line:84%
something called
orange.classific

00:45:28.917 --> 00:45:30.275 align:middle line:90%
ation.MajorityLearner.

00:45:30.275 --> 00:45:38.690 align:middle line:90%


00:45:38.690 --> 00:45:43.700 align:middle line:84%
And what a majority
learner is it's kind

00:45:43.700 --> 00:45:47.900 align:middle line:84%
of the control or the
placebo of your system

00:45:47.900 --> 00:45:51.270 align:middle line:84%
to make sure that you don't
get too excited by how

00:45:51.270 --> 00:45:53.650 align:middle line:90%
good your system is working.

00:45:53.650 --> 00:45:57.040 align:middle line:84%
What it does is it looks
at the training data,

00:45:57.040 --> 00:45:59.020 align:middle line:90%
which has hundreds--

00:45:59.020 --> 00:46:02.108 align:middle line:84%
what maybe the
training data has--

00:46:02.108 --> 00:46:02.650 align:middle line:90%
I don't know.

00:46:02.650 --> 00:46:08.620 align:middle line:84%
Let's say it has 51
jigs and 49 nonjigs.

00:46:08.620 --> 00:46:13.230 align:middle line:84%
And it says, I will always
say that any piece that's

00:46:13.230 --> 00:46:16.260 align:middle line:84%
ever shown to me is a jig
because then I will get over

00:46:16.260 --> 00:46:18.360 align:middle line:84%
50% right or I will
get the highest

00:46:18.360 --> 00:46:20.530 align:middle line:90%
answer of doing anything.

00:46:20.530 --> 00:46:24.630 align:middle line:84%
So if you are not beating
your majority learner,

00:46:24.630 --> 00:46:26.860 align:middle line:84%
then you're not doing
any classification.

00:46:26.860 --> 00:46:30.570 align:middle line:90%
So the majority classifier--

00:46:30.570 --> 00:46:33.430 align:middle line:84%
you all who have taken a
machine learning class,

00:46:33.430 --> 00:46:36.550 align:middle line:90%
do you get taught this or no?

00:46:36.550 --> 00:46:37.050 align:middle line:90%
Yeah.

00:46:37.050 --> 00:46:38.010 align:middle line:90%
OK, good.

00:46:38.010 --> 00:46:43.030 align:middle line:84%
Some people, this will be
totally old story and not.

00:46:43.030 --> 00:46:47.140 align:middle line:84%
So the majority learner
is just a generic thing.

00:46:47.140 --> 00:46:48.870 align:middle line:84%
And now we have a
classifier, which

00:46:48.870 --> 00:46:51.130 align:middle line:90%
is one trained on our data.

00:46:51.130 --> 00:46:56.490 align:middle line:84%
So we're going to say that the
majority classifier will now

00:46:56.490 --> 00:47:01.440 align:middle line:84%
know how to work with
this particular data.

00:47:01.440 --> 00:47:04.690 align:middle line:84%
And then we'll use another one
called k-nearest neighbors.

00:47:04.690 --> 00:47:08.470 align:middle line:84%
This was-- I don't know--
maybe 20 years ago,

00:47:08.470 --> 00:47:13.743 align:middle line:84%
the state of the art
of machine learning.

00:47:13.743 --> 00:47:15.160 align:middle line:84%
It's a little bit
out of date now.

00:47:15.160 --> 00:47:18.240 align:middle line:84%
But it does work pretty
well on small data

00:47:18.240 --> 00:47:20.470 align:middle line:90%
sets and few classifiers.

00:47:20.470 --> 00:47:23.700 align:middle line:84%
So nothing that it's
going to get you

00:47:23.700 --> 00:47:27.460 align:middle line:84%
super excited at
a top tech firm.

00:47:27.460 --> 00:47:30.910 align:middle line:90%
But it still has its uses.

00:47:30.910 --> 00:47:33.990 align:middle line:84%
So we're going to do the
same exact same thing.

00:47:33.990 --> 00:47:36.030 align:middle line:84%
Everything that I put
from majority learner,

00:47:36.030 --> 00:47:39.060 align:middle line:84%
and just put it
as KNN neighbors.

00:47:39.060 --> 00:47:41.840 align:middle line:84%
Look at the K, which
might be 4, might be 3,

00:47:41.840 --> 00:47:44.190 align:middle line:84%
might be 5, the
nearest neighbors

00:47:44.190 --> 00:47:49.200 align:middle line:84%
in a multi-dimensional vector
space to your one piece

00:47:49.200 --> 00:47:55.050 align:middle line:84%
and try to learn where
in this space it goes.

00:47:55.050 --> 00:47:58.290 align:middle line:90%
Snap if you're caught.

00:47:58.290 --> 00:48:01.620 align:middle line:84%
Snap if you're not now,
if you need a second.

00:48:01.620 --> 00:48:05.190 align:middle line:90%
OK, good.

00:48:05.190 --> 00:48:05.790 align:middle line:90%
Great.

00:48:05.790 --> 00:48:09.450 align:middle line:84%
So I'm just going to keep
track of how many correct

00:48:09.450 --> 00:48:11.860 align:middle line:84%
the majority gets in a
variable called majCorrect

00:48:11.860 --> 00:48:15.990 align:middle line:84%
and how many correct the
k-nearest neighbor gets

00:48:15.990 --> 00:48:18.100 align:middle line:90%
in a variable called knnCorrect.

00:48:18.100 --> 00:48:24.240 align:middle line:84%
And then total equals the
length of the test data, not

00:48:24.240 --> 00:48:25.000 align:middle line:90%
the training data.

00:48:25.000 --> 00:48:27.280 align:middle line:84%
So now we're going to
be working on this.

00:48:27.280 --> 00:48:31.480 align:middle line:84%
And we should have
something like this.

00:48:31.480 --> 00:48:38.490 align:middle line:84%
By the way, I lost half an hour
in preparing this lecture on,

00:48:38.490 --> 00:48:40.240 align:middle line:90%
why do I keep getting over 100%?

00:48:40.240 --> 00:48:44.340 align:middle line:84%
Always make sure to reclear
out your number correct as you

00:48:44.340 --> 00:48:49.938 align:middle line:84%
recode or something or make
sure to do it within your loop.

00:48:49.938 --> 00:48:51.440 align:middle line:90%
So good.

00:48:51.440 --> 00:48:56.030 align:middle line:84%
So we have 106 things that we're
going to be able to do now.

00:48:56.030 --> 00:48:59.500 align:middle line:90%
That was for our loop.

00:48:59.500 --> 00:49:06.230 align:middle line:84%
So we'll just do an enumeration
of each row in the test data.

00:49:06.230 --> 00:49:09.930 align:middle line:84%
So for i comma test row
in enumerate test data.

00:49:09.930 --> 00:49:13.885 align:middle line:90%


00:49:13.885 --> 00:49:16.450 align:middle line:84%
And then the majority
learner is going

00:49:16.450 --> 00:49:18.950 align:middle line:90%
to take a guess for each one.

00:49:18.950 --> 00:49:22.870 align:middle line:84%
So majority's guessed is going
to be the majority classifier

00:49:22.870 --> 00:49:26.320 align:middle line:84%
of the test row,
which it's always

00:49:26.320 --> 00:49:28.040 align:middle line:90%
going to guess the same thing.

00:49:28.040 --> 00:49:29.470 align:middle line:84%
I guess in this
case, it's always

00:49:29.470 --> 00:49:31.900 align:middle line:84%
going to guess jig
because there's four more

00:49:31.900 --> 00:49:33.650 align:middle line:90%
jigs than there are non jigs.

00:49:33.650 --> 00:49:38.050 align:middle line:84%
And then our classifier,
k-nearest neighbor classifier,

00:49:38.050 --> 00:49:43.630 align:middle line:84%
will also take a
guess, knnClassifier.

00:49:43.630 --> 00:49:45.550 align:middle line:84%
I know somebody's
probably saying "guess"

00:49:45.550 --> 00:49:48.440 align:middle line:84%
is not the right
word, but type works.

00:49:48.440 --> 00:49:55.310 align:middle line:84%
And then we'll get the real
is the testrows.get_class.

00:49:55.310 --> 00:50:00.200 align:middle line:84%
So as you said, the
class is either 1 or 0,

00:50:00.200 --> 00:50:01.760 align:middle line:90%
something like that.

00:50:01.760 --> 00:50:06.200 align:middle line:84%
And we can do print
out something.

00:50:06.200 --> 00:50:10.130 align:middle line:90%
But print-- how about this?

00:50:10.130 --> 00:50:19.180 align:middle line:84%
We'll just say majGuess,
knnGuess, and real.

00:50:19.180 --> 00:50:22.880 align:middle line:84%
So I'll start this
running for a second.

00:50:22.880 --> 00:50:24.940 align:middle line:84%
But notice, we haven't
put in anything

00:50:24.940 --> 00:50:26.600 align:middle line:84%
on whether it got
it right or not.

00:50:26.600 --> 00:50:28.930 align:middle line:90%
But we can just look at that.

00:50:28.930 --> 00:50:32.590 align:middle line:90%
Oh, one of them guesses.

00:50:32.590 --> 00:50:36.970 align:middle line:84%
So you can see that the majority
one for every single piece

00:50:36.970 --> 00:50:39.640 align:middle line:90%
just puts out--

00:50:39.640 --> 00:50:43.360 align:middle line:84%
yep, it's always a jig,
always a jig, always a jig.

00:50:43.360 --> 00:50:49.340 align:middle line:84%
K-nearest neighbor says, I
don't think this is a jig.

00:50:49.340 --> 00:50:50.690 align:middle line:90%
And here's the correct answer--

00:50:50.690 --> 00:50:52.460 align:middle line:90%
not a jig, not a jig, not a jig.

00:50:52.460 --> 00:50:55.930 align:middle line:84%
And here, k-nearest neighbor
is learning that, ooh, this one

00:50:55.930 --> 00:50:57.260 align:middle line:90%
looks like a jig.

00:50:57.260 --> 00:51:01.510 align:middle line:84%
So I'll just modify
this a tiny bit

00:51:01.510 --> 00:51:12.850 align:middle line:84%
and say, if majGuess equals
real, then majCorrect add 1.

00:51:12.850 --> 00:51:22.687 align:middle line:84%
If knnGuess equals real,
knnCorrect equals 1.

00:51:22.687 --> 00:51:24.770 align:middle line:84%
When you're trying to
figure out how to do things,

00:51:24.770 --> 00:51:26.210 align:middle line:90%
you'll use more classifiers.

00:51:26.210 --> 00:51:27.200 align:middle line:90%
There's a lot more.

00:51:27.200 --> 00:51:30.230 align:middle line:84%
And so you probably want to
do this in some of a loop.

00:51:30.230 --> 00:51:31.623 align:middle line:90%
But great.

00:51:31.623 --> 00:51:37.595 align:middle line:90%


00:51:37.595 --> 00:51:38.095 align:middle line:90%
Good.

00:51:38.095 --> 00:51:40.780 align:middle line:90%


00:51:40.780 --> 00:51:42.510 align:middle line:90%
And so now we'll see how we did.

00:51:42.510 --> 00:51:43.720 align:middle line:90%
How did majority do?

00:51:43.720 --> 00:51:48.230 align:middle line:90%


00:51:48.230 --> 00:51:49.940 align:middle line:90%
Here, I'll do this.

00:51:49.940 --> 00:51:55.010 align:middle line:84%
Majority majCorrect--
I always making

00:51:55.010 --> 00:51:56.605 align:middle line:90%
things look nice for humans.

00:51:56.605 --> 00:52:05.930 align:middle line:90%


00:52:05.930 --> 00:52:09.620 align:middle line:84%
Why am I anal enough
to start already

00:52:09.620 --> 00:52:14.040 align:middle line:84%
putting in some of a
rounding thing to look?

00:52:14.040 --> 00:52:18.990 align:middle line:84%
Because I do feel like when
you see all those digits,

00:52:18.990 --> 00:52:23.610 align:middle line:84%
it's really, really hard
to figure out how important

00:52:23.610 --> 00:52:24.360 align:middle line:90%
the difference is.

00:52:24.360 --> 00:52:26.270 align:middle line:84%
So the majority,
this is what I happen

00:52:26.270 --> 00:52:28.800 align:middle line:84%
to know that there's
59% of them are jigs.

00:52:28.800 --> 00:52:32.490 align:middle line:84%
And so the majority
learner got 59% of them.

00:52:32.490 --> 00:52:37.640 align:middle line:84%
And then we'll do the
same thing for KNN.

00:52:37.640 --> 00:52:39.912 align:middle line:84%
Here, I can cut
and paste, right?

00:52:39.912 --> 00:52:41.670 align:middle line:90%
We all know how to do that.

00:52:41.670 --> 00:52:43.450 align:middle line:90%
What are we looking up?

00:52:43.450 --> 00:52:43.950 align:middle line:90%
Great.

00:52:43.950 --> 00:52:47.100 align:middle line:90%


00:52:47.100 --> 00:52:49.750 align:middle line:84%
And we want to make sure
that that's knnCorrect.

00:52:49.750 --> 00:52:53.840 align:middle line:90%


00:52:53.840 --> 00:53:01.100 align:middle line:84%
So our classifier is getting
about 87% correct at this, just

00:53:01.100 --> 00:53:03.020 align:middle line:90%
with these few little things.

00:53:03.020 --> 00:53:07.100 align:middle line:84%
Now, this is always
the exciting moment.

00:53:07.100 --> 00:53:12.090 align:middle line:84%
And then the hard part is almost
always getting it from 87 to 95.

00:53:12.090 --> 00:53:14.360 align:middle line:84%
And the next harder part
is getting it from 95 to 97

00:53:14.360 --> 00:53:18.110 align:middle line:84%
and then going up and
up and up from there.

00:53:18.110 --> 00:53:21.900 align:middle line:84%
So that's the
theoretical part aside.

00:53:21.900 --> 00:53:28.460 align:middle line:84%
I'm going to really quickly
just go through some things

00:53:28.460 --> 00:53:37.610 align:middle line:84%
that music 21 has
that just make some

00:53:37.610 --> 00:53:40.460 align:middle line:90%
of this a little bit easier.

00:53:40.460 --> 00:53:44.040 align:middle line:84%
So I know it's already
imported since I imported star.

00:53:44.040 --> 00:53:46.050 align:middle line:84%
But there's something
called features.

00:53:46.050 --> 00:53:54.440 align:middle line:84%
And what we can do is set equals
a features.DataSet classLabel

00:53:54.440 --> 00:53:57.050 align:middle line:90%
equals is_jig.

00:53:57.050 --> 00:54:00.650 align:middle line:84%
And then we'll do the same
thing with the test set.

00:54:00.650 --> 00:54:05.210 align:middle line:84%
So far, it's basically
the same type of thing.

00:54:05.210 --> 00:54:08.780 align:middle line:84%
And then I believe
if you type fes,

00:54:08.780 --> 00:54:10.970 align:middle line:90%
you should have something there.

00:54:10.970 --> 00:54:12.470 align:middle line:90%
I think I pasted this.

00:54:12.470 --> 00:54:15.210 align:middle line:90%


00:54:15.210 --> 00:54:17.480 align:middle line:84%
These are built-in
feature extractor.

00:54:17.480 --> 00:54:19.580 align:middle line:90%
And each one of them has an ID.

00:54:19.580 --> 00:54:23.680 align:middle line:84%
And no, I don't have these
memorized, but something about--

00:54:23.680 --> 00:54:27.050 align:middle line:90%


00:54:27.050 --> 00:54:29.477 align:middle line:90%
I can't remember what these are.

00:54:29.477 --> 00:54:30.060 align:middle line:90%
You know what?

00:54:30.060 --> 00:54:32.602 align:middle line:84%
I'm just going to cut and paste
because you already have this

00:54:32.602 --> 00:54:35.780 align:middle line:90%
and put it here.

00:54:35.780 --> 00:54:37.800 align:middle line:90%
STUDENT: You have fears?

00:54:37.800 --> 00:54:41.890 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT:
Fears, yes, that's my hidden--

00:54:41.890 --> 00:54:42.970 align:middle line:90%
thank you very much.

00:54:42.970 --> 00:54:44.140 align:middle line:90%
Appreciate that.

00:54:44.140 --> 00:54:47.550 align:middle line:90%
And think that should work.

00:54:47.550 --> 00:54:52.650 align:middle line:84%
And so these are some features
that have already been put in.

00:54:52.650 --> 00:54:56.680 align:middle line:84%
So one of them, I don't know,
what's the range of the piece?

00:54:56.680 --> 00:54:59.440 align:middle line:84%
How far is it from the lowest
note to the highest note?

00:54:59.440 --> 00:55:02.670 align:middle line:84%
A lot of these, they're
adapted from a really, really

00:55:02.670 --> 00:55:06.870 align:middle line:84%
cool toolkit called
jSymbolic part of jMIR

00:55:06.870 --> 00:55:12.630 align:middle line:84%
by Cory Mckay up in Canada,
and just ported them over

00:55:12.630 --> 00:55:13.930 align:middle line:90%
because they're kind of neat.

00:55:13.930 --> 00:55:17.760 align:middle line:84%
And then some of them are ones
that I've written because I kind

00:55:17.760 --> 00:55:19.830 align:middle line:84%
think that they're
a little valuable

00:55:19.830 --> 00:55:22.360 align:middle line:84%
or somebody in the Music
21 team has written.

00:55:22.360 --> 00:55:25.660 align:middle line:84%
So here, we have a lot
more features here.

00:55:25.660 --> 00:55:28.930 align:middle line:84%
And what we can do is we
have our two data sets.

00:55:28.930 --> 00:55:34.020 align:middle line:84%
So we'll say the training
set addFeatureExtractors

00:55:34.020 --> 00:55:36.660 align:middle line:84%
and add all those
features extractors

00:55:36.660 --> 00:55:38.570 align:middle line:84%
and then same thing
for the test set.

00:55:38.570 --> 00:55:43.140 align:middle line:90%


00:55:43.140 --> 00:55:44.797 align:middle line:84%
And this, as I
said, you don't need

00:55:44.797 --> 00:55:46.380 align:middle line:84%
to be typing too
much because I'm just

00:55:46.380 --> 00:55:48.250 align:middle line:90%
going to go pretty fast.

00:55:48.250 --> 00:55:53.730 align:middle line:84%
And what we'll do is I'm just
going to cut and paste this

00:55:53.730 --> 00:55:57.420 align:middle line:84%
because all we're doing
is dividing things up

00:55:57.420 --> 00:56:00.040 align:middle line:84%
into either the test
or the training set,

00:56:00.040 --> 00:56:02.860 align:middle line:84%
depending on if
it's even or odd.

00:56:02.860 --> 00:56:06.450 align:middle line:84%
And so we'll just
add the data on here

00:56:06.450 --> 00:56:08.280 align:middle line:90%
with some nice little features.

00:56:08.280 --> 00:56:11.080 align:middle line:84%
And this will just generate
all the headers for you.

00:56:11.080 --> 00:56:13.500 align:middle line:90%
Whoops, what did I do?

00:56:13.500 --> 00:56:16.240 align:middle line:84%
Testing set is what
I called it before.

00:56:16.240 --> 00:56:18.395 align:middle line:84%
Sorry, training and
testing, that makes sense.

00:56:18.395 --> 00:56:21.330 align:middle line:90%


00:56:21.330 --> 00:56:22.630 align:middle line:90%
Did I do something wrong?

00:56:22.630 --> 00:56:25.300 align:middle line:90%
Oh I have to change it up here.

00:56:25.300 --> 00:56:26.370 align:middle line:90%
There we go.

00:56:26.370 --> 00:56:29.830 align:middle line:84%
Starting all over, hopefully,
I don't have any num correct.

00:56:29.830 --> 00:56:33.870 align:middle line:84%
Great, and that's just doing
all the feature extraction

00:56:33.870 --> 00:56:35.080 align:middle line:90%
of getting them in.

00:56:35.080 --> 00:56:37.380 align:middle line:84%
That's going to take
a little bit of time.

00:56:37.380 --> 00:56:39.570 align:middle line:84%
So we're going to
switch like they

00:56:39.570 --> 00:56:43.110 align:middle line:84%
do in the cooking shows to
the already baked version

00:56:43.110 --> 00:56:45.180 align:middle line:90%
where it's all done.

00:56:45.180 --> 00:56:47.400 align:middle line:90%
OK.

00:56:47.400 --> 00:56:48.990 align:middle line:90%
Oops.

00:56:48.990 --> 00:56:51.840 align:middle line:90%
Here we go.

00:56:51.840 --> 00:56:53.090 align:middle line:90%
Where do we go?

00:56:53.090 --> 00:56:55.660 align:middle line:90%


00:56:55.660 --> 00:56:58.900 align:middle line:84%
Yep, so the next couple
of things that you do,

00:56:58.900 --> 00:57:02.160 align:middle line:84%
you want to process
all your training set

00:57:02.160 --> 00:57:04.390 align:middle line:84%
and write it out
just like before,

00:57:04.390 --> 00:57:05.950 align:middle line:90%
process it and write it out.

00:57:05.950 --> 00:57:08.020 align:middle line:90%
Why is it taking so much longer?

00:57:08.020 --> 00:57:10.780 align:middle line:84%
Because we gave it a
whole bunch of features.

00:57:10.780 --> 00:57:13.240 align:middle line:84%
And some of them take
a long time to do,

00:57:13.240 --> 00:57:17.670 align:middle line:84%
like ones that have to do
with variability between parts

00:57:17.670 --> 00:57:22.020 align:middle line:84%
and parallel fifths, finding if
it's a multi-part thing and so

00:57:22.020 --> 00:57:23.460 align:middle line:90%
on.

00:57:23.460 --> 00:57:26.430 align:middle line:84%
But then the next
row ends up being

00:57:26.430 --> 00:57:28.180 align:middle line:90%
the exact same type of thing.

00:57:28.180 --> 00:57:29.380 align:middle line:90%
We have a majority learner.

00:57:29.380 --> 00:57:31.840 align:middle line:84%
We're going to still
use the knnLearner

00:57:31.840 --> 00:57:39.110 align:middle line:84%
and then try to see how well
it did and keep looking.

00:57:39.110 --> 00:57:42.350 align:middle line:84%
And again, the majority
learner is still 59%.

00:57:42.350 --> 00:57:43.970 align:middle line:90%
You hope that doesn't change.

00:57:43.970 --> 00:57:47.390 align:middle line:84%
And now, using all of
these extra features,

00:57:47.390 --> 00:57:53.710 align:middle line:84%
we've gotten our number from
87% all the way up to 61%.

00:57:53.710 --> 00:57:58.510 align:middle line:84%
So sometimes, just throwing
more feature extractors

00:57:58.510 --> 00:58:01.750 align:middle line:84%
at the problem is
just going to have you

00:58:01.750 --> 00:58:04.720 align:middle line:90%
wait longer at the computer.

00:58:04.720 --> 00:58:09.820 align:middle line:84%
Sometimes, thinking really
carefully about what you already

00:58:09.820 --> 00:58:13.220 align:middle line:84%
think the data might look
like is a pretty good thing,

00:58:13.220 --> 00:58:16.030 align:middle line:84%
and especially if you're
working with a small data

00:58:16.030 --> 00:58:18.430 align:middle line:84%
set where it's not
going to be able to do

00:58:18.430 --> 00:58:21.490 align:middle line:84%
the kinds of deep
neural network learning.

00:58:21.490 --> 00:58:23.890 align:middle line:84%
You have to keep
going through enough

00:58:23.890 --> 00:58:26.930 align:middle line:84%
to really build a
model of the set.

00:58:26.930 --> 00:58:33.640 align:middle line:84%
As some people say that
look, the neural networks

00:58:33.640 --> 00:58:35.770 align:middle line:90%
are getting better and better.

00:58:35.770 --> 00:58:39.260 align:middle line:84%
And we just need to
throw more data at it.

00:58:39.260 --> 00:58:41.950 align:middle line:84%
But imagine if
you wanted to have

00:58:41.950 --> 00:58:46.310 align:middle line:84%
a program that was automatically
reading handwriting.

00:58:46.310 --> 00:58:51.440 align:middle line:84%
And you gave the program all
these papers of handwriting.

00:58:51.440 --> 00:58:53.560 align:middle line:84%
And you just gave
them an audio file

00:58:53.560 --> 00:58:56.840 align:middle line:84%
of how it drops, how it sounds
when it drops and try to do it.

00:58:56.840 --> 00:58:59.870 align:middle line:84%
You're giving it kind of
the wrong data to learn on.

00:58:59.870 --> 00:59:03.020 align:middle line:84%
And so a lot of
the extractors now,

00:59:03.020 --> 00:59:06.010 align:middle line:84%
unless you're writing your own
or unless you're using really

00:59:06.010 --> 00:59:09.760 align:middle line:84%
musically sensitive ones,
you can save the computer

00:59:09.760 --> 00:59:14.290 align:middle line:84%
a lot of time by trying to
already say, hey, let's process

00:59:14.290 --> 00:59:18.880 align:middle line:84%
this as a symbols ahead of
time or something like that.

00:59:18.880 --> 00:59:23.660 align:middle line:84%
A lot of, by the way, state
of the art of symbolic music

00:59:23.660 --> 00:59:25.930 align:middle line:90%
machine learning things are--

00:59:25.930 --> 00:59:29.830 align:middle line:84%
you all remember
the piano roll where

00:59:29.830 --> 00:59:34.220 align:middle line:84%
we put things like this to show
length and stuff like that?

00:59:34.220 --> 00:59:38.230 align:middle line:84%
Yeah, well, it's converting
the entire musical score

00:59:38.230 --> 00:59:42.790 align:middle line:84%
to a piano roll, saving
that as an image,

00:59:42.790 --> 00:59:47.200 align:middle line:84%
and then using image
classifiers and image generators

00:59:47.200 --> 00:59:50.140 align:middle line:84%
to generate pieces that
look like the piano rolls

00:59:50.140 --> 00:59:51.770 align:middle line:90%
and then translating them back.

00:59:51.770 --> 00:59:56.060 align:middle line:84%
So I'm hoping that over
the next decade or so,

00:59:56.060 --> 00:59:58.750 align:middle line:84%
we can do better and
do some things that

00:59:58.750 --> 01:00:02.920 align:middle line:84%
help these neural
nets and classifiers

01:00:02.920 --> 01:00:05.530 align:middle line:84%
work with data that's
a little bit closer

01:00:05.530 --> 01:00:08.320 align:middle line:90%
to the original numbers.

01:00:08.320 --> 01:00:14.350 align:middle line:84%
OK, I have time for
just a little fun

01:00:14.350 --> 01:00:21.620 align:middle line:84%
thing with my favorite low
feature extraction thing.

01:00:21.620 --> 01:00:25.215 align:middle line:84%
So let me just show a
couple little things.

01:00:25.215 --> 01:00:26.410 align:middle line:90%
OK.

01:00:26.410 --> 01:00:28.220 align:middle line:90%
Yeah.

01:00:28.220 --> 01:00:31.310 align:middle line:84%
First off, the importance
of thinking about data sets

01:00:31.310 --> 01:00:34.700 align:middle line:84%
and ground truths,
this is, I think,

01:00:34.700 --> 01:00:37.430 align:middle line:84%
one of the first
pieces that showed

01:00:37.430 --> 01:00:40.460 align:middle line:84%
deep learning, the kind
of for people in the

01:00:40.460 --> 01:00:45.570 align:middle line:84%
know moment like ChatGPT has
been in the last year happened.

01:00:45.570 --> 01:00:49.580 align:middle line:84%
I think it was about 10 years
ago when AlphaZero and AlphaGo

01:00:49.580 --> 01:00:54.320 align:middle line:84%
suddenly became the world's
greatest go and chess players.

01:00:54.320 --> 01:00:56.210 align:middle line:84%
And so a lot of people
think, well, this

01:00:56.210 --> 01:00:59.360 align:middle line:84%
was with generalized knowledge,
no rules being taught

01:00:59.360 --> 01:01:02.300 align:middle line:90%
except for legal move or not.

01:01:02.300 --> 01:01:07.460 align:middle line:84%
But one of the things to think
about the difference between

01:01:07.460 --> 01:01:10.670 align:middle line:84%
a lot of the things that they
were being trained on and what

01:01:10.670 --> 01:01:14.940 align:middle line:84%
you have is that AlphaZero, the
chess playing computer, played,

01:01:14.940 --> 01:01:18.770 align:middle line:84%
what was it, 700,000 games or a
million games or something like

01:01:18.770 --> 01:01:19.560 align:middle line:90%
that.

01:01:19.560 --> 01:01:23.280 align:middle line:84%
And at the end of every
single game it played,

01:01:23.280 --> 01:01:26.940 align:middle line:84%
it got perfect feedback
on how it did--

01:01:26.940 --> 01:01:30.200 align:middle line:84%
you won, you lost, you tied,
you won, you lost, you tied.

01:01:30.200 --> 01:01:33.230 align:middle line:84%
A lot of the things that we're
interested in doing with music

01:01:33.230 --> 01:01:36.500 align:middle line:84%
like music
recommendation or things

01:01:36.500 --> 01:01:39.180 align:middle line:84%
like this, predicting
what's the next great hit,

01:01:39.180 --> 01:01:42.780 align:middle line:84%
first off, we don't
have that correct data.

01:01:42.780 --> 01:01:45.270 align:middle line:84%
Maybe what's the Billboard
chart or something like that?

01:01:45.270 --> 01:01:48.525 align:middle line:84%
But for how good was this
piece, because it's going

01:01:48.525 --> 01:01:49.650 align:middle line:90%
to be different every time.

01:01:49.650 --> 01:01:51.500 align:middle line:84%
It's going to take
us three minutes

01:01:51.500 --> 01:01:54.543 align:middle line:84%
to listen to if it's
computer generating a song.

01:01:54.543 --> 01:01:56.210 align:middle line:84%
And then we're going
to give it feedback

01:01:56.210 --> 01:01:59.010 align:middle line:84%
that we might feel differently
about that piece tomorrow.

01:01:59.010 --> 01:02:00.800 align:middle line:84%
So we don't give
perfect feedback.

01:02:00.800 --> 01:02:02.490 align:middle line:90%
And it takes a long time.

01:02:02.490 --> 01:02:05.660 align:middle line:84%
So this is one of the
reasons I like working

01:02:05.660 --> 01:02:07.920 align:middle line:90%
with some of the older things.

01:02:07.920 --> 01:02:08.940 align:middle line:90%
OK, we'll go back.

01:02:08.940 --> 01:02:10.790 align:middle line:90%
Great.

01:02:10.790 --> 01:02:12.810 align:middle line:90%
I don't think I presented this.

01:02:12.810 --> 01:02:14.220 align:middle line:90%
No, I presented in other place.

01:02:14.220 --> 01:02:17.000 align:middle line:84%
So this is what we'll end
for the last 10 minutes

01:02:17.000 --> 01:02:20.060 align:middle line:84%
and talking about some of
the interesting things that

01:02:20.060 --> 01:02:22.580 align:middle line:90%
come out with features.

01:02:22.580 --> 01:02:26.760 align:middle line:84%
So how would you distinguish
choral music from Bach

01:02:26.760 --> 01:02:28.190 align:middle line:90%
from Monteverdi?

01:02:28.190 --> 01:02:32.400 align:middle line:84%
So we're doing a lot
of Bach in this class.

01:02:32.400 --> 01:02:34.650 align:middle line:84%
But we'll get a little
bit more into the ear.

01:02:34.650 --> 01:02:36.990 align:middle line:90%
Here's Bach.

01:02:36.990 --> 01:02:39.593 align:middle line:90%
[MUSIC PLAYING]

01:02:39.593 --> 01:02:40.440 align:middle line:90%


01:02:40.440 --> 01:02:41.180 align:middle line:90%
So this is Bach.

01:02:41.180 --> 01:02:51.440 align:middle line:90%


01:02:51.440 --> 01:02:54.890 align:middle line:84%
And so then we'll switch to one
of the other great composers

01:02:54.890 --> 01:03:00.020 align:middle line:84%
about 100 years before
Bach, Claudio Monteverdi.

01:03:00.020 --> 01:03:03.949 align:middle line:84%
And so, some of you, this might
be the first time you hear him.

01:03:03.949 --> 01:03:06.943 align:middle line:90%
[NO AUDIO]

01:03:06.943 --> 01:03:27.930 align:middle line:90%


01:03:27.930 --> 01:03:30.515 align:middle line:84%
One second with the Back
again so we can get back.

01:03:30.515 --> 01:03:35.010 align:middle line:90%


01:03:35.010 --> 01:03:36.390 align:middle line:90%
Great.

01:03:36.390 --> 01:03:39.210 align:middle line:84%
What's something
you heard different

01:03:39.210 --> 01:03:42.512 align:middle line:90%
between the two of them?

01:03:42.512 --> 01:03:44.220 align:middle line:84%
STUDENT: Monteverdi
was a bit more somber

01:03:44.220 --> 01:03:45.413 align:middle line:90%
with more of the minor keys.

01:03:45.413 --> 01:03:47.830 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT:
OK, somber, more minor keys.

01:03:47.830 --> 01:03:49.140 align:middle line:90%
We could do a key detection.

01:03:49.140 --> 01:03:49.640 align:middle line:90%
Jonathan.

01:03:49.640 --> 01:03:53.040 align:middle line:90%


01:03:53.040 --> 01:03:55.260 align:middle line:84%
STUDENT: I mean, Bach
had sounded like there

01:03:55.260 --> 01:03:56.710 align:middle line:90%
were more people singing.

01:03:56.710 --> 01:03:58.470 align:middle line:90%
But it's hard to tell.

01:03:58.470 --> 01:04:00.637 align:middle line:84%
MICHAEL SCOTT ASATO CUTHBERT:
Yeah, but it could be.

01:04:00.637 --> 01:04:03.250 align:middle line:84%
It could be more people,
fuller than good.

01:04:03.250 --> 01:04:05.050 align:middle line:90%
Yeah.

01:04:05.050 --> 01:04:07.560 align:middle line:84%
STUDENT: Bach is
more together where

01:04:07.560 --> 01:04:11.408 align:middle line:84%
Monteverdi has a lot of voices
going off doing kind of thing.

01:04:11.408 --> 01:04:13.450 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: Bach more together,

01:04:13.450 --> 01:04:15.730 align:middle line:84%
homophonic maybe, Monteverdi
doing their own thing.

01:04:15.730 --> 01:04:16.230 align:middle line:90%
Good.

01:04:16.230 --> 01:04:17.270 align:middle line:90%
One last one.

01:04:17.270 --> 01:04:22.050 align:middle line:90%


01:04:22.050 --> 01:04:24.160 align:middle line:84%
OK, that's a pretty
good place to start.

01:04:24.160 --> 01:04:29.820 align:middle line:84%
So I threw everything
in, all the kitchen

01:04:29.820 --> 01:04:33.360 align:middle line:84%
sink of feature
extractors and got

01:04:33.360 --> 01:04:41.850 align:middle line:84%
to see what a particular
algorithm did that seemed

01:04:41.850 --> 01:04:43.390 align:middle line:90%
to work pretty well.

01:04:43.390 --> 01:04:46.390 align:middle line:84%
And the first,
here's a little quiz.

01:04:46.390 --> 01:04:49.380 align:middle line:84%
It's one of the few quizzes
that elementary school students

01:04:49.380 --> 01:04:51.995 align:middle line:90%
do better than adults at.

01:04:51.995 --> 01:04:53.620 align:middle line:84%
So let's see if we
can figure this out.

01:04:53.620 --> 01:04:56.808 align:middle line:90%
7802 is 3.

01:04:56.808 --> 01:04:59.050 align:middle line:90%
1065 is 2.

01:04:59.050 --> 01:05:02.010 align:middle line:84%
If you've seen it before,
then don't answer.

01:05:02.010 --> 01:05:05.910 align:middle line:90%
998 is 4.

01:05:05.910 --> 01:05:14.340 align:middle line:90%
And 1773 is 0.

01:05:14.340 --> 01:05:29.050 align:middle line:84%
If you're new to this, 1, 2, 3,
3 circles, 1 circle, 2 circles,

01:05:29.050 --> 01:05:31.960 align:middle line:84%
1, 2, 3, 4 circles
and no circles.

01:05:31.960 --> 01:05:35.220 align:middle line:84%
So I bring that up to say that
sometimes the computer is going

01:05:35.220 --> 01:05:40.107 align:middle line:84%
to be looking at things that
are really, really far out

01:05:40.107 --> 01:05:41.440 align:middle line:90%
and trying to figure out things.

01:05:41.440 --> 01:05:44.820 align:middle line:84%
So there's all these things
that we could be looking at.

01:05:44.820 --> 01:05:49.110 align:middle line:84%
I'll bet that the proportion of
instruments that are electronic

01:05:49.110 --> 01:05:52.030 align:middle line:84%
isn't going to help with
Bach versus Monteverdi.

01:05:52.030 --> 01:05:56.190 align:middle line:84%
But one of the things I like
about a particular classifier

01:05:56.190 --> 01:05:59.860 align:middle line:84%
that is not close to
the state of the art

01:05:59.860 --> 01:06:01.780 align:middle line:84%
or to the getting
the best results.

01:06:01.780 --> 01:06:05.220 align:middle line:90%
But this tree learner can--

01:06:05.220 --> 01:06:09.370 align:middle line:84%
unlike being a black box, it can
actually show what the path--

01:06:09.370 --> 01:06:11.730 align:middle line:84%
so it's of a decision
tree, branching tree--

01:06:11.730 --> 01:06:13.420 align:middle line:90%
it took to get there.

01:06:13.420 --> 01:06:17.770 align:middle line:84%
So here's how it
can say, to begin,

01:06:17.770 --> 01:06:23.380 align:middle line:84%
if the note f sharp below
middle C is used more than 14%

01:06:23.380 --> 01:06:26.140 align:middle line:84%
of the time, the
piece is by Bach.

01:06:26.140 --> 01:06:31.700 align:middle line:84%
Otherwise, if the top number in
the time signature is 3 or less,

01:06:31.700 --> 01:06:33.670 align:middle line:90%
it is by Bach.

01:06:33.670 --> 01:06:36.358 align:middle line:90%
Otherwise-- I love this one.

01:06:36.358 --> 01:06:38.650 align:middle line:84%
If the distance between the
highest note in the soprano

01:06:38.650 --> 01:06:40.390 align:middle line:84%
and the lowest
note of the bass is

01:06:40.390 --> 01:06:44.150 align:middle line:84%
less than 2 octaves and a
minor sixth, then it's by Bach.

01:06:44.150 --> 01:06:45.740 align:middle line:84%
And then there's
three more things.

01:06:45.740 --> 01:06:47.920 align:middle line:84%
We get to the final
one, count the number

01:06:47.920 --> 01:06:49.430 align:middle line:90%
of times each note is used.

01:06:49.430 --> 01:06:51.170 align:middle line:84%
Find the note that is
used the most often

01:06:51.170 --> 01:06:53.170 align:middle line:84%
and the note that is used
the second most often.

01:06:53.170 --> 01:06:56.260 align:middle line:84%
If the second most often used
note is used less than 97%

01:06:56.260 --> 01:07:00.430 align:middle line:84%
as often as the most commonly
used note, the piece is by Bach.

01:07:00.430 --> 01:07:02.210 align:middle line:90%
Otherwise, it's by Monteverdi.

01:07:02.210 --> 01:07:07.420 align:middle line:84%
And this worked
with 99% accuracy.

01:07:07.420 --> 01:07:13.030 align:middle line:84%
What I loved about this is that
this was the first decision

01:07:13.030 --> 01:07:14.210 align:middle line:90%
to distinguish.

01:07:14.210 --> 01:07:19.330 align:middle line:84%
And I was just baffled by it
until I realized, well, OK, Bach

01:07:19.330 --> 01:07:23.030 align:middle line:84%
has more pieces in sharp
keys than Monteverdi is.

01:07:23.030 --> 01:07:24.590 align:middle line:90%
OK, that would make sense.

01:07:24.590 --> 01:07:29.290 align:middle line:84%
Monteverdi was mostly hovering
around no sharps or flats or one

01:07:29.290 --> 01:07:30.410 align:middle line:90%
flat assigned.

01:07:30.410 --> 01:07:34.060 align:middle line:84%
But then it's minor, and there's
raised leading tones and stuff

01:07:34.060 --> 01:07:35.480 align:middle line:90%
like that, so why not?

01:07:35.480 --> 01:07:40.180 align:middle line:84%
Well, the leading tone tends to
get raised in the melody, which

01:07:40.180 --> 01:07:42.250 align:middle line:90%
tends to be in a higher voice.

01:07:42.250 --> 01:07:46.180 align:middle line:84%
The middle area,
tenor, will only

01:07:46.180 --> 01:07:48.860 align:middle line:84%
appear as f sharp if the key
signature is already f sharp.

01:07:48.860 --> 01:07:51.410 align:middle line:84%
So it's a way of learning
some things like this.

01:07:51.410 --> 01:07:56.530 align:middle line:84%
And this particular one ended up
being garbage in, garbage out,

01:07:56.530 --> 01:08:00.890 align:middle line:84%
that Monteverdi doesn't
using modern time signatures.

01:08:00.890 --> 01:08:06.800 align:middle line:84%
And so the people who encoded
this chose never to use 2-4,

01:08:06.800 --> 01:08:11.510 align:middle line:84%
always put it into 4-4, because
it also weren't bar lines.

01:08:11.510 --> 01:08:12.830 align:middle line:90%
So you could decide how long.

01:08:12.830 --> 01:08:16.540 align:middle line:84%
So this ended up being
that the computer learned

01:08:16.540 --> 01:08:19.160 align:middle line:84%
not the difference between
Bach and Monteverdi

01:08:19.160 --> 01:08:22.240 align:middle line:84%
but the difference between
Bach's editor, modern editor,

01:08:22.240 --> 01:08:24.560 align:middle line:90%
and Monteverdi modern editor.

01:08:24.560 --> 01:08:27.279 align:middle line:84%
I have lost the
reference, but I have

01:08:27.279 --> 01:08:32.170 align:middle line:84%
been told about an
audio classifier that

01:08:32.170 --> 01:08:34.160 align:middle line:90%
tried to classify by genre.

01:08:34.160 --> 01:08:37.840 align:middle line:84%
And it was doing very, very
well until it turns out

01:08:37.840 --> 01:08:41.319 align:middle line:84%
that different genres of music
used different microphones

01:08:41.319 --> 01:08:42.439 align:middle line:90%
in general.

01:08:42.439 --> 01:08:44.470 align:middle line:84%
And it was picking
up the difference

01:08:44.470 --> 01:08:45.830 align:middle line:90%
between the microphones.

01:08:45.830 --> 01:08:49.460 align:middle line:84%
So if you sing country music
on a hip hop microphone,

01:08:49.460 --> 01:08:51.910 align:middle line:90%
it would classify as hip hop.

01:08:51.910 --> 01:08:54.010 align:middle line:84%
So all of these
things, we need to be

01:08:54.010 --> 01:08:58.840 align:middle line:84%
really careful about what's
going on with the potential

01:08:58.840 --> 01:09:00.140 align:middle line:90%
for classification.

01:09:00.140 --> 01:09:04.450 align:middle line:84%
And so this is where I
like this old school--

01:09:04.450 --> 01:09:07.645 align:middle line:84%
imagine this as a tree diagram
of things going left and right,

01:09:07.645 --> 01:09:09.020 align:middle line:84%
I guess if you
turn it sideways--

01:09:09.020 --> 01:09:13.779 align:middle line:84%
these old school feature
classifiers a little bit just

01:09:13.779 --> 01:09:18.920 align:middle line:84%
to check what might be happening
in the latest black box.

01:09:18.920 --> 01:09:24.450 align:middle line:84%
So you guys did a
remarkable stamina.

01:09:24.450 --> 01:09:29.279 align:middle line:84%
You got through the zombie of
music eating feature extraction.

01:09:29.279 --> 01:09:34.229 align:middle line:84%
And I hope that some people
will choose to find--

01:09:34.229 --> 01:09:37.910 align:middle line:84%
if you find this to be
helpful in doing something

01:09:37.910 --> 01:09:41.550 align:middle line:84%
in your final project, you now
have some of the tools to do it.

01:09:41.550 --> 01:09:45.630 align:middle line:84%
On Friday, we'll continue
with searching and similarity,

01:09:45.630 --> 01:09:49.250 align:middle line:84%
and will be giving the
first 15 minutes explaining

01:09:49.250 --> 01:09:50.760 align:middle line:90%
what he's doing at MIT.

01:09:50.760 --> 01:09:53.029 align:middle line:84%
He's a professor
of computer science

01:09:53.029 --> 01:09:57.300 align:middle line:84%
and what he's been doing
with music on his work.

01:09:57.300 --> 01:09:59.343 align:middle line:90%
So there'll be a start.

01:09:59.343 --> 01:10:01.260 align:middle line:84%
And then I'll continue
with some other things.

01:10:01.260 --> 01:10:03.350 align:middle line:90%
Great, thanks.

01:10:03.350 --> 01:10:14.000 align:middle line:90%