text: { "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 }
explanation: The document is a Jupyter notebook that serves as an introduction to Python programming and Jupyter notebooks for a course on Statistical Machine Learning. It contains several sections with questions and placeholders for solutions, covering topics such as random variables, discrete probabilities, linear algebra, and calculus. The notebook also includes sections on Python programming concepts and the use of Jupyter notebooks.
distilabel_metadata.content: Evaluate the user given text extract and determine if it contains a math question and optionally and answer to this question.
  
  Output rules:
  
  1. Briefly describe the document and mention if it contains a question or a question and answer.
  2. Finalize the output with: Label: no-question,question,question-and-answer,multiple-question,multiple-question-and-answer
distilabel_metadata.role: system
distilabel_metadata.content: { "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 }
distilabel_metadata.role: user
distilabel_metadata.raw_output_q_a_detector_0: The document is a Jupyter notebook that serves as an introduction to Python programming and Jupyter notebooks for a course on Statistical Machine Learning. It contains several sections with questions and placeholders for solutions, covering topics such as random variables, discrete probabilities, linear algebra, and calculus. The notebook also includes sections on Python programming concepts and the use of Jupyter notebooks.
  
  Label: multiple-question-and-answer