diff --git a/02_lab/lab1_regression_faces.ipynb b/02_lab/lab1_regression_faces.ipynb index 22ccf3b..dc34349 100644 --- a/02_lab/lab1_regression_faces.ipynb +++ b/02_lab/lab1_regression_faces.ipynb @@ -3,7 +3,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "import numpy as np\n", @@ -24,7 +26,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from sklearn.datasets import fetch_olivetti_faces\n", @@ -34,7 +38,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# @this code showcases matplotlib subplots. The syntax is: plt.subplot(height, width, index_starting_from_1)\n", @@ -56,12 +62,14 @@ "\n", "Let's solve the face reconstruction problem: given left halves of facex __(X)__, our algorithm shall predict the right half __(y)__. Our first step is to slice the photos into X and y using slices.\n", "\n", + "__Slices in numpy:__\n", "* In regular python, slice looks roughly like this: `a[2:5]` _(select elements from 2 to 5)_\n", "* Numpy allows you to slice N-dimensional arrays along each dimension: [image_index, height, width]\n", " * `data[:10]` - Select first 10 images\n", " * `data[:, :10]` - For all images, select a horizontal stripe 10 pixels high at the top of the image\n", " * `data[10:20, :, -25:-15]` - Take images [10, 11, ..., 19], for each image select a _vetrical stripe_ of width 10 pixels, 15 pixels away from the _right_ side.\n", "\n", + "__Your task:__\n", "\n", "Let's use slices to select all __left image halves as X__ and all __right halves as y__." ] @@ -69,7 +77,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# select left half of each face as X, right half as Y\n", @@ -80,7 +90,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# If you did everything right, you're gonna see left half-image and right half-image drawn separately in natural order\n", @@ -95,7 +107,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def glue(left_half,right_half):\n", @@ -119,7 +133,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from sklearn.model_selection import train_test_split\n", @@ -133,7 +149,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from sklearn.linear_model import LinearRegression\n", @@ -151,7 +169,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from sklearn.metrics import mean_squared_error\n", @@ -163,7 +183,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# Train predictions\n", @@ -177,7 +199,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# Test predictions\n", @@ -247,7 +271,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ ""