Skip to content

Commit

Permalink
Added noise to the in-class data set.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdrangan committed Feb 12, 2019
1 parent 2a18ae7 commit 8456f2e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Binary file modified lectures/Lect05_Lasso.pdf
Binary file not shown.
Binary file modified lectures/Lect05_Lasso.pptx
Binary file not shown.
19 changes: 10 additions & 9 deletions unit05_lasso/lasso_in_class.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# LASSO Regression In-Class Exercise\n",
"\n",
"In this exercise, we will see how to use LASSO for pitch detection in audio.\n",
"In this exercise, we will see how to use LASSO for pitch detection and noise removal in audio.\n",
"\n",
"We load the following packages."
]
Expand All @@ -26,14 +26,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load the data\n",
"## Load the Data\n",
"\n",
"The data is taken from a sample of about 20~ms of audio from a viola. I have already pre-processed the data. You can load it with the following command. The value `t` is the time (in seconds) and `y` is the sample of audio (this is a mono recording)."
"The data is taken from a sample of about 20 ms of audio from a viola. I have already pre-processed the data. You can load it with the following command. The value `t` is the time (in seconds) and `y` is the sample of audio (this is a mono recording). Noise has been artificially added to the sample."
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -85,11 +85,14 @@
"source": [
"## Creating Features for a Sinusoidal Model\n",
"\n",
"We will try to fit a model of the\n",
"We will try to fit a model of the form:\n",
"\n",
" y[i] = \\sum_j a[j]*sin(2*pi*freq[j]*t[i]) + b[j]*cos(2*pi*freq[j]*t[i])\n",
"\n",
"That is, `y[i]` is a sum of sinusoids. This is a common model for audio signals.\n",
"That is, `y[i]` is a sum of sinusoids. This is a common model for audio signals since an instrument, such as a viola, produces discrete tones. \n",
"\n",
"This model is non-linear in the frequency parameters. So, instead of trying to find the frequencies, we will fix a large number of frequencies and then require that the coefficients `a[j]` and `b[j]` are mostly sparse. \n",
"\n",
"We will use the following vector of frequencies. This vector includes frequencies on the muscial scale as well as frequencies between the musical notes."
]
},
Expand Down Expand Up @@ -175,9 +178,7 @@
"We can now use LASSO regression to find the model\n",
"* Use LASSO regression with `alpha=500` to fit the model. \n",
"* Find the R^2-score on the test data.\n",
"* Plot the predicted value of `y` for `t in [0,0.02]`.\n",
"* \n",
"\n"
"* Plot the predicted value of `y` for `t in [0,0.02]`."
]
},
{
Expand Down
Binary file modified unit05_lasso/viola_sample.p
Binary file not shown.

0 comments on commit 8456f2e

Please sign in to comment.