{ "cells": [ { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "# Introduction to Jupyter notebooks" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "###### COMP4670/8600 - Introduction to Statistical Machine Learning - Tutorial 1A" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "The first tutorial will introduce the *basic elements* for writing Python programs, and using \n", "[Jupyter notebooks](http://jupyter.org/). All tutorials and assignments will be done using this format.\n", "\n", "Due to the wide variety of backgrounds that students may have, it is worth recalling some mathematics and statistics that we build upon in this course." ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "## Basic knowledge\n", "\n", "**IMPORTANT: When using mathematical formulas, provide the precise name for each component.**\n", "\n", "$\\newcommand{\\RR}{\\mathbb{R}}$\n", "\n", "\n", "### Random variables\n", "\n", "Write down the definitions of the following entities, and provide a simple example to illustrate.\n", "\n", "1. The expectation of a function $f$ with respect to a\n", " * continuous random variable $X$\n", " * discrete random variable $X$\n", "2. The variance of a random variable $X$.\n", "3. Independence of two random variables $X$ and $Y$" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Solution description" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Discrete probabilities\n", "\n", "For discrete random variables $X$ and $Y$, define the following, and show an example of how it applies to the example below.\n", "\n", "| $p(\\mathbf{X},\\mathbf{Y})$ | X=a | X=b | X=c | X=d | X=e |\n", "|:--------------------------:|:--:|:--:|:--:|:--:|:--:|\n", "| **Y** = red |0.2 |0.1 |0.1 |0.01|0.04|\n", "| **Y** = green |0.08|0.07|0.01|0.05|0.05|\n", "| **Y** = blue |0.01|0.01|0.07|0.05|0.15|\n", "\n", "1. The sum rule of probability theory\n", "2. The product rule of probability theory\n", "3. Independence of two random variables $X$ and $Y$" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Solution description" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Linear algebra\n", "\n", "Write down the definitions, being careful to specify conditions (if needed) when they exist.\n", "\n", "1. The eigenvector decomposition of a matrix $C$.\n", "2. The solution of a linear system of equations $Ax=b$." ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Solution description" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Calculus\n", "\n", "Compute the gradient of the following function $f:\\RR\\to\\RR$\n", "$$\n", "f(x) = \\frac{1}{1 + \\exp(x^2)}\n", "$$\n", "What would the gradient be if $x$ was two dimensional (that is $f:\\RR^2\\to\\RR$), and we let $x^2$ be the squared Euclidean norm, $\\|x\\|^2$?" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Solution description" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "## Python and Programming for Machine Learning" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "*If you already know Python and Jupyter notebooks well, please work on Tutorial 1B \"Linear Algebra and Optimisation\".*\n", "\n", "The introduction will focus on the concepts necessary for writing small programs in Python for the purpose of Machine Learning. That means, we expect a user of the code will be a reasonable knowledgeable person. Therefore, we can *skip* most of the code a robust system would have to contain in order to *check* the input types, *verify* the input parameter ranges, and *make sure* that really nothing can go wrong when somebody else is using the code.\n", "Having said this, you are nevertheless encouraged to include some sanity tests into your code to avoid making simple errors which can cost you a lot of time to find.\n", "Some of the Python concepts discussed in the tutorial will be\n", "- Data types (bool, int, float, str, list, tuple, set, dict)\n", "- Operators\n", "- Data flow\n", "- Functions\n", "- Classes and objects\n", "- Modules and how to use them\n", "\n", "**We will be using [Python3](https://wiki.python.org/moin/Python2orPython3) in this course**.\n", "\n", "Some resources:\n", "- [CodeAcademy](http://www.codecademy.com/en/tracks/python) gives a step by step introduction to python\n", "- [How to think like a computer scientist](http://interactivepython.org/courselib/static/thinkcspy/index.html) does what it says, using Python\n", "\n", "## Installation\n", "\n", "The easiest way to get a working Python environment is using one of the following collections:\n", "- [Enthought canopy](https://store.enthought.com/)\n", "- [Anaconda](http://continuum.io/downloads)\n", "\n", "It is also not too difficult to install python using your favourite package manager and then use [conda](http://conda.pydata.org/docs/) or [pip](http://en.wikipedia.org/wiki/Pip_%28package_manager%29) to manage python packages." ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "## Jupyter Notebooks" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "**To work on a worksheet or assignment, download the notebook and edit it locally.**\n", "\n", "[Jupyter notebooks](http://jupyter.org/) provide a convenient browser based environment for data analysis in a literate programming environment. The descriptive parts of the notebook implements an enhanced version of [markdown](http://daringfireball.net/projects/markdown/syntax), which allows the use of [LaTeX](http://www.latex-project.org/) for rendering equations.\n", "1. Descriptive notes\n", " - Markdown\n", " - LaTeX\n", "2. Computational code\n", " - numerical python\n", " * numpy\n", " * scipy\n", " - matplotlib\n", " \n", "To use a notebook locally:\n", "bash\n", "jupyter notebook name_of_file.ipynb\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "# Markdown and LaTeX\n", "\n", "In addition to lists and links which are already shown above, \n", "tables are also nice and easy\n", "\n", "|Title | Middle| Left aligned | Right aligned |\n", "|------|:-----:|:-----|--:|\n", "|Monday|10:00|Sunny|*30*|\n", "|Thursday|12:32|Rain|*22.3*|\n", "\n", "It is also easy to typeset good looking equations inline, such as $f(x) = x^2$, or on a line by itself.\n", "\$$\n", " g(x) = \\sum_{i=1}^n \\frac{\\prod_{j=1}^d y_j \\sqrt{3x_i^4}}{f(x_i)}\n", "\$$\n", "If you use a symbol often, you can define it at the top of a document as follows (look at source), and use it in equations.\n", "\n", "$\\newcommand{\\amazing}{\\sqrt{3x_i^4}}$\n", "\n", "\$$\n", " h(x) = \\sum_{i=1}^n \\amazing\n", "\$$\n", "\n", "## Computational code\n", "\n", "Setting up python environment ([do not use pylab](http://carreau.github.io/posts/10-No-PyLab-Thanks.html))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import scipy as sp\n", "\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "Some resources:\n", "* [Tentative NumPy Tutorial](http://wiki.scipy.org/Tentative_NumPy_Tutorial)\n", "* [SciPy Tutorial](http://docs.scipy.org/doc/scipy/reference/tutorial/)\n", "* [Matplotlib PyPlot Tutorial](http://matplotlib.org/1.3.1/users/pyplot_tutorial.html)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "deletable": true, "editable": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.2" } }, "nbformat": 4, "nbformat_minor": 0 }
The content structure consists of a series of markdown cells that introduce Jupyter notebooks, provide mathematical questions and prompts, and describe solutions. There are also code cells for setting up the Python environment.
multiple_questions

the text contains multiple mathematical questions and prompts, but no answers are provided within the text. the questions are related to random variables, discrete probabilities, linear algebra, and calculus.
Given a text passage, determine:
    1. If it contains a mathematical question (including word problems or calculations)
    2. If an answer to that mathematical question is provided in the text

First, describe the content structure you found in 1-2 sentences.

Then provide your analysis in the following format:
TYPE: <one of the following values>
- NO_QUESTION
- SINGLE_QUESTION
- SINGLE_QUESTION_WITH_ANSWER
- MULTIPLE_QUESTIONS
- MULTIPLE_QUESTIONS_WITH_ANSWERS
system
{ "cells": [ { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "# Introduction to Jupyter notebooks" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "###### COMP4670/8600 - Introduction to Statistical Machine Learning - Tutorial 1A" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "The first tutorial will introduce the *basic elements* for writing Python programs, and using \n", "[Jupyter notebooks](http://jupyter.org/). All tutorials and assignments will be done using this format.\n", "\n", "Due to the wide variety of backgrounds that students may have, it is worth recalling some mathematics and statistics that we build upon in this course." ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "## Basic knowledge\n", "\n", "**IMPORTANT: When using mathematical formulas, provide the precise name for each component.**\n", "\n", "$\\newcommand{\\RR}{\\mathbb{R}}$\n", "\n", "\n", "### Random variables\n", "\n", "Write down the definitions of the following entities, and provide a simple example to illustrate.\n", "\n", "1. The expectation of a function $f$ with respect to a\n", " * continuous random variable $X$\n", " * discrete random variable $X$\n", "2. The variance of a random variable $X$.\n", "3. Independence of two random variables $X$ and $Y$" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Solution description" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Discrete probabilities\n", "\n", "For discrete random variables $X$ and $Y$, define the following, and show an example of how it applies to the example below.\n", "\n", "| $p(\\mathbf{X},\\mathbf{Y})$ | X=a | X=b | X=c | X=d | X=e |\n", "|:--------------------------:|:--:|:--:|:--:|:--:|:--:|\n", "| **Y** = red |0.2 |0.1 |0.1 |0.01|0.04|\n", "| **Y** = green |0.08|0.07|0.01|0.05|0.05|\n", "| **Y** = blue |0.01|0.01|0.07|0.05|0.15|\n", "\n", "1. The sum rule of probability theory\n", "2. The product rule of probability theory\n", "3. Independence of two random variables $X$ and $Y$" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Solution description" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Linear algebra\n", "\n", "Write down the definitions, being careful to specify conditions (if needed) when they exist.\n", "\n", "1. The eigenvector decomposition of a matrix $C$.\n", "2. The solution of a linear system of equations $Ax=b$." ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Solution description" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Calculus\n", "\n", "Compute the gradient of the following function $f:\\RR\\to\\RR$\n", "$$\n", "f(x) = \\frac{1}{1 + \\exp(x^2)}\n", "$$\n", "What would the gradient be if $x$ was two dimensional (that is $f:\\RR^2\\to\\RR$), and we let $x^2$ be the squared Euclidean norm, $\\|x\\|^2$?" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Solution description" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "## Python and Programming for Machine Learning" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "*If you already know Python and Jupyter notebooks well, please work on Tutorial 1B \"Linear Algebra and Optimisation\".*\n", "\n", "The introduction will focus on the concepts necessary for writing small programs in Python for the purpose of Machine Learning. That means, we expect a user of the code will be a reasonable knowledgeable person. Therefore, we can *skip* most of the code a robust system would have to contain in order to *check* the input types, *verify* the input parameter ranges, and *make sure* that really nothing can go wrong when somebody else is using the code.\n", "Having said this, you are nevertheless encouraged to include some sanity tests into your code to avoid making simple errors which can cost you a lot of time to find.\n", "Some of the Python concepts discussed in the tutorial will be\n", "- Data types (bool, int, float, str, list, tuple, set, dict)\n", "- Operators\n", "- Data flow\n", "- Functions\n", "- Classes and objects\n", "- Modules and how to use them\n", "\n", "**We will be using [Python3](https://wiki.python.org/moin/Python2orPython3) in this course**.\n", "\n", "Some resources:\n", "- [CodeAcademy](http://www.codecademy.com/en/tracks/python) gives a step by step introduction to python\n", "- [How to think like a computer scientist](http://interactivepython.org/courselib/static/thinkcspy/index.html) does what it says, using Python\n", "\n", "## Installation\n", "\n", "The easiest way to get a working Python environment is using one of the following collections:\n", "- [Enthought canopy](https://store.enthought.com/)\n", "- [Anaconda](http://continuum.io/downloads)\n", "\n", "It is also not too difficult to install python using your favourite package manager and then use [conda](http://conda.pydata.org/docs/) or [pip](http://en.wikipedia.org/wiki/Pip_%28package_manager%29) to manage python packages." ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "## Jupyter Notebooks" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "**To work on a worksheet or assignment, download the notebook and edit it locally.**\n", "\n", "[Jupyter notebooks](http://jupyter.org/) provide a convenient browser based environment for data analysis in a literate programming environment. The descriptive parts of the notebook implements an enhanced version of [markdown](http://daringfireball.net/projects/markdown/syntax), which allows the use of [LaTeX](http://www.latex-project.org/) for rendering equations.\n", "1. Descriptive notes\n", " - Markdown\n", " - LaTeX\n", "2. Computational code\n", " - numerical python\n", " * numpy\n", " * scipy\n", " - matplotlib\n", " \n", "To use a notebook locally:\n", "bash\n", "jupyter notebook name_of_file.ipynb\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "# Markdown and LaTeX\n", "\n", "In addition to lists and links which are already shown above, \n", "tables are also nice and easy\n", "\n", "|Title | Middle| Left aligned | Right aligned |\n", "|------|:-----:|:-----|--:|\n", "|Monday|10:00|Sunny|*30*|\n", "|Thursday|12:32|Rain|*22.3*|\n", "\n", "It is also easy to typeset good looking equations inline, such as $f(x) = x^2$, or on a line by itself.\n", "\$$\n", " g(x) = \\sum_{i=1}^n \\frac{\\prod_{j=1}^d y_j \\sqrt{3x_i^4}}{f(x_i)}\n", "\$$\n", "If you use a symbol often, you can define it at the top of a document as follows (look at source), and use it in equations.\n", "\n", "$\\newcommand{\\amazing}{\\sqrt{3x_i^4}}$\n", "\n", "\$$\n", " h(x) = \\sum_{i=1}^n \\amazing\n", "\$$\n", "\n", "## Computational code\n", "\n", "Setting up python environment ([do not use pylab](http://carreau.github.io/posts/10-No-PyLab-Thanks.html))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import scipy as sp\n", "\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "Some resources:\n", "* [Tentative NumPy Tutorial](http://wiki.scipy.org/Tentative_NumPy_Tutorial)\n", "* [SciPy Tutorial](http://docs.scipy.org/doc/scipy/reference/tutorial/)\n", "* [Matplotlib PyPlot Tutorial](http://matplotlib.org/1.3.1/users/pyplot_tutorial.html)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "deletable": true, "editable": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.2" } }, "nbformat": 4, "nbformat_minor": 0 }
user
The content structure consists of a series of markdown cells that introduce Jupyter notebooks, provide mathematical questions and prompts, and describe solutions. There are also code cells for setting up the Python environment.

TYPE: MULTIPLE_QUESTIONS

The text contains multiple mathematical questions and prompts, but no answers are provided within the text. The questions are related to random variables, discrete probabilities, linear algebra, and calculus.