From c9bd48a1b2bbb79b000b5c19af547323f1f4fe0a Mon Sep 17 00:00:00 2001 From: ShashankPatel0111 Date: Fri, 8 Oct 2021 10:35:56 +0530 Subject: [PATCH 1/2] Update 1_numpy_essentials.ipynb --- lesson_0/1_numpy_essentials.ipynb | 373 +++++++++++++++--------------- 1 file changed, 190 insertions(+), 183 deletions(-) diff --git a/lesson_0/1_numpy_essentials.ipynb b/lesson_0/1_numpy_essentials.ipynb index 34c9a91..5d1eeba 100644 --- a/lesson_0/1_numpy_essentials.ipynb +++ b/lesson_0/1_numpy_essentials.ipynb @@ -1,43 +1,29 @@ { - "nbformat": 4, - "nbformat_minor": 2, - "metadata": { - "colab": { - "name": "1_numpy_essentials.ipynb", - "provenance": [], - "authorship_tag": "ABX9TyMW4V7nidS+Gtk84VK4Og+h", - "include_colab_link": true - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "language_info": { - "name": "python" - } - }, "cells": [ { "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, "source": [ "\"Open" - ], - "metadata": { - "id": "view-in-github", - "colab_type": "text" - } + ] }, { "cell_type": "markdown", - "source": [ - "# **IMPORTANT**: Please avoid creating unnecessary arrays: use the arrays declared in section 1; create additional arrays only if necessary!" - ], "metadata": { "id": "DgtsvALoxjKB" - } + }, + "source": [ + "# **IMPORTANT**: Please avoid creating unnecessary arrays: use the arrays declared in section 1; create additional arrays only if necessary!" + ] }, { "cell_type": "markdown", + "metadata": { + "id": "xlcUVM0FiM7v" + }, "source": [ "# **NumPy Essentials**\n", "\n", @@ -55,43 +41,43 @@ "\n", "---\n", "\n" - ], - "metadata": { - "id": "xlcUVM0FiM7v" - } + ] }, { "cell_type": "markdown", + "metadata": { + "id": "QOS0Or4Xjjuu" + }, "source": [ "# 1. Creating an array\n", "\n", "Create an 1D, 2D and a 3D array." - ], - "metadata": { - "id": "QOS0Or4Xjjuu" - } + ] }, { "cell_type": "code", - "execution_count": null, - "source": [ - "import numpy as np\r\n", - "# TODO: create 1D array\r\n", - "arr1=np.array([0, 1, 2, 3, 4])\r\n", - "\r\n", - "# TODO: create 2D array\r\n", - "arr2=np.array([0, 2, 4],[1, 3, 5])\r\n", - "\r\n", - "# TODO: create 3D array\r\n", - "arr3=np.array([0,1,2], ndmin=3)" - ], - "outputs": [], + "execution_count": 2, "metadata": { "id": "vmkYB3wVhccv" - } + }, + "outputs": [], + "source": [ + "import numpy as np\n", + "# TODO: create 1D array\n", + "arr1=np.array([10, 20, 30, 40, 50])\n", + "\n", + "# TODO: create 2D array\n", + "arr2=np.array([[0, 2, 4],[1, 3, 5]])\n", + "\n", + "# TODO: create 3D array\n", + "arr3=np.array([0,1,2], ndmin=3)" + ] }, { "cell_type": "markdown", + "metadata": { + "id": "KTHL7EUIj1v6" + }, "source": [ "# 2. Basic array operations\n", "\n", @@ -100,37 +86,32 @@ "- Initialize an array of ones\n", "- Printing an array\n", "\n" - ], - "metadata": { - "id": "KTHL7EUIj1v6" - } + ] }, { "cell_type": "code", - "execution_count": null, - "source": [ - "# TODO: add arrays\r\n", - "\r\n", - "\r\n", - "# TODO: subtract arrays\r\n", - "\r\n", - "\r\n", - "# TODO: multiply arrays\r\n", - "\r\n", - "\r\n", - "# TODO: divide arrays\r\n", - "\r\n", - "\r\n", - "# TODO: print an array\r\n", - "\r\n" - ], - "outputs": [], + "execution_count": 4, "metadata": { "id": "GzS5EuIYsW2H" - } + }, + "outputs": [], + "source": [ + "# TODO: print an array\n", + "\n", + "# TODO: add arrays\n", + "\n", + "# TODO: subtract arrays\n", + "\n", + "# TODO: multiply arrays\n", + "\n", + "# TODO: divide arrays\n" + ] }, { "cell_type": "markdown", + "metadata": { + "id": "5A11rtzItx8P" + }, "source": [ "# 3. Arrays, into it!\n", "- Indexing and slicing an array\n", @@ -139,86 +120,86 @@ "- Reshape an array\n", "- Stacking multiple arrays\n", "- Deep copy and Shallow copy" - ], - "metadata": { - "id": "5A11rtzItx8P" - } + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "# TODO: indexing and slicing an array\r\n", - "\r\n", - "\r\n", - "# TODO: Print n th row of a 2D array\r\n", - "\r\n", - "\r\n", - "# TODO: Print n th column of a 2D array\r\n", - "\r\n", - "\r\n", - "# TODO: Reshape an array\r\n", - "\r\n", - "\r\n", - "# TODO: Stacking multiple arrays\r\n", - "\r\n", - "\r\n", - "# TODO: Deep copy and Shallow copy\r\n", - "\r\n" - ], - "outputs": [], "metadata": { "id": "CaZK6aDOvPHC" - } + }, + "outputs": [], + "source": [ + "# TODO: indexing and slicing an array\n", + "\n", + "\n", + "# TODO: Print n th row of a 2D array\n", + "\n", + "\n", + "# TODO: Print n th column of a 2D array\n", + "\n", + "\n", + "# TODO: Reshape an array\n", + "\n", + "\n", + "# TODO: Stacking multiple arrays\n", + "\n", + "\n", + "# TODO: Deep copy and Shallow copy\n", + "\n" + ] }, { "cell_type": "markdown", + "metadata": { + "id": "-Hk1NjeXuLHg" + }, "source": [ "# 4. NumPy methods\n", "NumPy has useful methods that simplify and allow greater degree of manipulation of arrays.\n", "This section is completely open, unstructured!\n", "Please go ahead and add all the interesting methods you've discovered! (Mention appropriate description as comments for the same)" - ], - "metadata": { - "id": "-Hk1NjeXuLHg" - } + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "# write them all!" - ], - "outputs": [], "metadata": { "id": "HvLafvyauwb_" - } + }, + "outputs": [], + "source": [ + "# write them all!" + ] }, { "cell_type": "markdown", + "metadata": { + "id": "ztqLrB9tu2nt" + }, "source": [ "# 5. Properties of an array\n", "Just like functions and methods, a NumPy array has properties!\n", "This section is completely open, unstructured!\n", "Please go ahead and add all the interesting methods you've discovered! (Mention appropriate description as comments for the same)" - ], - "metadata": { - "id": "ztqLrB9tu2nt" - } + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "# write them all!" - ], - "outputs": [], "metadata": { "id": "h88U3jT1vL8Q" - } + }, + "outputs": [], + "source": [ + "# write them all!" + ] }, { "cell_type": "markdown", + "metadata": { + "id": "DmLW18s2wEX4" + }, "source": [ "# 6. Matrix operations\n", "- Inner product\n", @@ -233,14 +214,15 @@ "- Eigenvalues and eigenvectors\n", "\n", "*Note: understand the @ operator and its significance!*" - ], - "metadata": { - "id": "DmLW18s2wEX4" - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "id": "YJxtNVtPwttM" + }, + "outputs": [], "source": [ "# TODO: Inner product\n", "\n", @@ -271,14 +253,13 @@ "\n", "# TODO: Eigenvalues and eigenvectors\n", "\n" - ], - "outputs": [], - "metadata": { - "id": "YJxtNVtPwttM" - } + ] }, { "cell_type": "markdown", + "metadata": { + "id": "lDnNLp-m2nz4" + }, "source": [ "# 7. 10 useful NumPy methods you should know!\n", "**show histograms wherever necessary**\n", @@ -294,123 +275,123 @@ "- loadtxt and savetxt\n", "\n", "\n" - ], - "metadata": { - "id": "lDnNLp-m2nz4" - } + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "# TODO: linspace" - ], - "outputs": [], "metadata": { "id": "lSac5Aas4BfV" - } + }, + "outputs": [], + "source": [ + "# TODO: linspace" + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "# TODO: arange" - ], - "outputs": [], "metadata": { "id": "Y6ur3CIk4BY3" - } + }, + "outputs": [], + "source": [ + "# TODO: arange" + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "# TODO: digitize" - ], - "outputs": [], "metadata": { "id": "i6SrOPQl4BSd" - } + }, + "outputs": [], + "source": [ + "# TODO: digitize" + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "# TODO: repeat" - ], - "outputs": [], "metadata": { "id": "uiy4Aa3x4BLs" - } + }, + "outputs": [], + "source": [ + "# TODO: repeat" + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "# TODO: histogram" - ], - "outputs": [], "metadata": { "id": "JdnerfxO4BGL" - } + }, + "outputs": [], + "source": [ + "# TODO: histogram" + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "# TODO: random" - ], - "outputs": [], "metadata": { "id": "Xbd2LIcB4BBf" - } + }, + "outputs": [], + "source": [ + "# TODO: random" + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "# TODO: polyfit" - ], - "outputs": [], "metadata": { "id": "6n58A-6_4Avv" - } + }, + "outputs": [], + "source": [ + "# TODO: polyfit" + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "# TODO: squeeze" - ], - "outputs": [], "metadata": { "id": "oKXfkaqy4An2" - } + }, + "outputs": [], + "source": [ + "# TODO: squeeze" + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "# TODO: argmax" - ], - "outputs": [], "metadata": { "id": "fUdXK3d64AbX" - } + }, + "outputs": [], + "source": [ + "# TODO: argmax" + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "# TODO: loadtxt and savetxt" - ], - "outputs": [], "metadata": { "id": "85MT5Pt_3__w" - } + }, + "outputs": [], + "source": [ + "# TODO: loadtxt and savetxt" + ] }, { "cell_type": "markdown", + "metadata": { + "id": "BI2qJkwA5FpB" + }, "source": [ "\n", "\n", @@ -421,10 +402,36 @@ "## Now you know how to perform basic linear algebra operations with NumPy to get you started with deep learning!\n", "\n", "### Proceed to chapter 2 to learn about DataFrames and how to handle them with pandas!" - ], - "metadata": { - "id": "BI2qJkwA5FpB" - } + ] + } + ], + "metadata": { + "colab": { + "authorship_tag": "ABX9TyMW4V7nidS+Gtk84VK4Og+h", + "include_colab_link": true, + "name": "1_numpy_essentials.ipynb", + "provenance": [] + }, + "interpreter": { + "hash": "9161589c03f79ee8f44dc63a9f12af7430698781a52da1375abbf686abf58478" + }, + "kernelspec": { + "display_name": "Python 3.8.5 64-bit ('base': conda)", + "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.8.5" } - ] -} \ No newline at end of file + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 35552b97f24efcdf821666f0670bbca6c64062fe Mon Sep 17 00:00:00 2001 From: ShashankPatel0111 Date: Fri, 8 Oct 2021 10:36:24 +0530 Subject: [PATCH 2/2] Added Basic Array Operations --- lesson_0/1_numpy_essentials.ipynb | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/lesson_0/1_numpy_essentials.ipynb b/lesson_0/1_numpy_essentials.ipynb index 5d1eeba..19f02a0 100644 --- a/lesson_0/1_numpy_essentials.ipynb +++ b/lesson_0/1_numpy_essentials.ipynb @@ -56,7 +56,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 5, "metadata": { "id": "vmkYB3wVhccv" }, @@ -90,21 +90,41 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": { "id": "GzS5EuIYsW2H" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "First Array: [10 20 30 40 50]\n", + "Second Array: [ 5 15 4 25 10]\n", + "Added Array: [15 35 34 65 60]\n", + "Subtracted Array: [ 5 5 26 15 40]\n", + "Multiplied Array: [ 50 300 120 1000 500]\n", + "Divided Array: [2. 1.33333333 7.5 1.6 5. ]\n" + ] + } + ], "source": [ + "arr2=np.array([5, 15, 4, 25, 10])\n", "# TODO: print an array\n", + "print(\"First Array: {}\".format(arr1))\n", + "print(\"Second Array: {}\".format(arr2))\n", "\n", "# TODO: add arrays\n", + "print(\"Added Array: {}\".format(np.add(arr1, arr2)))\n", "\n", "# TODO: subtract arrays\n", + "print(\"Subtracted Array: {}\".format(np.subtract(arr1, arr2)))\n", "\n", "# TODO: multiply arrays\n", + "print(\"Multiplied Array: {}\".format(np.multiply(arr1, arr2)))\n", "\n", - "# TODO: divide arrays\n" + "# TODO: divide arrays\n", + "print(\"Divided Array: {}\".format(np.divide(arr1, arr2))) " ] }, {