├── .ipynb_checkpoints
├── Loading the MNIST Dataset-checkpoint.ipynb
├── README-checkpoint.md
└── playing with numpy library-checkpoint.ipynb
├── Data
└── MNIST
│ └── raw
│ └── train-images-idx3-ubyte.gz
├── Exercise Notebooks
├── .ipynb_checkpoints
│ ├── How_to_Define_Functional_And_Sequential_Keras_Models-checkpoint.ipynb
│ ├── Loading the MNIST Dataset-checkpoint.ipynb
│ ├── NumPy_Exercises_From_Udemy_Course-checkpoint.ipynb
│ ├── Pandas_Exercises_From_Udemy_Course-checkpoint.ipynb
│ ├── Playing with numpy library-checkpoint.ipynb
│ ├── Playing_With_Matplotlib_Library-checkpoint.ipynb
│ ├── Playing_With_Numpy_Library-checkpoint.ipynb
│ ├── Playing_With_Pandas_Library-checkpoint.ipynb
│ ├── Playing_With_Pytorch_Library-checkpoint.ipynb
│ ├── Playing_With_Scipy_Library-checkpoint.ipynb
│ ├── Playing_With_Seaborn_Library-checkpoint.ipynb
│ ├── Training_a_Convolutional_Dense_Layer_With_Recognition_Model_Using_Keras_on_the_CIFAR_10_Dataset-checkpoint.ipynb
│ ├── Training_a_Convolutional_Layer_With_Recognition_Model_Using_Pytorch_on_the_MNIST_Dataset-checkpoint.ipynb
│ ├── Training_a_Digit_Recognition_Model_Using_Keras_on_the_MNIST_Dataset-checkpoint.ipynb
│ ├── Training_a_Digit_Recognition_Model_Using_Pytorch_Library_on_the_MNIST_Dataset-checkpoint.ipynb
│ ├── Training_a_Learning_Model_Using_Keras_for_Digit_Recognition_on_the_MNIST_Dataset-checkpoint.ipynb
│ ├── Training_a_Recognition_Model_Using_Keras_on_the_CIFAR_10_Dataset-checkpoint.ipynb
│ └── Training_a_Recognition_Model_Using_Keras_on_the_CIFAR_10_Dataset.ipynb-checkpoint.ipynb
├── Data
│ ├── Data_model_CIFAR-10.h5
│ ├── Data_model_CIFAR-10.json
│ ├── Hand_Writing_Number_4.png
│ ├── Universities.csv
│ ├── Yasin Rezvani.jpg
│ ├── Yasin Rezvani_grayscale.jpg
│ ├── Yasin Rezvani_resized.jpg
│ ├── african_econ_crises.csv
│ ├── face_from_scipy_misc_library.png
│ ├── heart.csv
│ ├── iris.csv
│ ├── model.h5
│ ├── model.json
│ ├── outputfromDataFrame.csv
│ └── outputfromDataFramewithindex.csv
├── How_to_Define_Functional_And_Sequential_Keras_Models.ipynb
├── Loading_The_MNIST_Dataset.ipynb
├── NumPy_Exercises_From_Udemy_Course.ipynb
├── Pandas_Exercises_From_Udemy_Course.ipynb
├── Playing_With_Matplotlib_Library.ipynb
├── Playing_With_Numpy_Library.ipynb
├── Playing_With_Pandas_Library.ipynb
├── Playing_With_Scipy_Library.ipynb
├── Playing_With_Seaborn_Library.ipynb
├── Training_a_Convolutional_Dense_Layer_With_Recognition_Model_Using_Keras_on_the_CIFAR_10_Dataset.ipynb
├── Training_a_Convolutional_Layer_With_Recognition_Model_Using_Pytorch_on_the_MNIST_Dataset.ipynb
├── Training_a_Digit_Recognition_Model_Using_Keras_on_the_MNIST_Dataset.ipynb
├── Training_a_Digit_Recognition_Model_Using_Pytorch_Library_on_the_MNIST_Dataset.ipynb
└── Training_a_Recognition_Model_Using_Keras_on_the_CIFAR_10_Dataset.ipynb
├── LICENSE.txt
└── README.md
/.ipynb_checkpoints/Loading the MNIST Dataset-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 7,
6 | "id": "c41bbec6-578e-406d-b67f-aaebbba89e15",
7 | "metadata": {},
8 | "outputs": [
9 | {
10 | "ename": "ModuleNotFoundError",
11 | "evalue": "No module named 'tensorflow'",
12 | "output_type": "error",
13 | "traceback": [
14 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
15 | "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
16 | "Cell \u001b[1;32mIn[7], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mnp\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mdatasets\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m mnist\n",
17 | "File \u001b[1;32mc:\\users\\yasin\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\keras\\__init__.py:3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;124;03m\"\"\"AUTOGENERATED. DO NOT EDIT.\"\"\"\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m __internal__\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m activations\n\u001b[0;32m 5\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m applications\n",
18 | "File \u001b[1;32mc:\\users\\yasin\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\keras\\__internal__\\__init__.py:3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;124;03m\"\"\"AUTOGENERATED. DO NOT EDIT.\"\"\"\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01m__internal__\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m backend\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01m__internal__\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m layers\n\u001b[0;32m 5\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01m__internal__\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m losses\n",
19 | "File \u001b[1;32mc:\\users\\yasin\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\keras\\__internal__\\backend\\__init__.py:3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;124;03m\"\"\"AUTOGENERATED. DO NOT EDIT.\"\"\"\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01msrc\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mbackend\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m _initialize_variables \u001b[38;5;28;01mas\u001b[39;00m initialize_variables\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01msrc\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mbackend\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m track_variable\n",
20 | "File \u001b[1;32mc:\\users\\yasin\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\keras\\src\\__init__.py:21\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m# Copyright 2015 The TensorFlow Authors. All Rights Reserved.\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[0;32m 3\u001b[0m \u001b[38;5;66;03m# Licensed under the Apache License, Version 2.0 (the \"License\");\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 13\u001b[0m \u001b[38;5;66;03m# limitations under the License.\u001b[39;00m\n\u001b[0;32m 14\u001b[0m \u001b[38;5;66;03m# ==============================================================================\u001b[39;00m\n\u001b[0;32m 15\u001b[0m \u001b[38;5;124;03m\"\"\"Implementation of the Keras API, the high-level API of TensorFlow.\u001b[39;00m\n\u001b[0;32m 16\u001b[0m \n\u001b[0;32m 17\u001b[0m \u001b[38;5;124;03mDetailed documentation and user guides are available at\u001b[39;00m\n\u001b[0;32m 18\u001b[0m \u001b[38;5;124;03m[keras.io](https://keras.io).\u001b[39;00m\n\u001b[0;32m 19\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m---> 21\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01msrc\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m applications\n\u001b[0;32m 22\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01msrc\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m distribute\n\u001b[0;32m 23\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01msrc\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m models\n",
21 | "File \u001b[1;32mc:\\users\\yasin\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\keras\\src\\applications\\__init__.py:18\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m# Copyright 2016 The TensorFlow Authors. All Rights Reserved.\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[0;32m 3\u001b[0m \u001b[38;5;66;03m# Licensed under the Apache License, Version 2.0 (the \"License\");\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 13\u001b[0m \u001b[38;5;66;03m# limitations under the License.\u001b[39;00m\n\u001b[0;32m 14\u001b[0m \u001b[38;5;66;03m# ==============================================================================\u001b[39;00m\n\u001b[0;32m 15\u001b[0m \u001b[38;5;124;03m\"\"\"Keras Applications are premade architectures with pre-trained weights.\"\"\"\u001b[39;00m\n\u001b[1;32m---> 18\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01msrc\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mapplications\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mconvnext\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m ConvNeXtBase\n\u001b[0;32m 19\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01msrc\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mapplications\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mconvnext\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m ConvNeXtLarge\n\u001b[0;32m 20\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01msrc\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mapplications\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mconvnext\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m ConvNeXtSmall\n",
22 | "File \u001b[1;32mc:\\users\\yasin\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\keras\\src\\applications\\convnext.py:26\u001b[0m\n\u001b[0;32m 17\u001b[0m \u001b[38;5;124;03m\"\"\"ConvNeXt models for Keras.\u001b[39;00m\n\u001b[0;32m 18\u001b[0m \n\u001b[0;32m 19\u001b[0m \u001b[38;5;124;03mReferences:\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 22\u001b[0m \u001b[38;5;124;03m (CVPR 2022)\u001b[39;00m\n\u001b[0;32m 23\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 25\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mnp\u001b[39;00m\n\u001b[1;32m---> 26\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mtensorflow\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcompat\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mv2\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mtf\u001b[39;00m\n\u001b[0;32m 28\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01msrc\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m backend\n\u001b[0;32m 29\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01msrc\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m initializers\n",
23 | "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'tensorflow'"
24 | ]
25 | }
26 | ],
27 | "source": [
28 | "import numpy as np\n",
29 | "from keras.datasets import mnist"
30 | ]
31 | },
32 | {
33 | "cell_type": "code",
34 | "execution_count": null,
35 | "id": "f93cfc01-aa90-48ae-9883-6423a3216138",
36 | "metadata": {},
37 | "outputs": [],
38 | "source": []
39 | }
40 | ],
41 | "metadata": {
42 | "kernelspec": {
43 | "display_name": "Python 3 (ipykernel)",
44 | "language": "python",
45 | "name": "python3"
46 | },
47 | "language_info": {
48 | "codemirror_mode": {
49 | "name": "ipython",
50 | "version": 3
51 | },
52 | "file_extension": ".py",
53 | "mimetype": "text/x-python",
54 | "name": "python",
55 | "nbconvert_exporter": "python",
56 | "pygments_lexer": "ipython3",
57 | "version": "3.8.10"
58 | }
59 | },
60 | "nbformat": 4,
61 | "nbformat_minor": 5
62 | }
63 |
--------------------------------------------------------------------------------
/.ipynb_checkpoints/README-checkpoint.md:
--------------------------------------------------------------------------------
1 | # Python_Learning_Practice_Notebook
2 |
3 | ## I plan to kick off soon and will share my progress with you, take care...:)
4 |
5 | #### i'm gonna make it
6 |
7 | check it connceted to msi laptop
8 |
--------------------------------------------------------------------------------
/.ipynb_checkpoints/playing with numpy library-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "id": "b9499a42-604e-41af-889d-140cec4baace",
7 | "metadata": {},
8 | "outputs": [],
9 | "source": [
10 | "import numpy as np"
11 | ]
12 | },
13 | {
14 | "cell_type": "code",
15 | "execution_count": 10,
16 | "id": "38d272a3-447f-4636-8341-76827f10a53a",
17 | "metadata": {},
18 | "outputs": [],
19 | "source": [
20 | "first_array = np.array([[10,20,30],[40,50,60]])"
21 | ]
22 | },
23 | {
24 | "cell_type": "code",
25 | "execution_count": 21,
26 | "id": "454e89e1-c805-4845-9e84-0ae931dfd351",
27 | "metadata": {},
28 | "outputs": [
29 | {
30 | "name": "stdout",
31 | "output_type": "stream",
32 | "text": [
33 | "[[10 20 30]\n",
34 | " [40 50 60]]\n"
35 | ]
36 | }
37 | ],
38 | "source": [
39 | "print(first_array)"
40 | ]
41 | },
42 | {
43 | "cell_type": "code",
44 | "execution_count": 19,
45 | "id": "087623e2-973f-4208-9335-5557b11d42c6",
46 | "metadata": {},
47 | "outputs": [
48 | {
49 | "name": "stdout",
50 | "output_type": "stream",
51 | "text": [
52 | "[10 20 30]\n",
53 | "[40 50 60]\n"
54 | ]
55 | }
56 | ],
57 | "source": [
58 | "for i in first_array:\n",
59 | " print(i)"
60 | ]
61 | },
62 | {
63 | "cell_type": "code",
64 | "execution_count": 20,
65 | "id": "b6f37ae7-e18a-46ca-8945-16beed12a5cf",
66 | "metadata": {},
67 | "outputs": [
68 | {
69 | "data": {
70 | "text/plain": [
71 | "numpy.ndarray"
72 | ]
73 | },
74 | "execution_count": 20,
75 | "metadata": {},
76 | "output_type": "execute_result"
77 | }
78 | ],
79 | "source": [
80 | "type(first_array)"
81 | ]
82 | },
83 | {
84 | "cell_type": "code",
85 | "execution_count": 27,
86 | "id": "8df5ae2f-4686-4ea3-a1c6-5399d4baa8f7",
87 | "metadata": {},
88 | "outputs": [],
89 | "source": [
90 | "second_array = np.array(range(100))"
91 | ]
92 | },
93 | {
94 | "cell_type": "code",
95 | "execution_count": 33,
96 | "id": "2fe72892-2c3c-4511-ac1c-3c448c5c06c5",
97 | "metadata": {},
98 | "outputs": [
99 | {
100 | "name": "stdout",
101 | "output_type": "stream",
102 | "text": [
103 | "[[ 0 1 2 3 4 5 6 7 8 9]\n",
104 | " [10 11 12 13 14 15 16 17 18 19]\n",
105 | " [20 21 22 23 24 25 26 27 28 29]\n",
106 | " [30 31 32 33 34 35 36 37 38 39]\n",
107 | " [40 41 42 43 44 45 46 47 48 49]\n",
108 | " [50 51 52 53 54 55 56 57 58 59]\n",
109 | " [60 61 62 63 64 65 66 67 68 69]\n",
110 | " [70 71 72 73 74 75 76 77 78 79]\n",
111 | " [80 81 82 83 84 85 86 87 88 89]\n",
112 | " [90 91 92 93 94 95 96 97 98 99]]\n"
113 | ]
114 | }
115 | ],
116 | "source": [
117 | "print(second_array.reshape(10,10))"
118 | ]
119 | },
120 | {
121 | "cell_type": "code",
122 | "execution_count": null,
123 | "id": "063b49a8-c352-4551-8a27-27287ca1d8df",
124 | "metadata": {},
125 | "outputs": [],
126 | "source": []
127 | }
128 | ],
129 | "metadata": {
130 | "kernelspec": {
131 | "display_name": "Python 3 (ipykernel)",
132 | "language": "python",
133 | "name": "python3"
134 | },
135 | "language_info": {
136 | "codemirror_mode": {
137 | "name": "ipython",
138 | "version": 3
139 | },
140 | "file_extension": ".py",
141 | "mimetype": "text/x-python",
142 | "name": "python",
143 | "nbconvert_exporter": "python",
144 | "pygments_lexer": "ipython3",
145 | "version": "3.8.10"
146 | }
147 | },
148 | "nbformat": 4,
149 | "nbformat_minor": 5
150 | }
151 |
--------------------------------------------------------------------------------
/Data/MNIST/raw/train-images-idx3-ubyte.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YasinRezvani/Hands_On_Machine_Learning_and_Deep_Learning_with_Python/0f1876aa3e18636857a38aac46fc2f0843a009f8/Data/MNIST/raw/train-images-idx3-ubyte.gz
--------------------------------------------------------------------------------
/Exercise Notebooks/.ipynb_checkpoints/NumPy_Exercises_From_Udemy_Course-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "___\n",
8 | "\n",
9 | "
\n",
10 | "___\n",
11 | "
Copyright Pierian Data\n",
12 | "For more information, visit us at www.pieriandata.com"
13 | ]
14 | },
15 | {
16 | "cell_type": "markdown",
17 | "metadata": {},
18 | "source": [
19 | "# NumPy Exercises\n",
20 | "\n",
21 | "Now that we've learned about NumPy let's test your knowledge. We'll start off with a few simple tasks and then you'll be asked some more complicated questions.\n",
22 | "\n",
23 | "IMPORTANT NOTE! Make sure you don't run the cells directly above the example output shown,
otherwise you will end up writing over the example output!
"
24 | ]
25 | },
26 | {
27 | "cell_type": "markdown",
28 | "metadata": {},
29 | "source": [
30 | "#### 1. Import NumPy as np"
31 | ]
32 | },
33 | {
34 | "cell_type": "code",
35 | "execution_count": 2,
36 | "metadata": {},
37 | "outputs": [],
38 | "source": [
39 | "import numpy as np"
40 | ]
41 | },
42 | {
43 | "cell_type": "markdown",
44 | "metadata": {},
45 | "source": [
46 | "#### 2. Create an array of 10 zeros "
47 | ]
48 | },
49 | {
50 | "cell_type": "code",
51 | "execution_count": 2,
52 | "metadata": {},
53 | "outputs": [
54 | {
55 | "data": {
56 | "text/plain": [
57 | "array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])"
58 | ]
59 | },
60 | "execution_count": 2,
61 | "metadata": {},
62 | "output_type": "execute_result"
63 | }
64 | ],
65 | "source": [
66 | "# CODE HERE\n",
67 | "np.zeros(10)"
68 | ]
69 | },
70 | {
71 | "cell_type": "code",
72 | "execution_count": 2,
73 | "metadata": {},
74 | "outputs": [
75 | {
76 | "data": {
77 | "text/plain": [
78 | "array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])"
79 | ]
80 | },
81 | "execution_count": 2,
82 | "metadata": {},
83 | "output_type": "execute_result"
84 | }
85 | ],
86 | "source": [
87 | "# DON'T WRITE HERE"
88 | ]
89 | },
90 | {
91 | "cell_type": "markdown",
92 | "metadata": {},
93 | "source": [
94 | "#### 3. Create an array of 10 ones"
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": 3,
100 | "metadata": {},
101 | "outputs": [
102 | {
103 | "data": {
104 | "text/plain": [
105 | "array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])"
106 | ]
107 | },
108 | "execution_count": 3,
109 | "metadata": {},
110 | "output_type": "execute_result"
111 | }
112 | ],
113 | "source": [
114 | "np.ones(10)"
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": 3,
120 | "metadata": {},
121 | "outputs": [
122 | {
123 | "data": {
124 | "text/plain": [
125 | "array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])"
126 | ]
127 | },
128 | "execution_count": 3,
129 | "metadata": {},
130 | "output_type": "execute_result"
131 | }
132 | ],
133 | "source": [
134 | "# DON'T WRITE HERE"
135 | ]
136 | },
137 | {
138 | "cell_type": "markdown",
139 | "metadata": {},
140 | "source": [
141 | "#### 4. Create an array of 10 fives"
142 | ]
143 | },
144 | {
145 | "cell_type": "code",
146 | "execution_count": 7,
147 | "metadata": {},
148 | "outputs": [
149 | {
150 | "data": {
151 | "text/plain": [
152 | "array([5., 5., 5., 5., 5., 5., 5., 5., 5., 5.])"
153 | ]
154 | },
155 | "execution_count": 7,
156 | "metadata": {},
157 | "output_type": "execute_result"
158 | }
159 | ],
160 | "source": [
161 | "np.zeros(10) + 5"
162 | ]
163 | },
164 | {
165 | "cell_type": "code",
166 | "execution_count": 4,
167 | "metadata": {},
168 | "outputs": [
169 | {
170 | "data": {
171 | "text/plain": [
172 | "array([5., 5., 5., 5., 5., 5., 5., 5., 5., 5.])"
173 | ]
174 | },
175 | "execution_count": 4,
176 | "metadata": {},
177 | "output_type": "execute_result"
178 | }
179 | ],
180 | "source": [
181 | "# DON'T WRITE HERE"
182 | ]
183 | },
184 | {
185 | "cell_type": "markdown",
186 | "metadata": {},
187 | "source": [
188 | "#### 5. Create an array of the integers from 10 to 50"
189 | ]
190 | },
191 | {
192 | "cell_type": "code",
193 | "execution_count": 8,
194 | "metadata": {},
195 | "outputs": [
196 | {
197 | "data": {
198 | "text/plain": [
199 | "array([10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,\n",
200 | " 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,\n",
201 | " 44, 45, 46, 47, 48, 49, 50])"
202 | ]
203 | },
204 | "execution_count": 8,
205 | "metadata": {},
206 | "output_type": "execute_result"
207 | }
208 | ],
209 | "source": [
210 | "np.arange(10,51)"
211 | ]
212 | },
213 | {
214 | "cell_type": "code",
215 | "execution_count": 5,
216 | "metadata": {},
217 | "outputs": [
218 | {
219 | "data": {
220 | "text/plain": [
221 | "array([10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,\n",
222 | " 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,\n",
223 | " 44, 45, 46, 47, 48, 49, 50])"
224 | ]
225 | },
226 | "execution_count": 5,
227 | "metadata": {},
228 | "output_type": "execute_result"
229 | }
230 | ],
231 | "source": [
232 | "# DON'T WRITE HERE"
233 | ]
234 | },
235 | {
236 | "cell_type": "markdown",
237 | "metadata": {},
238 | "source": [
239 | "#### 6. Create an array of all the even integers from 10 to 50"
240 | ]
241 | },
242 | {
243 | "cell_type": "code",
244 | "execution_count": 9,
245 | "metadata": {},
246 | "outputs": [
247 | {
248 | "data": {
249 | "text/plain": [
250 | "array([10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42,\n",
251 | " 44, 46, 48, 50])"
252 | ]
253 | },
254 | "execution_count": 9,
255 | "metadata": {},
256 | "output_type": "execute_result"
257 | }
258 | ],
259 | "source": [
260 | "np.arange(10,51,2)"
261 | ]
262 | },
263 | {
264 | "cell_type": "code",
265 | "execution_count": 6,
266 | "metadata": {},
267 | "outputs": [
268 | {
269 | "data": {
270 | "text/plain": [
271 | "array([10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42,\n",
272 | " 44, 46, 48, 50])"
273 | ]
274 | },
275 | "execution_count": 6,
276 | "metadata": {},
277 | "output_type": "execute_result"
278 | }
279 | ],
280 | "source": [
281 | "# DON'T WRITE HERE"
282 | ]
283 | },
284 | {
285 | "cell_type": "markdown",
286 | "metadata": {},
287 | "source": [
288 | "#### 7. Create a 3x3 matrix with values ranging from 0 to 8"
289 | ]
290 | },
291 | {
292 | "cell_type": "code",
293 | "execution_count": 11,
294 | "metadata": {},
295 | "outputs": [
296 | {
297 | "data": {
298 | "text/plain": [
299 | "array([[0, 1, 2],\n",
300 | " [3, 4, 5],\n",
301 | " [6, 7, 8]])"
302 | ]
303 | },
304 | "execution_count": 11,
305 | "metadata": {},
306 | "output_type": "execute_result"
307 | }
308 | ],
309 | "source": [
310 | "np.arange(0,9).reshape(3,3)"
311 | ]
312 | },
313 | {
314 | "cell_type": "code",
315 | "execution_count": 7,
316 | "metadata": {},
317 | "outputs": [
318 | {
319 | "data": {
320 | "text/plain": [
321 | "array([[0, 1, 2],\n",
322 | " [3, 4, 5],\n",
323 | " [6, 7, 8]])"
324 | ]
325 | },
326 | "execution_count": 7,
327 | "metadata": {},
328 | "output_type": "execute_result"
329 | }
330 | ],
331 | "source": [
332 | "# DON'T WRITE HERE"
333 | ]
334 | },
335 | {
336 | "cell_type": "markdown",
337 | "metadata": {},
338 | "source": [
339 | "#### 8. Create a 3x3 identity matrix"
340 | ]
341 | },
342 | {
343 | "cell_type": "code",
344 | "execution_count": 12,
345 | "metadata": {},
346 | "outputs": [
347 | {
348 | "data": {
349 | "text/plain": [
350 | "array([[1., 0., 0.],\n",
351 | " [0., 1., 0.],\n",
352 | " [0., 0., 1.]])"
353 | ]
354 | },
355 | "execution_count": 12,
356 | "metadata": {},
357 | "output_type": "execute_result"
358 | }
359 | ],
360 | "source": [
361 | "np.eye(3,3)"
362 | ]
363 | },
364 | {
365 | "cell_type": "code",
366 | "execution_count": 8,
367 | "metadata": {},
368 | "outputs": [
369 | {
370 | "data": {
371 | "text/plain": [
372 | "array([[1., 0., 0.],\n",
373 | " [0., 1., 0.],\n",
374 | " [0., 0., 1.]])"
375 | ]
376 | },
377 | "execution_count": 8,
378 | "metadata": {},
379 | "output_type": "execute_result"
380 | }
381 | ],
382 | "source": [
383 | "# DON'T WRITE HERE"
384 | ]
385 | },
386 | {
387 | "cell_type": "markdown",
388 | "metadata": {},
389 | "source": [
390 | "#### 9. Use NumPy to generate a random number between 0 and 1
NOTE: Your result's value should be different from the one shown below."
391 | ]
392 | },
393 | {
394 | "cell_type": "code",
395 | "execution_count": 30,
396 | "metadata": {},
397 | "outputs": [
398 | {
399 | "data": {
400 | "text/plain": [
401 | "array([0.37454012])"
402 | ]
403 | },
404 | "execution_count": 30,
405 | "metadata": {},
406 | "output_type": "execute_result"
407 | }
408 | ],
409 | "source": [
410 | "np.random.seed(42)\n",
411 | "np.random.rand(1)"
412 | ]
413 | },
414 | {
415 | "cell_type": "code",
416 | "execution_count": 28,
417 | "metadata": {},
418 | "outputs": [],
419 | "source": [
420 | "# DON'T WRITE HERE"
421 | ]
422 | },
423 | {
424 | "cell_type": "markdown",
425 | "metadata": {},
426 | "source": [
427 | "#### 10. Use NumPy to generate an array of 25 random numbers sampled from a standard normal distribution
NOTE: Your result's values should be different from the ones shown below."
428 | ]
429 | },
430 | {
431 | "cell_type": "code",
432 | "execution_count": 33,
433 | "metadata": {},
434 | "outputs": [
435 | {
436 | "data": {
437 | "text/plain": [
438 | "array([ 0.49671415, -0.1382643 , 0.64768854, 1.52302986, -0.23415337,\n",
439 | " -0.23413696, 1.57921282, 0.76743473, -0.46947439, 0.54256004,\n",
440 | " -0.46341769, -0.46572975, 0.24196227, -1.91328024, -1.72491783,\n",
441 | " -0.56228753, -1.01283112, 0.31424733, -0.90802408, -1.4123037 ,\n",
442 | " 1.46564877, -0.2257763 , 0.0675282 , -1.42474819, -0.54438272])"
443 | ]
444 | },
445 | "execution_count": 33,
446 | "metadata": {},
447 | "output_type": "execute_result"
448 | }
449 | ],
450 | "source": [
451 | "np.random.seed(42)\n",
452 | "np.random.randn(25)"
453 | ]
454 | },
455 | {
456 | "cell_type": "code",
457 | "execution_count": 10,
458 | "metadata": {},
459 | "outputs": [
460 | {
461 | "data": {
462 | "text/plain": [
463 | "array([ 1.80076712, -1.12375847, -0.98524305, 0.11673573, 1.96346762,\n",
464 | " 1.81378592, -0.33790771, 0.85012656, 0.0100703 , -0.91005957,\n",
465 | " 0.29064366, 0.69906357, 0.1774377 , -0.61958694, -0.45498611,\n",
466 | " -2.0804685 , -0.06778549, 1.06403819, 0.4311884 , -1.09853837,\n",
467 | " 1.11980469, -0.48751963, 1.32517611, -0.61775122, -0.00622865])"
468 | ]
469 | },
470 | "execution_count": 10,
471 | "metadata": {},
472 | "output_type": "execute_result"
473 | }
474 | ],
475 | "source": [
476 | "# DON'T WRITE HERE"
477 | ]
478 | },
479 | {
480 | "cell_type": "markdown",
481 | "metadata": {},
482 | "source": [
483 | "#### 11. Create the following matrix:"
484 | ]
485 | },
486 | {
487 | "cell_type": "code",
488 | "execution_count": 5,
489 | "metadata": {},
490 | "outputs": [
491 | {
492 | "data": {
493 | "text/plain": [
494 | "array([[0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1 ],\n",
495 | " [0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2 ],\n",
496 | " [0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3 ],\n",
497 | " [0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4 ],\n",
498 | " [0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5 ],\n",
499 | " [0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6 ],\n",
500 | " [0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7 ],\n",
501 | " [0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8 ],\n",
502 | " [0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9 ],\n",
503 | " [0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1. ]])"
504 | ]
505 | },
506 | "execution_count": 5,
507 | "metadata": {},
508 | "output_type": "execute_result"
509 | }
510 | ],
511 | "source": [
512 | "np.arange(0.01,1.01,0.01,dtype=float).reshape(10,10)\n",
513 | "np.arange(1,101).reshape(10,10) / 100"
514 | ]
515 | },
516 | {
517 | "cell_type": "code",
518 | "execution_count": 11,
519 | "metadata": {},
520 | "outputs": [
521 | {
522 | "data": {
523 | "text/plain": [
524 | "array([[0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1 ],\n",
525 | " [0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2 ],\n",
526 | " [0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3 ],\n",
527 | " [0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4 ],\n",
528 | " [0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5 ],\n",
529 | " [0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6 ],\n",
530 | " [0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7 ],\n",
531 | " [0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8 ],\n",
532 | " [0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9 ],\n",
533 | " [0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1. ]])"
534 | ]
535 | },
536 | "execution_count": 11,
537 | "metadata": {},
538 | "output_type": "execute_result"
539 | }
540 | ],
541 | "source": [
542 | "# DON'T WRITE HERE"
543 | ]
544 | },
545 | {
546 | "cell_type": "markdown",
547 | "metadata": {},
548 | "source": [
549 | "#### 12. Create an array of 20 linearly spaced points between 0 and 1:"
550 | ]
551 | },
552 | {
553 | "cell_type": "code",
554 | "execution_count": 46,
555 | "metadata": {},
556 | "outputs": [
557 | {
558 | "data": {
559 | "text/plain": [
560 | "array([0. , 0.05263158, 0.10526316, 0.15789474, 0.21052632,\n",
561 | " 0.26315789, 0.31578947, 0.36842105, 0.42105263, 0.47368421,\n",
562 | " 0.52631579, 0.57894737, 0.63157895, 0.68421053, 0.73684211,\n",
563 | " 0.78947368, 0.84210526, 0.89473684, 0.94736842, 1. ])"
564 | ]
565 | },
566 | "execution_count": 46,
567 | "metadata": {},
568 | "output_type": "execute_result"
569 | }
570 | ],
571 | "source": [
572 | "np.linspace(0,1,20)"
573 | ]
574 | },
575 | {
576 | "cell_type": "code",
577 | "execution_count": 12,
578 | "metadata": {},
579 | "outputs": [
580 | {
581 | "data": {
582 | "text/plain": [
583 | "array([0. , 0.05263158, 0.10526316, 0.15789474, 0.21052632,\n",
584 | " 0.26315789, 0.31578947, 0.36842105, 0.42105263, 0.47368421,\n",
585 | " 0.52631579, 0.57894737, 0.63157895, 0.68421053, 0.73684211,\n",
586 | " 0.78947368, 0.84210526, 0.89473684, 0.94736842, 1. ])"
587 | ]
588 | },
589 | "execution_count": 12,
590 | "metadata": {},
591 | "output_type": "execute_result"
592 | }
593 | ],
594 | "source": [
595 | "# DON'T WRITE HERE"
596 | ]
597 | },
598 | {
599 | "cell_type": "markdown",
600 | "metadata": {},
601 | "source": [
602 | "## Numpy Indexing and Selection\n",
603 | "\n",
604 | "Now you will be given a starting matrix (be sure to run the cell below!), and be asked to replicate the resulting matrix outputs:"
605 | ]
606 | },
607 | {
608 | "cell_type": "code",
609 | "execution_count": 48,
610 | "metadata": {},
611 | "outputs": [
612 | {
613 | "data": {
614 | "text/plain": [
615 | "array([[ 1, 2, 3, 4, 5],\n",
616 | " [ 6, 7, 8, 9, 10],\n",
617 | " [11, 12, 13, 14, 15],\n",
618 | " [16, 17, 18, 19, 20],\n",
619 | " [21, 22, 23, 24, 25]])"
620 | ]
621 | },
622 | "execution_count": 48,
623 | "metadata": {},
624 | "output_type": "execute_result"
625 | }
626 | ],
627 | "source": [
628 | "# RUN THIS CELL - THIS IS OUR STARTING MATRIX\n",
629 | "mat = np.arange(1,26).reshape(5,5)\n",
630 | "mat"
631 | ]
632 | },
633 | {
634 | "cell_type": "markdown",
635 | "metadata": {},
636 | "source": [
637 | "#### 13. Write code that reproduces the output shown below.
Be careful not to run the cell immediately above the output, otherwise you won't be able to see the output any more."
638 | ]
639 | },
640 | {
641 | "cell_type": "code",
642 | "execution_count": 56,
643 | "metadata": {},
644 | "outputs": [
645 | {
646 | "data": {
647 | "text/plain": [
648 | "array([[12, 13, 14, 15],\n",
649 | " [17, 18, 19, 20],\n",
650 | " [22, 23, 24, 25]])"
651 | ]
652 | },
653 | "execution_count": 56,
654 | "metadata": {},
655 | "output_type": "execute_result"
656 | }
657 | ],
658 | "source": [
659 | "# CODE HERE\n",
660 | "mat[2:,1:]"
661 | ]
662 | },
663 | {
664 | "cell_type": "code",
665 | "execution_count": 14,
666 | "metadata": {},
667 | "outputs": [
668 | {
669 | "data": {
670 | "text/plain": [
671 | "array([[12, 13, 14, 15],\n",
672 | " [17, 18, 19, 20],\n",
673 | " [22, 23, 24, 25]])"
674 | ]
675 | },
676 | "execution_count": 14,
677 | "metadata": {},
678 | "output_type": "execute_result"
679 | }
680 | ],
681 | "source": [
682 | "# DON'T WRITE HERE"
683 | ]
684 | },
685 | {
686 | "cell_type": "markdown",
687 | "metadata": {},
688 | "source": [
689 | "#### 14. Write code that reproduces the output shown below."
690 | ]
691 | },
692 | {
693 | "cell_type": "code",
694 | "execution_count": 57,
695 | "metadata": {},
696 | "outputs": [
697 | {
698 | "data": {
699 | "text/plain": [
700 | "20"
701 | ]
702 | },
703 | "execution_count": 57,
704 | "metadata": {},
705 | "output_type": "execute_result"
706 | }
707 | ],
708 | "source": [
709 | "mat[3,4]"
710 | ]
711 | },
712 | {
713 | "cell_type": "code",
714 | "execution_count": 15,
715 | "metadata": {},
716 | "outputs": [
717 | {
718 | "data": {
719 | "text/plain": [
720 | "20"
721 | ]
722 | },
723 | "execution_count": 15,
724 | "metadata": {},
725 | "output_type": "execute_result"
726 | }
727 | ],
728 | "source": [
729 | "# DON'T WRITE HERE"
730 | ]
731 | },
732 | {
733 | "cell_type": "markdown",
734 | "metadata": {},
735 | "source": [
736 | "#### 15. Write code that reproduces the output shown below."
737 | ]
738 | },
739 | {
740 | "cell_type": "code",
741 | "execution_count": 58,
742 | "metadata": {},
743 | "outputs": [
744 | {
745 | "data": {
746 | "text/plain": [
747 | "array([[ 2],\n",
748 | " [ 7],\n",
749 | " [12]])"
750 | ]
751 | },
752 | "execution_count": 58,
753 | "metadata": {},
754 | "output_type": "execute_result"
755 | }
756 | ],
757 | "source": [
758 | "mat[:3,1:2]"
759 | ]
760 | },
761 | {
762 | "cell_type": "code",
763 | "execution_count": 16,
764 | "metadata": {},
765 | "outputs": [
766 | {
767 | "data": {
768 | "text/plain": [
769 | "array([[ 2],\n",
770 | " [ 7],\n",
771 | " [12]])"
772 | ]
773 | },
774 | "execution_count": 16,
775 | "metadata": {},
776 | "output_type": "execute_result"
777 | }
778 | ],
779 | "source": [
780 | "# DON'T WRITE HERE"
781 | ]
782 | },
783 | {
784 | "cell_type": "markdown",
785 | "metadata": {},
786 | "source": [
787 | "#### 16. Write code that reproduces the output shown below."
788 | ]
789 | },
790 | {
791 | "cell_type": "code",
792 | "execution_count": 61,
793 | "metadata": {},
794 | "outputs": [
795 | {
796 | "data": {
797 | "text/plain": [
798 | "array([21, 22, 23, 24, 25])"
799 | ]
800 | },
801 | "execution_count": 61,
802 | "metadata": {},
803 | "output_type": "execute_result"
804 | }
805 | ],
806 | "source": [
807 | "mat[4]"
808 | ]
809 | },
810 | {
811 | "cell_type": "code",
812 | "execution_count": 17,
813 | "metadata": {},
814 | "outputs": [
815 | {
816 | "data": {
817 | "text/plain": [
818 | "array([21, 22, 23, 24, 25])"
819 | ]
820 | },
821 | "execution_count": 17,
822 | "metadata": {},
823 | "output_type": "execute_result"
824 | }
825 | ],
826 | "source": [
827 | "# DON'T WRITE HERE"
828 | ]
829 | },
830 | {
831 | "cell_type": "markdown",
832 | "metadata": {},
833 | "source": [
834 | "#### 17. Write code that reproduces the output shown below."
835 | ]
836 | },
837 | {
838 | "cell_type": "code",
839 | "execution_count": 62,
840 | "metadata": {},
841 | "outputs": [
842 | {
843 | "data": {
844 | "text/plain": [
845 | "array([[16, 17, 18, 19, 20],\n",
846 | " [21, 22, 23, 24, 25]])"
847 | ]
848 | },
849 | "execution_count": 62,
850 | "metadata": {},
851 | "output_type": "execute_result"
852 | }
853 | ],
854 | "source": [
855 | "mat[3:,:]"
856 | ]
857 | },
858 | {
859 | "cell_type": "code",
860 | "execution_count": 18,
861 | "metadata": {},
862 | "outputs": [
863 | {
864 | "data": {
865 | "text/plain": [
866 | "array([[16, 17, 18, 19, 20],\n",
867 | " [21, 22, 23, 24, 25]])"
868 | ]
869 | },
870 | "execution_count": 18,
871 | "metadata": {},
872 | "output_type": "execute_result"
873 | }
874 | ],
875 | "source": [
876 | "# DON'T WRITE HERE"
877 | ]
878 | },
879 | {
880 | "cell_type": "markdown",
881 | "metadata": {},
882 | "source": [
883 | "## NumPy Operations"
884 | ]
885 | },
886 | {
887 | "cell_type": "markdown",
888 | "metadata": {},
889 | "source": [
890 | "#### 18. Get the sum of all the values in mat"
891 | ]
892 | },
893 | {
894 | "cell_type": "code",
895 | "execution_count": 63,
896 | "metadata": {},
897 | "outputs": [
898 | {
899 | "data": {
900 | "text/plain": [
901 | "325"
902 | ]
903 | },
904 | "execution_count": 63,
905 | "metadata": {},
906 | "output_type": "execute_result"
907 | }
908 | ],
909 | "source": [
910 | "mat.sum()"
911 | ]
912 | },
913 | {
914 | "cell_type": "code",
915 | "execution_count": 19,
916 | "metadata": {},
917 | "outputs": [
918 | {
919 | "data": {
920 | "text/plain": [
921 | "325"
922 | ]
923 | },
924 | "execution_count": 19,
925 | "metadata": {},
926 | "output_type": "execute_result"
927 | }
928 | ],
929 | "source": [
930 | "# DON'T WRITE HERE"
931 | ]
932 | },
933 | {
934 | "cell_type": "markdown",
935 | "metadata": {},
936 | "source": [
937 | "#### 19. Get the standard deviation of the values in mat"
938 | ]
939 | },
940 | {
941 | "cell_type": "code",
942 | "execution_count": 65,
943 | "metadata": {},
944 | "outputs": [
945 | {
946 | "data": {
947 | "text/plain": [
948 | "7.211102550927978"
949 | ]
950 | },
951 | "execution_count": 65,
952 | "metadata": {},
953 | "output_type": "execute_result"
954 | }
955 | ],
956 | "source": [
957 | "mat.std()"
958 | ]
959 | },
960 | {
961 | "cell_type": "code",
962 | "execution_count": 20,
963 | "metadata": {},
964 | "outputs": [
965 | {
966 | "data": {
967 | "text/plain": [
968 | "7.211102550927978"
969 | ]
970 | },
971 | "execution_count": 20,
972 | "metadata": {},
973 | "output_type": "execute_result"
974 | }
975 | ],
976 | "source": [
977 | "# DON'T WRITE HERE"
978 | ]
979 | },
980 | {
981 | "cell_type": "markdown",
982 | "metadata": {},
983 | "source": [
984 | "#### 20. Get the sum of all the columns in mat"
985 | ]
986 | },
987 | {
988 | "cell_type": "code",
989 | "execution_count": 66,
990 | "metadata": {},
991 | "outputs": [
992 | {
993 | "data": {
994 | "text/plain": [
995 | "array([55, 60, 65, 70, 75])"
996 | ]
997 | },
998 | "execution_count": 66,
999 | "metadata": {},
1000 | "output_type": "execute_result"
1001 | }
1002 | ],
1003 | "source": [
1004 | "mat.sum(axis=0)"
1005 | ]
1006 | },
1007 | {
1008 | "cell_type": "code",
1009 | "execution_count": 21,
1010 | "metadata": {},
1011 | "outputs": [
1012 | {
1013 | "data": {
1014 | "text/plain": [
1015 | "array([55, 60, 65, 70, 75])"
1016 | ]
1017 | },
1018 | "execution_count": 21,
1019 | "metadata": {},
1020 | "output_type": "execute_result"
1021 | }
1022 | ],
1023 | "source": [
1024 | "# DON'T WRITE HERE"
1025 | ]
1026 | },
1027 | {
1028 | "cell_type": "markdown",
1029 | "metadata": {},
1030 | "source": [
1031 | "## Bonus Question\n",
1032 | "We worked a lot with random data with numpy, but is there a way we can insure that we always get the same random numbers? What does the seed value mean? Does it matter what the actual number is? [Click Here for a Hint](https://www.google.com/search?q=numpy+random+seed)"
1033 | ]
1034 | },
1035 | {
1036 | "cell_type": "code",
1037 | "execution_count": 11,
1038 | "metadata": {},
1039 | "outputs": [
1040 | {
1041 | "data": {
1042 | "text/plain": [
1043 | "array([0.37454012, 0.95071431])"
1044 | ]
1045 | },
1046 | "execution_count": 11,
1047 | "metadata": {},
1048 | "output_type": "execute_result"
1049 | }
1050 | ],
1051 | "source": [
1052 | "np.random.seed(42)\n",
1053 | "np.random.rand(2)"
1054 | ]
1055 | },
1056 | {
1057 | "cell_type": "markdown",
1058 | "metadata": {
1059 | "collapsed": true,
1060 | "jupyter": {
1061 | "outputs_hidden": true
1062 | }
1063 | },
1064 | "source": [
1065 | "# Great Job!"
1066 | ]
1067 | }
1068 | ],
1069 | "metadata": {
1070 | "anaconda-cloud": {},
1071 | "kernelspec": {
1072 | "display_name": "Python 3 (ipykernel)",
1073 | "language": "python",
1074 | "name": "python3"
1075 | },
1076 | "language_info": {
1077 | "codemirror_mode": {
1078 | "name": "ipython",
1079 | "version": 3
1080 | },
1081 | "file_extension": ".py",
1082 | "mimetype": "text/x-python",
1083 | "name": "python",
1084 | "nbconvert_exporter": "python",
1085 | "pygments_lexer": "ipython3",
1086 | "version": "3.8.10"
1087 | }
1088 | },
1089 | "nbformat": 4,
1090 | "nbformat_minor": 4
1091 | }
1092 |
--------------------------------------------------------------------------------
/Exercise Notebooks/.ipynb_checkpoints/Playing with numpy library-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 143,
6 | "id": "b9499a42-604e-41af-889d-140cec4baace",
7 | "metadata": {},
8 | "outputs": [],
9 | "source": [
10 | "import numpy as np"
11 | ]
12 | },
13 | {
14 | "cell_type": "code",
15 | "execution_count": 144,
16 | "id": "38d272a3-447f-4636-8341-76827f10a53a",
17 | "metadata": {},
18 | "outputs": [],
19 | "source": [
20 | "first_array = np.array([[10,20,30],[40,50,60]])"
21 | ]
22 | },
23 | {
24 | "cell_type": "code",
25 | "execution_count": 145,
26 | "id": "454e89e1-c805-4845-9e84-0ae931dfd351",
27 | "metadata": {},
28 | "outputs": [
29 | {
30 | "name": "stdout",
31 | "output_type": "stream",
32 | "text": [
33 | "[[10 20 30]\n",
34 | " [40 50 60]]\n"
35 | ]
36 | }
37 | ],
38 | "source": [
39 | "print(first_array)"
40 | ]
41 | },
42 | {
43 | "cell_type": "code",
44 | "execution_count": 146,
45 | "id": "087623e2-973f-4208-9335-5557b11d42c6",
46 | "metadata": {},
47 | "outputs": [
48 | {
49 | "name": "stdout",
50 | "output_type": "stream",
51 | "text": [
52 | "[10 20 30]\n",
53 | "[40 50 60]\n"
54 | ]
55 | }
56 | ],
57 | "source": [
58 | "for i in first_array:\n",
59 | " print(i)"
60 | ]
61 | },
62 | {
63 | "cell_type": "code",
64 | "execution_count": 147,
65 | "id": "ce319ee7-24f1-4446-aaa8-90d8b548cefd",
66 | "metadata": {},
67 | "outputs": [
68 | {
69 | "name": "stdout",
70 | "output_type": "stream",
71 | "text": [
72 | "10\n",
73 | "20\n",
74 | "30\n",
75 | "40\n",
76 | "50\n",
77 | "60\n"
78 | ]
79 | }
80 | ],
81 | "source": [
82 | "for i in first_array:\n",
83 | " for j in i: \n",
84 | " print(j)"
85 | ]
86 | },
87 | {
88 | "cell_type": "code",
89 | "execution_count": 148,
90 | "id": "b6f37ae7-e18a-46ca-8945-16beed12a5cf",
91 | "metadata": {},
92 | "outputs": [
93 | {
94 | "data": {
95 | "text/plain": [
96 | "numpy.ndarray"
97 | ]
98 | },
99 | "execution_count": 148,
100 | "metadata": {},
101 | "output_type": "execute_result"
102 | }
103 | ],
104 | "source": [
105 | "type(first_array)"
106 | ]
107 | },
108 | {
109 | "cell_type": "code",
110 | "execution_count": 149,
111 | "id": "8df5ae2f-4686-4ea3-a1c6-5399d4baa8f7",
112 | "metadata": {},
113 | "outputs": [],
114 | "source": [
115 | "second_array = np.array(range(100))"
116 | ]
117 | },
118 | {
119 | "cell_type": "code",
120 | "execution_count": 150,
121 | "id": "2fe72892-2c3c-4511-ac1c-3c448c5c06c5",
122 | "metadata": {},
123 | "outputs": [
124 | {
125 | "name": "stdout",
126 | "output_type": "stream",
127 | "text": [
128 | "[[ 0 1 2 3 4 5 6 7 8 9]\n",
129 | " [10 11 12 13 14 15 16 17 18 19]\n",
130 | " [20 21 22 23 24 25 26 27 28 29]\n",
131 | " [30 31 32 33 34 35 36 37 38 39]\n",
132 | " [40 41 42 43 44 45 46 47 48 49]\n",
133 | " [50 51 52 53 54 55 56 57 58 59]\n",
134 | " [60 61 62 63 64 65 66 67 68 69]\n",
135 | " [70 71 72 73 74 75 76 77 78 79]\n",
136 | " [80 81 82 83 84 85 86 87 88 89]\n",
137 | " [90 91 92 93 94 95 96 97 98 99]]\n"
138 | ]
139 | }
140 | ],
141 | "source": [
142 | "print(second_array.reshape(10,10))"
143 | ]
144 | },
145 | {
146 | "cell_type": "code",
147 | "execution_count": 151,
148 | "id": "063b49a8-c352-4551-8a27-27287ca1d8df",
149 | "metadata": {},
150 | "outputs": [],
151 | "source": [
152 | "third_array = np.array([[[0,1],[2,3]],[[4,5],[6,7]]])"
153 | ]
154 | },
155 | {
156 | "cell_type": "code",
157 | "execution_count": 152,
158 | "id": "75c84eba-6475-4b62-8268-448d1c54f44b",
159 | "metadata": {},
160 | "outputs": [
161 | {
162 | "name": "stdout",
163 | "output_type": "stream",
164 | "text": [
165 | "0\n",
166 | "1\n",
167 | "2\n",
168 | "3\n",
169 | "4\n",
170 | "5\n",
171 | "6\n",
172 | "7\n"
173 | ]
174 | }
175 | ],
176 | "source": [
177 | "for i in third_array:\n",
178 | " for j in i:\n",
179 | " for k in j:\n",
180 | " print(k)"
181 | ]
182 | },
183 | {
184 | "cell_type": "code",
185 | "execution_count": 153,
186 | "id": "a115da36-4f4f-46fa-acd0-e6b0adb34b3d",
187 | "metadata": {},
188 | "outputs": [
189 | {
190 | "name": "stdout",
191 | "output_type": "stream",
192 | "text": [
193 | "0\n",
194 | "1\n",
195 | "2\n",
196 | "3\n",
197 | "4\n",
198 | "5\n",
199 | "6\n",
200 | "7\n"
201 | ]
202 | }
203 | ],
204 | "source": [
205 | "for i in np.nditer(third_array):\n",
206 | " print(i)"
207 | ]
208 | },
209 | {
210 | "cell_type": "code",
211 | "execution_count": 154,
212 | "id": "743b8459-08b7-47e7-ad8b-d62a953ac6df",
213 | "metadata": {},
214 | "outputs": [
215 | {
216 | "name": "stdout",
217 | "output_type": "stream",
218 | "text": [
219 | "(0, 0, 0) 0\n",
220 | "(0, 0, 1) 1\n",
221 | "(0, 1, 0) 2\n",
222 | "(0, 1, 1) 3\n",
223 | "(1, 0, 0) 4\n",
224 | "(1, 0, 1) 5\n",
225 | "(1, 1, 0) 6\n",
226 | "(1, 1, 1) 7\n"
227 | ]
228 | }
229 | ],
230 | "source": [
231 | "# hey, binary to decimal system, I'm lucky :)\n",
232 | "for i,j in np.ndenumerate(third_array):\n",
233 | " print(i,j)"
234 | ]
235 | },
236 | {
237 | "cell_type": "code",
238 | "execution_count": 155,
239 | "id": "9dfdf998-bc9f-420f-b9bb-32644c931ab7",
240 | "metadata": {},
241 | "outputs": [],
242 | "source": [
243 | "python_list = [[1,2] , [3,4] , [5,6]]"
244 | ]
245 | },
246 | {
247 | "cell_type": "code",
248 | "execution_count": 156,
249 | "id": "eaf4b23c-b1ab-4d0f-8b12-07a12cf5b8a5",
250 | "metadata": {},
251 | "outputs": [
252 | {
253 | "data": {
254 | "text/plain": [
255 | "array([[1, 2],\n",
256 | " [3, 4],\n",
257 | " [5, 6]])"
258 | ]
259 | },
260 | "execution_count": 156,
261 | "metadata": {},
262 | "output_type": "execute_result"
263 | }
264 | ],
265 | "source": [
266 | "np.array(python_list)"
267 | ]
268 | },
269 | {
270 | "cell_type": "code",
271 | "execution_count": 157,
272 | "id": "e56dbf39-4f4a-42ff-80fb-bb66001a4565",
273 | "metadata": {},
274 | "outputs": [
275 | {
276 | "data": {
277 | "text/plain": [
278 | "array([ 0, 2, 4, 6, 8, 10])"
279 | ]
280 | },
281 | "execution_count": 157,
282 | "metadata": {},
283 | "output_type": "execute_result"
284 | }
285 | ],
286 | "source": [
287 | "np.arange(0,11,2)"
288 | ]
289 | },
290 | {
291 | "cell_type": "code",
292 | "execution_count": 158,
293 | "id": "99989246-c773-4893-b9c6-1b4c9d27c2fe",
294 | "metadata": {},
295 | "outputs": [
296 | {
297 | "data": {
298 | "text/plain": [
299 | "array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])"
300 | ]
301 | },
302 | "execution_count": 158,
303 | "metadata": {},
304 | "output_type": "execute_result"
305 | }
306 | ],
307 | "source": [
308 | "np.zeros(10 , int)"
309 | ]
310 | },
311 | {
312 | "cell_type": "code",
313 | "execution_count": 159,
314 | "id": "fca3b98f-0da3-4c82-ae40-300f132603e8",
315 | "metadata": {},
316 | "outputs": [
317 | {
318 | "data": {
319 | "text/plain": [
320 | "array([[0, 0, 0],\n",
321 | " [0, 0, 0],\n",
322 | " [0, 0, 0]])"
323 | ]
324 | },
325 | "execution_count": 159,
326 | "metadata": {},
327 | "output_type": "execute_result"
328 | }
329 | ],
330 | "source": [
331 | "np.zeros((3,3) , int)"
332 | ]
333 | },
334 | {
335 | "cell_type": "code",
336 | "execution_count": 160,
337 | "id": "e268c25d-4581-4441-9c4f-e956316e9bfc",
338 | "metadata": {},
339 | "outputs": [
340 | {
341 | "data": {
342 | "text/plain": [
343 | "array([[[1., 1., 1., 1.],\n",
344 | " [1., 1., 1., 1.]],\n",
345 | "\n",
346 | " [[1., 1., 1., 1.],\n",
347 | " [1., 1., 1., 1.]],\n",
348 | "\n",
349 | " [[1., 1., 1., 1.],\n",
350 | " [1., 1., 1., 1.]],\n",
351 | "\n",
352 | " [[1., 1., 1., 1.],\n",
353 | " [1., 1., 1., 1.]],\n",
354 | "\n",
355 | " [[1., 1., 1., 1.],\n",
356 | " [1., 1., 1., 1.]]])"
357 | ]
358 | },
359 | "execution_count": 160,
360 | "metadata": {},
361 | "output_type": "execute_result"
362 | }
363 | ],
364 | "source": [
365 | "np.ones((5,2,4))"
366 | ]
367 | },
368 | {
369 | "cell_type": "code",
370 | "execution_count": 161,
371 | "id": "3b116d19-1650-46c5-8257-369c50b23cf2",
372 | "metadata": {},
373 | "outputs": [
374 | {
375 | "data": {
376 | "text/plain": [
377 | "array([[1, 0, 0],\n",
378 | " [0, 1, 0],\n",
379 | " [0, 0, 1]])"
380 | ]
381 | },
382 | "execution_count": 161,
383 | "metadata": {},
384 | "output_type": "execute_result"
385 | }
386 | ],
387 | "source": [
388 | "#diagonal matrices\n",
389 | "np.eye(3,dtype=int)"
390 | ]
391 | },
392 | {
393 | "cell_type": "code",
394 | "execution_count": 162,
395 | "id": "14348881-36f8-4385-929a-767be93da987",
396 | "metadata": {},
397 | "outputs": [
398 | {
399 | "data": {
400 | "text/plain": [
401 | "array([[0.52477466, 0.39986097, 0.04666566],\n",
402 | " [0.97375552, 0.23277134, 0.09060643],\n",
403 | " [0.61838601, 0.38246199, 0.98323089]])"
404 | ]
405 | },
406 | "execution_count": 162,
407 | "metadata": {},
408 | "output_type": "execute_result"
409 | }
410 | ],
411 | "source": [
412 | "#between 0 and 1\n",
413 | "np.random.rand(3,3)"
414 | ]
415 | },
416 | {
417 | "cell_type": "code",
418 | "execution_count": 163,
419 | "id": "90199006-29a6-489c-ae4a-589652d6292d",
420 | "metadata": {},
421 | "outputs": [
422 | {
423 | "data": {
424 | "text/plain": [
425 | "array([[ 1.13433927, -0.10474555, -0.52512285, 1.91277127],\n",
426 | " [-2.02671962, 1.11942361, 0.77919263, -1.10109776]])"
427 | ]
428 | },
429 | "execution_count": 163,
430 | "metadata": {},
431 | "output_type": "execute_result"
432 | }
433 | ],
434 | "source": [
435 | "# standard distribution contain variance number(negetive)\n",
436 | "np.random.randn(2,4)"
437 | ]
438 | },
439 | {
440 | "cell_type": "code",
441 | "execution_count": 164,
442 | "id": "47667242-00bb-40d2-b3a7-2632f4190950",
443 | "metadata": {},
444 | "outputs": [
445 | {
446 | "data": {
447 | "text/plain": [
448 | "array([[43, 7, 46, 34, 13],\n",
449 | " [16, 35, 49, 39, 3],\n",
450 | " [ 1, 5, 41, 3, 28]])"
451 | ]
452 | },
453 | "execution_count": 164,
454 | "metadata": {},
455 | "output_type": "execute_result"
456 | }
457 | ],
458 | "source": [
459 | "np.random.randint(0,50,(3,5))"
460 | ]
461 | },
462 | {
463 | "cell_type": "code",
464 | "execution_count": 165,
465 | "id": "e099b25c-c09a-403a-ad76-260fb4ebf380",
466 | "metadata": {},
467 | "outputs": [
468 | {
469 | "data": {
470 | "text/plain": [
471 | "array([51, 92, 14, 71, 60, 20, 82, 86, 74, 74])"
472 | ]
473 | },
474 | "execution_count": 165,
475 | "metadata": {},
476 | "output_type": "execute_result"
477 | }
478 | ],
479 | "source": [
480 | "# but this section doesn't change any compile and default value with np.random.seed()\n",
481 | "# especially in machine learning algorithms\n",
482 | "np.random.seed(42)\n",
483 | "np.random.randint(0,100,10)"
484 | ]
485 | },
486 | {
487 | "cell_type": "code",
488 | "execution_count": 166,
489 | "id": "33039e74-390f-4f16-a61e-e081aac46ead",
490 | "metadata": {},
491 | "outputs": [
492 | {
493 | "data": {
494 | "text/plain": [
495 | "array([87, 99, 23, 2, 21, 52, 1, 87, 29, 37])"
496 | ]
497 | },
498 | "execution_count": 166,
499 | "metadata": {},
500 | "output_type": "execute_result"
501 | }
502 | ],
503 | "source": [
504 | "# in any compile reproduce new value\n",
505 | "np.random.randint(0,100,10)"
506 | ]
507 | },
508 | {
509 | "cell_type": "code",
510 | "execution_count": 167,
511 | "id": "1b0e1455-9b5b-4b9d-b813-0395cbdac563",
512 | "metadata": {},
513 | "outputs": [],
514 | "source": [
515 | "ex_arr = np.random.randint(0,100,10)"
516 | ]
517 | },
518 | {
519 | "cell_type": "code",
520 | "execution_count": 168,
521 | "id": "12543062-2799-4d00-8280-3dbb20dc2345",
522 | "metadata": {},
523 | "outputs": [
524 | {
525 | "data": {
526 | "text/plain": [
527 | "numpy.ndarray"
528 | ]
529 | },
530 | "execution_count": 168,
531 | "metadata": {},
532 | "output_type": "execute_result"
533 | }
534 | ],
535 | "source": [
536 | "type(ex_arr)"
537 | ]
538 | },
539 | {
540 | "cell_type": "code",
541 | "execution_count": 169,
542 | "id": "29f55460-b5f3-4b10-af0a-96086e975a57",
543 | "metadata": {},
544 | "outputs": [
545 | {
546 | "data": {
547 | "text/plain": [
548 | "dtype('int32')"
549 | ]
550 | },
551 | "execution_count": 169,
552 | "metadata": {},
553 | "output_type": "execute_result"
554 | }
555 | ],
556 | "source": [
557 | "ex_arr.dtype"
558 | ]
559 | },
560 | {
561 | "cell_type": "code",
562 | "execution_count": 170,
563 | "id": "4e4f3fa4-059e-43b7-ac97-fa60aa53ba6f",
564 | "metadata": {},
565 | "outputs": [
566 | {
567 | "data": {
568 | "text/plain": [
569 | "(10,)"
570 | ]
571 | },
572 | "execution_count": 170,
573 | "metadata": {},
574 | "output_type": "execute_result"
575 | }
576 | ],
577 | "source": [
578 | "ex_arr.shape"
579 | ]
580 | },
581 | {
582 | "cell_type": "code",
583 | "execution_count": 171,
584 | "id": "7f1ffe8c-23a0-4d38-82d8-df14d8450f1a",
585 | "metadata": {},
586 | "outputs": [
587 | {
588 | "data": {
589 | "text/plain": [
590 | "array([[ 1, 63, 59, 20, 32],\n",
591 | " [75, 57, 21, 88, 48]])"
592 | ]
593 | },
594 | "execution_count": 171,
595 | "metadata": {},
596 | "output_type": "execute_result"
597 | }
598 | ],
599 | "source": [
600 | "ex_arr.reshape(2,5)"
601 | ]
602 | },
603 | {
604 | "cell_type": "code",
605 | "execution_count": 172,
606 | "id": "adc377f2-3d76-430c-bb28-f30e99e6494f",
607 | "metadata": {},
608 | "outputs": [
609 | {
610 | "data": {
611 | "text/plain": [
612 | "88"
613 | ]
614 | },
615 | "execution_count": 172,
616 | "metadata": {},
617 | "output_type": "execute_result"
618 | }
619 | ],
620 | "source": [
621 | "ex_arr.max()"
622 | ]
623 | },
624 | {
625 | "cell_type": "code",
626 | "execution_count": 173,
627 | "id": "63c679b1-d835-4235-906d-1394a39c2df5",
628 | "metadata": {},
629 | "outputs": [
630 | {
631 | "data": {
632 | "text/plain": [
633 | "8"
634 | ]
635 | },
636 | "execution_count": 173,
637 | "metadata": {},
638 | "output_type": "execute_result"
639 | }
640 | ],
641 | "source": [
642 | "ex_arr.argmax()"
643 | ]
644 | },
645 | {
646 | "cell_type": "code",
647 | "execution_count": 174,
648 | "id": "01281f3f-5c31-400e-bd6d-8ef06210b964",
649 | "metadata": {},
650 | "outputs": [],
651 | "source": [
652 | "arr_2d = np.array([[1,2,3],[4,5,6],[7,8,9]])"
653 | ]
654 | },
655 | {
656 | "cell_type": "code",
657 | "execution_count": 175,
658 | "id": "4acc3789-fcca-4b5c-85d8-e33468c908c1",
659 | "metadata": {},
660 | "outputs": [
661 | {
662 | "data": {
663 | "text/plain": [
664 | "(3, 3)"
665 | ]
666 | },
667 | "execution_count": 175,
668 | "metadata": {},
669 | "output_type": "execute_result"
670 | }
671 | ],
672 | "source": [
673 | "arr_2d.shape"
674 | ]
675 | },
676 | {
677 | "cell_type": "code",
678 | "execution_count": 176,
679 | "id": "fb9f7640-d7f7-4706-bde2-c336c792ee5f",
680 | "metadata": {},
681 | "outputs": [
682 | {
683 | "data": {
684 | "text/plain": [
685 | "array([[4, 5, 6]])"
686 | ]
687 | },
688 | "execution_count": 176,
689 | "metadata": {},
690 | "output_type": "execute_result"
691 | }
692 | ],
693 | "source": [
694 | "arr_2d[1:2]"
695 | ]
696 | },
697 | {
698 | "cell_type": "code",
699 | "execution_count": 177,
700 | "id": "7006585b-a31e-4bec-8504-672431ada2aa",
701 | "metadata": {},
702 | "outputs": [],
703 | "source": [
704 | "arr_copy = arr_2d.copy()"
705 | ]
706 | },
707 | {
708 | "cell_type": "code",
709 | "execution_count": 178,
710 | "id": "50733767-33f8-4665-8340-3fef829da337",
711 | "metadata": {},
712 | "outputs": [
713 | {
714 | "data": {
715 | "text/plain": [
716 | "array([[4, 5],\n",
717 | " [7, 8]])"
718 | ]
719 | },
720 | "execution_count": 178,
721 | "metadata": {},
722 | "output_type": "execute_result"
723 | }
724 | ],
725 | "source": [
726 | "arr_copy[1:,:2]"
727 | ]
728 | },
729 | {
730 | "cell_type": "code",
731 | "execution_count": 179,
732 | "id": "df1c8e69-8a8f-4c4a-9335-4eac25fe8bde",
733 | "metadata": {},
734 | "outputs": [],
735 | "source": [
736 | "arr_bool = arr_copy > 4"
737 | ]
738 | },
739 | {
740 | "cell_type": "code",
741 | "execution_count": 180,
742 | "id": "c9efd0d5-d984-4f91-b2d2-a46049540e07",
743 | "metadata": {},
744 | "outputs": [
745 | {
746 | "data": {
747 | "text/plain": [
748 | "array([5, 6, 7, 8, 9])"
749 | ]
750 | },
751 | "execution_count": 180,
752 | "metadata": {},
753 | "output_type": "execute_result"
754 | }
755 | ],
756 | "source": [
757 | "arr_copy[arr_bool]"
758 | ]
759 | },
760 | {
761 | "cell_type": "code",
762 | "execution_count": 185,
763 | "id": "4c753625-9fed-4846-a8db-fe8ab190eaae",
764 | "metadata": {},
765 | "outputs": [
766 | {
767 | "data": {
768 | "text/plain": [
769 | "45"
770 | ]
771 | },
772 | "execution_count": 185,
773 | "metadata": {},
774 | "output_type": "execute_result"
775 | }
776 | ],
777 | "source": [
778 | "arr_copy.sum()"
779 | ]
780 | },
781 | {
782 | "cell_type": "code",
783 | "execution_count": 186,
784 | "id": "eb4be50c-2fe0-4a58-81c0-54156e9aeb1d",
785 | "metadata": {},
786 | "outputs": [
787 | {
788 | "data": {
789 | "text/plain": [
790 | "5.0"
791 | ]
792 | },
793 | "execution_count": 186,
794 | "metadata": {},
795 | "output_type": "execute_result"
796 | }
797 | ],
798 | "source": [
799 | "arr_copy.mean()"
800 | ]
801 | },
802 | {
803 | "cell_type": "code",
804 | "execution_count": 187,
805 | "id": "279c5632-78aa-481c-b26e-54d4b1679a2c",
806 | "metadata": {},
807 | "outputs": [],
808 | "source": [
809 | "arr_5_5 = np.arange(25).reshape(5,5)"
810 | ]
811 | },
812 | {
813 | "cell_type": "code",
814 | "execution_count": 188,
815 | "id": "36d0b85e-30cf-471a-a032-cb0a2ebc5c66",
816 | "metadata": {},
817 | "outputs": [
818 | {
819 | "data": {
820 | "text/plain": [
821 | "array([[ 0, 1, 2, 3, 4],\n",
822 | " [ 5, 6, 7, 8, 9],\n",
823 | " [10, 11, 12, 13, 14],\n",
824 | " [15, 16, 17, 18, 19],\n",
825 | " [20, 21, 22, 23, 24]])"
826 | ]
827 | },
828 | "execution_count": 188,
829 | "metadata": {},
830 | "output_type": "execute_result"
831 | }
832 | ],
833 | "source": [
834 | "arr_5_5"
835 | ]
836 | },
837 | {
838 | "cell_type": "code",
839 | "execution_count": 190,
840 | "id": "0ef86885-5728-456b-a970-8d5cb2531147",
841 | "metadata": {},
842 | "outputs": [
843 | {
844 | "data": {
845 | "text/plain": [
846 | "array([50, 55, 60, 65, 70])"
847 | ]
848 | },
849 | "execution_count": 190,
850 | "metadata": {},
851 | "output_type": "execute_result"
852 | }
853 | ],
854 | "source": [
855 | "# column by column \n",
856 | "arr_5_5.sum(axis = 0)"
857 | ]
858 | },
859 | {
860 | "cell_type": "code",
861 | "execution_count": 191,
862 | "id": "c0f647f1-4f5d-43e0-b67d-4cf99c9ede17",
863 | "metadata": {},
864 | "outputs": [
865 | {
866 | "data": {
867 | "text/plain": [
868 | "array([ 10, 35, 60, 85, 110])"
869 | ]
870 | },
871 | "execution_count": 191,
872 | "metadata": {},
873 | "output_type": "execute_result"
874 | }
875 | ],
876 | "source": [
877 | "# row by row\n",
878 | "arr_5_5.sum(axis = 1)"
879 | ]
880 | },
881 | {
882 | "cell_type": "code",
883 | "execution_count": 192,
884 | "id": "057bff41-68bc-4f28-876f-f724e251ade3",
885 | "metadata": {},
886 | "outputs": [
887 | {
888 | "data": {
889 | "text/plain": [
890 | "array([ 2., 7., 12., 17., 22.])"
891 | ]
892 | },
893 | "execution_count": 192,
894 | "metadata": {},
895 | "output_type": "execute_result"
896 | }
897 | ],
898 | "source": [
899 | "# average of first row \n",
900 | "arr_5_5.mean(axis=1)"
901 | ]
902 | },
903 | {
904 | "cell_type": "code",
905 | "execution_count": null,
906 | "id": "bbac4955-4e1b-47ff-9419-40f7804ef064",
907 | "metadata": {},
908 | "outputs": [],
909 | "source": []
910 | }
911 | ],
912 | "metadata": {
913 | "kernelspec": {
914 | "display_name": "Python 3 (ipykernel)",
915 | "language": "python",
916 | "name": "python3"
917 | },
918 | "language_info": {
919 | "codemirror_mode": {
920 | "name": "ipython",
921 | "version": 3
922 | },
923 | "file_extension": ".py",
924 | "mimetype": "text/x-python",
925 | "name": "python",
926 | "nbconvert_exporter": "python",
927 | "pygments_lexer": "ipython3",
928 | "version": "3.8.10"
929 | }
930 | },
931 | "nbformat": 4,
932 | "nbformat_minor": 5
933 | }
934 |
--------------------------------------------------------------------------------
/Exercise Notebooks/.ipynb_checkpoints/Playing_With_Numpy_Library-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "id": "b9499a42-604e-41af-889d-140cec4baace",
7 | "metadata": {},
8 | "outputs": [],
9 | "source": [
10 | "import numpy as np"
11 | ]
12 | },
13 | {
14 | "cell_type": "code",
15 | "execution_count": 2,
16 | "id": "38d272a3-447f-4636-8341-76827f10a53a",
17 | "metadata": {},
18 | "outputs": [],
19 | "source": [
20 | "first_array = np.array([[10,20,30],[40,50,60]])"
21 | ]
22 | },
23 | {
24 | "cell_type": "code",
25 | "execution_count": 3,
26 | "id": "454e89e1-c805-4845-9e84-0ae931dfd351",
27 | "metadata": {},
28 | "outputs": [
29 | {
30 | "name": "stdout",
31 | "output_type": "stream",
32 | "text": [
33 | "[[10 20 30]\n",
34 | " [40 50 60]]\n"
35 | ]
36 | }
37 | ],
38 | "source": [
39 | "print(first_array)"
40 | ]
41 | },
42 | {
43 | "cell_type": "code",
44 | "execution_count": 4,
45 | "id": "087623e2-973f-4208-9335-5557b11d42c6",
46 | "metadata": {},
47 | "outputs": [
48 | {
49 | "name": "stdout",
50 | "output_type": "stream",
51 | "text": [
52 | "[10 20 30]\n",
53 | "[40 50 60]\n"
54 | ]
55 | }
56 | ],
57 | "source": [
58 | "for i in first_array:\n",
59 | " print(i)"
60 | ]
61 | },
62 | {
63 | "cell_type": "code",
64 | "execution_count": 5,
65 | "id": "ce319ee7-24f1-4446-aaa8-90d8b548cefd",
66 | "metadata": {},
67 | "outputs": [
68 | {
69 | "name": "stdout",
70 | "output_type": "stream",
71 | "text": [
72 | "10\n",
73 | "20\n",
74 | "30\n",
75 | "40\n",
76 | "50\n",
77 | "60\n"
78 | ]
79 | }
80 | ],
81 | "source": [
82 | "for i in first_array:\n",
83 | " for j in i: \n",
84 | " print(j)"
85 | ]
86 | },
87 | {
88 | "cell_type": "code",
89 | "execution_count": 6,
90 | "id": "b6f37ae7-e18a-46ca-8945-16beed12a5cf",
91 | "metadata": {},
92 | "outputs": [
93 | {
94 | "data": {
95 | "text/plain": [
96 | "numpy.ndarray"
97 | ]
98 | },
99 | "execution_count": 6,
100 | "metadata": {},
101 | "output_type": "execute_result"
102 | }
103 | ],
104 | "source": [
105 | "type(first_array)"
106 | ]
107 | },
108 | {
109 | "cell_type": "code",
110 | "execution_count": 7,
111 | "id": "8df5ae2f-4686-4ea3-a1c6-5399d4baa8f7",
112 | "metadata": {},
113 | "outputs": [],
114 | "source": [
115 | "second_array = np.array(range(100))"
116 | ]
117 | },
118 | {
119 | "cell_type": "code",
120 | "execution_count": 8,
121 | "id": "2fe72892-2c3c-4511-ac1c-3c448c5c06c5",
122 | "metadata": {},
123 | "outputs": [
124 | {
125 | "name": "stdout",
126 | "output_type": "stream",
127 | "text": [
128 | "[[ 0 1 2 3 4 5 6 7 8 9]\n",
129 | " [10 11 12 13 14 15 16 17 18 19]\n",
130 | " [20 21 22 23 24 25 26 27 28 29]\n",
131 | " [30 31 32 33 34 35 36 37 38 39]\n",
132 | " [40 41 42 43 44 45 46 47 48 49]\n",
133 | " [50 51 52 53 54 55 56 57 58 59]\n",
134 | " [60 61 62 63 64 65 66 67 68 69]\n",
135 | " [70 71 72 73 74 75 76 77 78 79]\n",
136 | " [80 81 82 83 84 85 86 87 88 89]\n",
137 | " [90 91 92 93 94 95 96 97 98 99]]\n"
138 | ]
139 | }
140 | ],
141 | "source": [
142 | "print(second_array.reshape(10,10))"
143 | ]
144 | },
145 | {
146 | "cell_type": "code",
147 | "execution_count": 9,
148 | "id": "063b49a8-c352-4551-8a27-27287ca1d8df",
149 | "metadata": {},
150 | "outputs": [],
151 | "source": [
152 | "third_array = np.array([[[0,1],[2,3]],[[4,5],[6,7]]])"
153 | ]
154 | },
155 | {
156 | "cell_type": "code",
157 | "execution_count": 10,
158 | "id": "75c84eba-6475-4b62-8268-448d1c54f44b",
159 | "metadata": {},
160 | "outputs": [
161 | {
162 | "name": "stdout",
163 | "output_type": "stream",
164 | "text": [
165 | "0\n",
166 | "1\n",
167 | "2\n",
168 | "3\n",
169 | "4\n",
170 | "5\n",
171 | "6\n",
172 | "7\n"
173 | ]
174 | }
175 | ],
176 | "source": [
177 | "for i in third_array:\n",
178 | " for j in i:\n",
179 | " for k in j:\n",
180 | " print(k)"
181 | ]
182 | },
183 | {
184 | "cell_type": "code",
185 | "execution_count": 11,
186 | "id": "a115da36-4f4f-46fa-acd0-e6b0adb34b3d",
187 | "metadata": {},
188 | "outputs": [
189 | {
190 | "name": "stdout",
191 | "output_type": "stream",
192 | "text": [
193 | "0\n",
194 | "1\n",
195 | "2\n",
196 | "3\n",
197 | "4\n",
198 | "5\n",
199 | "6\n",
200 | "7\n"
201 | ]
202 | }
203 | ],
204 | "source": [
205 | "for i in np.nditer(third_array):\n",
206 | " print(i)"
207 | ]
208 | },
209 | {
210 | "cell_type": "code",
211 | "execution_count": 12,
212 | "id": "743b8459-08b7-47e7-ad8b-d62a953ac6df",
213 | "metadata": {},
214 | "outputs": [
215 | {
216 | "name": "stdout",
217 | "output_type": "stream",
218 | "text": [
219 | "(0, 0, 0) 0\n",
220 | "(0, 0, 1) 1\n",
221 | "(0, 1, 0) 2\n",
222 | "(0, 1, 1) 3\n",
223 | "(1, 0, 0) 4\n",
224 | "(1, 0, 1) 5\n",
225 | "(1, 1, 0) 6\n",
226 | "(1, 1, 1) 7\n"
227 | ]
228 | }
229 | ],
230 | "source": [
231 | "# hey, binary to decimal system, I'm lucky :)\n",
232 | "for i,j in np.ndenumerate(third_array):\n",
233 | " print(i,j)"
234 | ]
235 | },
236 | {
237 | "cell_type": "code",
238 | "execution_count": 13,
239 | "id": "9dfdf998-bc9f-420f-b9bb-32644c931ab7",
240 | "metadata": {},
241 | "outputs": [],
242 | "source": [
243 | "python_list = [[1,2] , [3,4] , [5,6]]"
244 | ]
245 | },
246 | {
247 | "cell_type": "code",
248 | "execution_count": 14,
249 | "id": "eaf4b23c-b1ab-4d0f-8b12-07a12cf5b8a5",
250 | "metadata": {},
251 | "outputs": [
252 | {
253 | "data": {
254 | "text/plain": [
255 | "array([[1, 2],\n",
256 | " [3, 4],\n",
257 | " [5, 6]])"
258 | ]
259 | },
260 | "execution_count": 14,
261 | "metadata": {},
262 | "output_type": "execute_result"
263 | }
264 | ],
265 | "source": [
266 | "np.array(python_list)"
267 | ]
268 | },
269 | {
270 | "cell_type": "code",
271 | "execution_count": 15,
272 | "id": "e56dbf39-4f4a-42ff-80fb-bb66001a4565",
273 | "metadata": {},
274 | "outputs": [
275 | {
276 | "data": {
277 | "text/plain": [
278 | "array([ 0, 2, 4, 6, 8, 10])"
279 | ]
280 | },
281 | "execution_count": 15,
282 | "metadata": {},
283 | "output_type": "execute_result"
284 | }
285 | ],
286 | "source": [
287 | "np.arange(0,11,2)"
288 | ]
289 | },
290 | {
291 | "cell_type": "code",
292 | "execution_count": 16,
293 | "id": "99989246-c773-4893-b9c6-1b4c9d27c2fe",
294 | "metadata": {},
295 | "outputs": [
296 | {
297 | "data": {
298 | "text/plain": [
299 | "array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])"
300 | ]
301 | },
302 | "execution_count": 16,
303 | "metadata": {},
304 | "output_type": "execute_result"
305 | }
306 | ],
307 | "source": [
308 | "np.zeros(10 , int)"
309 | ]
310 | },
311 | {
312 | "cell_type": "code",
313 | "execution_count": 17,
314 | "id": "fca3b98f-0da3-4c82-ae40-300f132603e8",
315 | "metadata": {},
316 | "outputs": [
317 | {
318 | "data": {
319 | "text/plain": [
320 | "array([[0, 0, 0],\n",
321 | " [0, 0, 0],\n",
322 | " [0, 0, 0]])"
323 | ]
324 | },
325 | "execution_count": 17,
326 | "metadata": {},
327 | "output_type": "execute_result"
328 | }
329 | ],
330 | "source": [
331 | "np.zeros((3,3) , int)"
332 | ]
333 | },
334 | {
335 | "cell_type": "code",
336 | "execution_count": 18,
337 | "id": "e268c25d-4581-4441-9c4f-e956316e9bfc",
338 | "metadata": {},
339 | "outputs": [
340 | {
341 | "data": {
342 | "text/plain": [
343 | "array([[[1., 1., 1., 1.],\n",
344 | " [1., 1., 1., 1.]],\n",
345 | "\n",
346 | " [[1., 1., 1., 1.],\n",
347 | " [1., 1., 1., 1.]],\n",
348 | "\n",
349 | " [[1., 1., 1., 1.],\n",
350 | " [1., 1., 1., 1.]],\n",
351 | "\n",
352 | " [[1., 1., 1., 1.],\n",
353 | " [1., 1., 1., 1.]],\n",
354 | "\n",
355 | " [[1., 1., 1., 1.],\n",
356 | " [1., 1., 1., 1.]]])"
357 | ]
358 | },
359 | "execution_count": 18,
360 | "metadata": {},
361 | "output_type": "execute_result"
362 | }
363 | ],
364 | "source": [
365 | "np.ones((5,2,4))"
366 | ]
367 | },
368 | {
369 | "cell_type": "code",
370 | "execution_count": 19,
371 | "id": "3b116d19-1650-46c5-8257-369c50b23cf2",
372 | "metadata": {},
373 | "outputs": [
374 | {
375 | "data": {
376 | "text/plain": [
377 | "array([[1, 0, 0],\n",
378 | " [0, 1, 0],\n",
379 | " [0, 0, 1]])"
380 | ]
381 | },
382 | "execution_count": 19,
383 | "metadata": {},
384 | "output_type": "execute_result"
385 | }
386 | ],
387 | "source": [
388 | "#diagonal matrices\n",
389 | "np.eye(3,dtype=int)"
390 | ]
391 | },
392 | {
393 | "cell_type": "code",
394 | "execution_count": 20,
395 | "id": "14348881-36f8-4385-929a-767be93da987",
396 | "metadata": {},
397 | "outputs": [
398 | {
399 | "data": {
400 | "text/plain": [
401 | "array([[0.23125289, 0.17657115, 0.73858594],\n",
402 | " [0.34483192, 0.40058807, 0.39550327],\n",
403 | " [0.37153114, 0.40700279, 0.77381529]])"
404 | ]
405 | },
406 | "execution_count": 20,
407 | "metadata": {},
408 | "output_type": "execute_result"
409 | }
410 | ],
411 | "source": [
412 | "#between 0 and 1\n",
413 | "np.random.rand(3,3)"
414 | ]
415 | },
416 | {
417 | "cell_type": "code",
418 | "execution_count": 21,
419 | "id": "90199006-29a6-489c-ae4a-589652d6292d",
420 | "metadata": {},
421 | "outputs": [
422 | {
423 | "data": {
424 | "text/plain": [
425 | "array([[ 0.43468629, 0.77698343, -0.26364651, 0.71574969],\n",
426 | " [-0.4778537 , -1.68156296, 0.85724506, 0.54020524]])"
427 | ]
428 | },
429 | "execution_count": 21,
430 | "metadata": {},
431 | "output_type": "execute_result"
432 | }
433 | ],
434 | "source": [
435 | "# standard distribution contain variance number(negetive)\n",
436 | "np.random.randn(2,4)"
437 | ]
438 | },
439 | {
440 | "cell_type": "code",
441 | "execution_count": 22,
442 | "id": "47667242-00bb-40d2-b3a7-2632f4190950",
443 | "metadata": {},
444 | "outputs": [
445 | {
446 | "data": {
447 | "text/plain": [
448 | "array([[35, 47, 26, 4, 48],\n",
449 | " [42, 25, 16, 27, 10],\n",
450 | " [35, 27, 17, 31, 18]])"
451 | ]
452 | },
453 | "execution_count": 22,
454 | "metadata": {},
455 | "output_type": "execute_result"
456 | }
457 | ],
458 | "source": [
459 | "np.random.randint(0,50,(3,5))"
460 | ]
461 | },
462 | {
463 | "cell_type": "code",
464 | "execution_count": 23,
465 | "id": "e099b25c-c09a-403a-ad76-260fb4ebf380",
466 | "metadata": {},
467 | "outputs": [
468 | {
469 | "data": {
470 | "text/plain": [
471 | "array([51, 92, 14, 71, 60, 20, 82, 86, 74, 74])"
472 | ]
473 | },
474 | "execution_count": 23,
475 | "metadata": {},
476 | "output_type": "execute_result"
477 | }
478 | ],
479 | "source": [
480 | "# but this section doesn't change any compile and default value with np.random.seed()\n",
481 | "# especially in machine learning algorithms\n",
482 | "np.random.seed(42)\n",
483 | "np.random.randint(0,100,10)"
484 | ]
485 | },
486 | {
487 | "cell_type": "code",
488 | "execution_count": 24,
489 | "id": "33039e74-390f-4f16-a61e-e081aac46ead",
490 | "metadata": {},
491 | "outputs": [
492 | {
493 | "data": {
494 | "text/plain": [
495 | "array([87, 99, 23, 2, 21, 52, 1, 87, 29, 37])"
496 | ]
497 | },
498 | "execution_count": 24,
499 | "metadata": {},
500 | "output_type": "execute_result"
501 | }
502 | ],
503 | "source": [
504 | "# in any compile reproduce new value\n",
505 | "np.random.randint(0,100,10)"
506 | ]
507 | },
508 | {
509 | "cell_type": "code",
510 | "execution_count": 25,
511 | "id": "1b0e1455-9b5b-4b9d-b813-0395cbdac563",
512 | "metadata": {},
513 | "outputs": [],
514 | "source": [
515 | "ex_arr = np.random.randint(0,100,10)"
516 | ]
517 | },
518 | {
519 | "cell_type": "code",
520 | "execution_count": 26,
521 | "id": "12543062-2799-4d00-8280-3dbb20dc2345",
522 | "metadata": {},
523 | "outputs": [
524 | {
525 | "data": {
526 | "text/plain": [
527 | "numpy.ndarray"
528 | ]
529 | },
530 | "execution_count": 26,
531 | "metadata": {},
532 | "output_type": "execute_result"
533 | }
534 | ],
535 | "source": [
536 | "type(ex_arr)"
537 | ]
538 | },
539 | {
540 | "cell_type": "code",
541 | "execution_count": 27,
542 | "id": "29f55460-b5f3-4b10-af0a-96086e975a57",
543 | "metadata": {},
544 | "outputs": [
545 | {
546 | "data": {
547 | "text/plain": [
548 | "dtype('int32')"
549 | ]
550 | },
551 | "execution_count": 27,
552 | "metadata": {},
553 | "output_type": "execute_result"
554 | }
555 | ],
556 | "source": [
557 | "ex_arr.dtype"
558 | ]
559 | },
560 | {
561 | "cell_type": "code",
562 | "execution_count": 28,
563 | "id": "4e4f3fa4-059e-43b7-ac97-fa60aa53ba6f",
564 | "metadata": {},
565 | "outputs": [
566 | {
567 | "data": {
568 | "text/plain": [
569 | "(10,)"
570 | ]
571 | },
572 | "execution_count": 28,
573 | "metadata": {},
574 | "output_type": "execute_result"
575 | }
576 | ],
577 | "source": [
578 | "ex_arr.shape"
579 | ]
580 | },
581 | {
582 | "cell_type": "code",
583 | "execution_count": 29,
584 | "id": "7f1ffe8c-23a0-4d38-82d8-df14d8450f1a",
585 | "metadata": {},
586 | "outputs": [
587 | {
588 | "data": {
589 | "text/plain": [
590 | "array([[ 1, 63, 59, 20, 32],\n",
591 | " [75, 57, 21, 88, 48]])"
592 | ]
593 | },
594 | "execution_count": 29,
595 | "metadata": {},
596 | "output_type": "execute_result"
597 | }
598 | ],
599 | "source": [
600 | "ex_arr.reshape(2,5)"
601 | ]
602 | },
603 | {
604 | "cell_type": "code",
605 | "execution_count": 30,
606 | "id": "adc377f2-3d76-430c-bb28-f30e99e6494f",
607 | "metadata": {},
608 | "outputs": [
609 | {
610 | "data": {
611 | "text/plain": [
612 | "88"
613 | ]
614 | },
615 | "execution_count": 30,
616 | "metadata": {},
617 | "output_type": "execute_result"
618 | }
619 | ],
620 | "source": [
621 | "ex_arr.max()"
622 | ]
623 | },
624 | {
625 | "cell_type": "code",
626 | "execution_count": 31,
627 | "id": "63c679b1-d835-4235-906d-1394a39c2df5",
628 | "metadata": {},
629 | "outputs": [
630 | {
631 | "data": {
632 | "text/plain": [
633 | "8"
634 | ]
635 | },
636 | "execution_count": 31,
637 | "metadata": {},
638 | "output_type": "execute_result"
639 | }
640 | ],
641 | "source": [
642 | "ex_arr.argmax()"
643 | ]
644 | },
645 | {
646 | "cell_type": "code",
647 | "execution_count": 32,
648 | "id": "01281f3f-5c31-400e-bd6d-8ef06210b964",
649 | "metadata": {},
650 | "outputs": [],
651 | "source": [
652 | "arr_2d = np.array([[1,2,3],[4,5,6],[7,8,9]])"
653 | ]
654 | },
655 | {
656 | "cell_type": "code",
657 | "execution_count": 33,
658 | "id": "4acc3789-fcca-4b5c-85d8-e33468c908c1",
659 | "metadata": {},
660 | "outputs": [
661 | {
662 | "data": {
663 | "text/plain": [
664 | "(3, 3)"
665 | ]
666 | },
667 | "execution_count": 33,
668 | "metadata": {},
669 | "output_type": "execute_result"
670 | }
671 | ],
672 | "source": [
673 | "arr_2d.shape"
674 | ]
675 | },
676 | {
677 | "cell_type": "code",
678 | "execution_count": 34,
679 | "id": "fb9f7640-d7f7-4706-bde2-c336c792ee5f",
680 | "metadata": {},
681 | "outputs": [
682 | {
683 | "data": {
684 | "text/plain": [
685 | "array([[4, 5, 6]])"
686 | ]
687 | },
688 | "execution_count": 34,
689 | "metadata": {},
690 | "output_type": "execute_result"
691 | }
692 | ],
693 | "source": [
694 | "arr_2d[1:2]"
695 | ]
696 | },
697 | {
698 | "cell_type": "code",
699 | "execution_count": 35,
700 | "id": "7006585b-a31e-4bec-8504-672431ada2aa",
701 | "metadata": {},
702 | "outputs": [],
703 | "source": [
704 | "arr_copy = arr_2d.copy()"
705 | ]
706 | },
707 | {
708 | "cell_type": "code",
709 | "execution_count": 36,
710 | "id": "50733767-33f8-4665-8340-3fef829da337",
711 | "metadata": {},
712 | "outputs": [
713 | {
714 | "data": {
715 | "text/plain": [
716 | "array([[4, 5],\n",
717 | " [7, 8]])"
718 | ]
719 | },
720 | "execution_count": 36,
721 | "metadata": {},
722 | "output_type": "execute_result"
723 | }
724 | ],
725 | "source": [
726 | "arr_copy[1:,:2]"
727 | ]
728 | },
729 | {
730 | "cell_type": "code",
731 | "execution_count": 37,
732 | "id": "df1c8e69-8a8f-4c4a-9335-4eac25fe8bde",
733 | "metadata": {},
734 | "outputs": [],
735 | "source": [
736 | "arr_bool = arr_copy > 4"
737 | ]
738 | },
739 | {
740 | "cell_type": "code",
741 | "execution_count": 38,
742 | "id": "c9efd0d5-d984-4f91-b2d2-a46049540e07",
743 | "metadata": {},
744 | "outputs": [
745 | {
746 | "data": {
747 | "text/plain": [
748 | "array([5, 6, 7, 8, 9])"
749 | ]
750 | },
751 | "execution_count": 38,
752 | "metadata": {},
753 | "output_type": "execute_result"
754 | }
755 | ],
756 | "source": [
757 | "arr_copy[arr_bool]"
758 | ]
759 | },
760 | {
761 | "cell_type": "code",
762 | "execution_count": 39,
763 | "id": "4c753625-9fed-4846-a8db-fe8ab190eaae",
764 | "metadata": {},
765 | "outputs": [
766 | {
767 | "data": {
768 | "text/plain": [
769 | "45"
770 | ]
771 | },
772 | "execution_count": 39,
773 | "metadata": {},
774 | "output_type": "execute_result"
775 | }
776 | ],
777 | "source": [
778 | "arr_copy.sum()"
779 | ]
780 | },
781 | {
782 | "cell_type": "code",
783 | "execution_count": 40,
784 | "id": "eb4be50c-2fe0-4a58-81c0-54156e9aeb1d",
785 | "metadata": {},
786 | "outputs": [
787 | {
788 | "data": {
789 | "text/plain": [
790 | "5.0"
791 | ]
792 | },
793 | "execution_count": 40,
794 | "metadata": {},
795 | "output_type": "execute_result"
796 | }
797 | ],
798 | "source": [
799 | "arr_copy.mean()"
800 | ]
801 | },
802 | {
803 | "cell_type": "code",
804 | "execution_count": 41,
805 | "id": "279c5632-78aa-481c-b26e-54d4b1679a2c",
806 | "metadata": {},
807 | "outputs": [],
808 | "source": [
809 | "arr_5_5 = np.arange(25).reshape(5,5)"
810 | ]
811 | },
812 | {
813 | "cell_type": "code",
814 | "execution_count": 42,
815 | "id": "36d0b85e-30cf-471a-a032-cb0a2ebc5c66",
816 | "metadata": {},
817 | "outputs": [
818 | {
819 | "data": {
820 | "text/plain": [
821 | "array([[ 0, 1, 2, 3, 4],\n",
822 | " [ 5, 6, 7, 8, 9],\n",
823 | " [10, 11, 12, 13, 14],\n",
824 | " [15, 16, 17, 18, 19],\n",
825 | " [20, 21, 22, 23, 24]])"
826 | ]
827 | },
828 | "execution_count": 42,
829 | "metadata": {},
830 | "output_type": "execute_result"
831 | }
832 | ],
833 | "source": [
834 | "arr_5_5"
835 | ]
836 | },
837 | {
838 | "cell_type": "code",
839 | "execution_count": 43,
840 | "id": "0ef86885-5728-456b-a970-8d5cb2531147",
841 | "metadata": {},
842 | "outputs": [
843 | {
844 | "data": {
845 | "text/plain": [
846 | "array([50, 55, 60, 65, 70])"
847 | ]
848 | },
849 | "execution_count": 43,
850 | "metadata": {},
851 | "output_type": "execute_result"
852 | }
853 | ],
854 | "source": [
855 | "# column by column \n",
856 | "arr_5_5.sum(axis = 0)"
857 | ]
858 | },
859 | {
860 | "cell_type": "code",
861 | "execution_count": 44,
862 | "id": "c0f647f1-4f5d-43e0-b67d-4cf99c9ede17",
863 | "metadata": {},
864 | "outputs": [
865 | {
866 | "data": {
867 | "text/plain": [
868 | "array([ 10, 35, 60, 85, 110])"
869 | ]
870 | },
871 | "execution_count": 44,
872 | "metadata": {},
873 | "output_type": "execute_result"
874 | }
875 | ],
876 | "source": [
877 | "# row by row\n",
878 | "arr_5_5.sum(axis = 1)"
879 | ]
880 | },
881 | {
882 | "cell_type": "code",
883 | "execution_count": 45,
884 | "id": "057bff41-68bc-4f28-876f-f724e251ade3",
885 | "metadata": {},
886 | "outputs": [
887 | {
888 | "data": {
889 | "text/plain": [
890 | "array([ 2., 7., 12., 17., 22.])"
891 | ]
892 | },
893 | "execution_count": 45,
894 | "metadata": {},
895 | "output_type": "execute_result"
896 | }
897 | ],
898 | "source": [
899 | "# average of first row \n",
900 | "arr_5_5.mean(axis=1)"
901 | ]
902 | },
903 | {
904 | "cell_type": "code",
905 | "execution_count": 48,
906 | "id": "bbac4955-4e1b-47ff-9419-40f7804ef064",
907 | "metadata": {},
908 | "outputs": [
909 | {
910 | "data": {
911 | "text/plain": [
912 | "array([1, 2, 3, 4, 5, 6, 7, 8, 9])"
913 | ]
914 | },
915 | "execution_count": 48,
916 | "metadata": {},
917 | "output_type": "execute_result"
918 | }
919 | ],
920 | "source": [
921 | "# use in neural networks to flat the array \n",
922 | "arr_2d.flatten()"
923 | ]
924 | },
925 | {
926 | "cell_type": "code",
927 | "execution_count": 51,
928 | "id": "6206f7a9-d696-4ae6-bea5-6ec11165ee28",
929 | "metadata": {},
930 | "outputs": [
931 | {
932 | "data": {
933 | "text/plain": [
934 | "array([[1, 2, 3],\n",
935 | " [4, 5, 6],\n",
936 | " [7, 8, 9]])"
937 | ]
938 | },
939 | "execution_count": 51,
940 | "metadata": {},
941 | "output_type": "execute_result"
942 | }
943 | ],
944 | "source": [
945 | "arr_2d"
946 | ]
947 | },
948 | {
949 | "cell_type": "code",
950 | "execution_count": 53,
951 | "id": "9e912888-02c1-4549-b84f-ee4c99a55225",
952 | "metadata": {},
953 | "outputs": [
954 | {
955 | "data": {
956 | "text/plain": [
957 | "array([7, 8, 9])"
958 | ]
959 | },
960 | "execution_count": 53,
961 | "metadata": {},
962 | "output_type": "execute_result"
963 | }
964 | ],
965 | "source": [
966 | "arr_2d.max(axis=0)"
967 | ]
968 | },
969 | {
970 | "cell_type": "code",
971 | "execution_count": 55,
972 | "id": "9cca3470-c8fa-4719-9897-2b46e198fb47",
973 | "metadata": {},
974 | "outputs": [
975 | {
976 | "data": {
977 | "text/plain": [
978 | "array([1, 4, 7])"
979 | ]
980 | },
981 | "execution_count": 55,
982 | "metadata": {},
983 | "output_type": "execute_result"
984 | }
985 | ],
986 | "source": [
987 | "arr_2d.min(axis=1)"
988 | ]
989 | },
990 | {
991 | "cell_type": "code",
992 | "execution_count": 58,
993 | "id": "5448699e-68fd-4478-b023-d938f8c99625",
994 | "metadata": {},
995 | "outputs": [
996 | {
997 | "data": {
998 | "text/plain": [
999 | "array([[0, 0, 0],\n",
1000 | " [0, 1, 1],\n",
1001 | " [1, 1, 1]])"
1002 | ]
1003 | },
1004 | "execution_count": 58,
1005 | "metadata": {},
1006 | "output_type": "execute_result"
1007 | }
1008 | ],
1009 | "source": [
1010 | "# condition in array use np.where \n",
1011 | "np.where(arr_2d >= 5 , 1 , 0)"
1012 | ]
1013 | },
1014 | {
1015 | "cell_type": "code",
1016 | "execution_count": 73,
1017 | "id": "1d6157c6-e908-4dba-8c97-10ec4e7edb53",
1018 | "metadata": {},
1019 | "outputs": [],
1020 | "source": [
1021 | "np.random.shuffle(arr_5_5)\n",
1022 | "np.random.seed(55)"
1023 | ]
1024 | },
1025 | {
1026 | "cell_type": "code",
1027 | "execution_count": 74,
1028 | "id": "e483a583-ba09-4509-8766-a1dca3c61f46",
1029 | "metadata": {},
1030 | "outputs": [
1031 | {
1032 | "data": {
1033 | "text/plain": [
1034 | "array([[20, 21, 22, 23, 24],\n",
1035 | " [ 5, 6, 7, 8, 9],\n",
1036 | " [15, 16, 17, 18, 19],\n",
1037 | " [10, 11, 12, 13, 14],\n",
1038 | " [ 0, 1, 2, 3, 4]])"
1039 | ]
1040 | },
1041 | "execution_count": 74,
1042 | "metadata": {},
1043 | "output_type": "execute_result"
1044 | }
1045 | ],
1046 | "source": [
1047 | "arr_5_5"
1048 | ]
1049 | },
1050 | {
1051 | "cell_type": "code",
1052 | "execution_count": 83,
1053 | "id": "80241cb5-638a-4f07-be24-eb37d5ea4277",
1054 | "metadata": {},
1055 | "outputs": [
1056 | {
1057 | "data": {
1058 | "text/plain": [
1059 | "array([8, 1, 5, 0, 7, 2, 9, 4, 3, 6])"
1060 | ]
1061 | },
1062 | "execution_count": 83,
1063 | "metadata": {},
1064 | "output_type": "execute_result"
1065 | }
1066 | ],
1067 | "source": [
1068 | "np.random.seed(42)\n",
1069 | "np.random.permutation(10)"
1070 | ]
1071 | },
1072 | {
1073 | "cell_type": "code",
1074 | "execution_count": 85,
1075 | "id": "f5024991-565c-4aef-a7ad-903bc6825b84",
1076 | "metadata": {},
1077 | "outputs": [
1078 | {
1079 | "data": {
1080 | "text/plain": [
1081 | "array([[20, 21, 22, 23, 24],\n",
1082 | " [ 5, 6, 7, 8, 9],\n",
1083 | " [15, 16, 17, 18, 19],\n",
1084 | " [10, 11, 12, 13, 14],\n",
1085 | " [ 0, 1, 2, 3, 4]])"
1086 | ]
1087 | },
1088 | "execution_count": 85,
1089 | "metadata": {},
1090 | "output_type": "execute_result"
1091 | }
1092 | ],
1093 | "source": [
1094 | "np.random.permutation(arr_5_5)"
1095 | ]
1096 | },
1097 | {
1098 | "cell_type": "code",
1099 | "execution_count": 104,
1100 | "id": "ac266379-2e8e-42d7-a5ce-492bc9da32f9",
1101 | "metadata": {},
1102 | "outputs": [
1103 | {
1104 | "data": {
1105 | "text/plain": [
1106 | "[6, 7, 5]"
1107 | ]
1108 | },
1109 | "execution_count": 104,
1110 | "metadata": {},
1111 | "output_type": "execute_result"
1112 | }
1113 | ],
1114 | "source": [
1115 | "from random import sample \n",
1116 | "sample([2,5,6,7,8,9], 3)\n"
1117 | ]
1118 | }
1119 | ],
1120 | "metadata": {
1121 | "kernelspec": {
1122 | "display_name": "Python 3 (ipykernel)",
1123 | "language": "python",
1124 | "name": "python3"
1125 | },
1126 | "language_info": {
1127 | "codemirror_mode": {
1128 | "name": "ipython",
1129 | "version": 3
1130 | },
1131 | "file_extension": ".py",
1132 | "mimetype": "text/x-python",
1133 | "name": "python",
1134 | "nbconvert_exporter": "python",
1135 | "pygments_lexer": "ipython3",
1136 | "version": "3.8.10"
1137 | }
1138 | },
1139 | "nbformat": 4,
1140 | "nbformat_minor": 5
1141 | }
1142 |
--------------------------------------------------------------------------------
/Exercise Notebooks/.ipynb_checkpoints/Training_a_Convolutional_Layer_With_Recognition_Model_Using_Pytorch_on_the_MNIST_Dataset-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 5
6 | }
7 |
--------------------------------------------------------------------------------
/Exercise Notebooks/Data/Data_model_CIFAR-10.h5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YasinRezvani/Hands_On_Machine_Learning_and_Deep_Learning_with_Python/0f1876aa3e18636857a38aac46fc2f0843a009f8/Exercise Notebooks/Data/Data_model_CIFAR-10.h5
--------------------------------------------------------------------------------
/Exercise Notebooks/Data/Data_model_CIFAR-10.json:
--------------------------------------------------------------------------------
1 | {"class_name": "Sequential", "config": {"name": "sequential_12", "layers": [{"module": "keras.layers", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 32, 32, 3], "dtype": "float32", "sparse": false, "ragged": false, "name": "input_13"}, "registered_name": null}, {"module": "keras.layers", "class_name": "Flatten", "config": {"name": "flatten_12", "trainable": true, "dtype": "float32", "data_format": "channels_last"}, "registered_name": null, "build_config": {"input_shape": [null, 32, 32, 3]}}, {"module": "keras.layers", "class_name": "Dense", "config": {"name": "dense_51", "trainable": true, "dtype": "float32", "units": 512, "activation": "relu", "use_bias": true, "kernel_initializer": {"module": "keras.initializers", "class_name": "GlorotUniform", "config": {"seed": null}, "registered_name": null}, "bias_initializer": {"module": "keras.initializers", "class_name": "Zeros", "config": {}, "registered_name": null}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "registered_name": null, "build_config": {"input_shape": [null, 3072]}}, {"module": "keras.layers", "class_name": "Dense", "config": {"name": "dense_52", "trainable": true, "dtype": "float32", "units": 512, "activation": "relu", "use_bias": true, "kernel_initializer": {"module": "keras.initializers", "class_name": "GlorotUniform", "config": {"seed": null}, "registered_name": null}, "bias_initializer": {"module": "keras.initializers", "class_name": "Zeros", "config": {}, "registered_name": null}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "registered_name": null, "build_config": {"input_shape": [null, 512]}}, {"module": "keras.layers", "class_name": "Dense", "config": {"name": "dense_53", "trainable": true, "dtype": "float32", "units": 512, "activation": "relu", "use_bias": true, "kernel_initializer": {"module": "keras.initializers", "class_name": "GlorotUniform", "config": {"seed": null}, "registered_name": null}, "bias_initializer": {"module": "keras.initializers", "class_name": "Zeros", "config": {}, "registered_name": null}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "registered_name": null, "build_config": {"input_shape": [null, 512]}}, {"module": "keras.layers", "class_name": "Dense", "config": {"name": "dense_54", "trainable": true, "dtype": "float32", "units": 512, "activation": "relu", "use_bias": true, "kernel_initializer": {"module": "keras.initializers", "class_name": "GlorotUniform", "config": {"seed": null}, "registered_name": null}, "bias_initializer": {"module": "keras.initializers", "class_name": "Zeros", "config": {}, "registered_name": null}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "registered_name": null, "build_config": {"input_shape": [null, 512]}}, {"module": "keras.layers", "class_name": "Dense", "config": {"name": "dense_55", "trainable": true, "dtype": "float32", "units": 512, "activation": "relu", "use_bias": true, "kernel_initializer": {"module": "keras.initializers", "class_name": "GlorotUniform", "config": {"seed": null}, "registered_name": null}, "bias_initializer": {"module": "keras.initializers", "class_name": "Zeros", "config": {}, "registered_name": null}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "registered_name": null, "build_config": {"input_shape": [null, 512]}}, {"module": "keras.layers", "class_name": "Dense", "config": {"name": "dense_56", "trainable": true, "dtype": "float32", "units": 512, "activation": "relu", "use_bias": true, "kernel_initializer": {"module": "keras.initializers", "class_name": "GlorotUniform", "config": {"seed": null}, "registered_name": null}, "bias_initializer": {"module": "keras.initializers", "class_name": "Zeros", "config": {}, "registered_name": null}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "registered_name": null, "build_config": {"input_shape": [null, 512]}}, {"module": "keras.layers", "class_name": "Dense", "config": {"name": "dense_57", "trainable": true, "dtype": "float32", "units": 512, "activation": "relu", "use_bias": true, "kernel_initializer": {"module": "keras.initializers", "class_name": "GlorotUniform", "config": {"seed": null}, "registered_name": null}, "bias_initializer": {"module": "keras.initializers", "class_name": "Zeros", "config": {}, "registered_name": null}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "registered_name": null, "build_config": {"input_shape": [null, 512]}}, {"module": "keras.layers", "class_name": "Dense", "config": {"name": "dense_58", "trainable": true, "dtype": "float32", "units": 512, "activation": "relu", "use_bias": true, "kernel_initializer": {"module": "keras.initializers", "class_name": "GlorotUniform", "config": {"seed": null}, "registered_name": null}, "bias_initializer": {"module": "keras.initializers", "class_name": "Zeros", "config": {}, "registered_name": null}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "registered_name": null, "build_config": {"input_shape": [null, 512]}}, {"module": "keras.layers", "class_name": "Dense", "config": {"name": "dense_59", "trainable": true, "dtype": "float32", "units": 512, "activation": "relu", "use_bias": true, "kernel_initializer": {"module": "keras.initializers", "class_name": "GlorotUniform", "config": {"seed": null}, "registered_name": null}, "bias_initializer": {"module": "keras.initializers", "class_name": "Zeros", "config": {}, "registered_name": null}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "registered_name": null, "build_config": {"input_shape": [null, 512]}}, {"module": "keras.layers", "class_name": "Dense", "config": {"name": "dense_60", "trainable": true, "dtype": "float32", "units": 10, "activation": "softmax", "use_bias": true, "kernel_initializer": {"module": "keras.initializers", "class_name": "GlorotUniform", "config": {"seed": null}, "registered_name": null}, "bias_initializer": {"module": "keras.initializers", "class_name": "Zeros", "config": {}, "registered_name": null}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "registered_name": null, "build_config": {"input_shape": [null, 512]}}]}, "keras_version": "2.15.0", "backend": "tensorflow"}
--------------------------------------------------------------------------------
/Exercise Notebooks/Data/Hand_Writing_Number_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YasinRezvani/Hands_On_Machine_Learning_and_Deep_Learning_with_Python/0f1876aa3e18636857a38aac46fc2f0843a009f8/Exercise Notebooks/Data/Hand_Writing_Number_4.png
--------------------------------------------------------------------------------
/Exercise Notebooks/Data/Universities.csv:
--------------------------------------------------------------------------------
1 | Sector,University,Year,Completions,Geography
2 | "Private for-profit, 2-year",Pima Medical Institute-Las Vegas,2016,591,Nevada
3 | "Private for-profit, less-than 2-year",Healthcare Preparatory Institute,2016,28,Nevada
4 | "Private for-profit, less-than 2-year",Milan Institute-Las Vegas,2016,408,Nevada
5 | "Private for-profit, less-than 2-year",Utah College of Massage Therapy-Vegas,2016,240,Nevada
6 | "Public, 4-year or above",Western Nevada College,2016,960,Nevada
7 | "Private for-profit, less-than 2-year",Advanced Training Institute,2016,372,Nevada
8 | "Public, 4-year or above",Great Basin College,2016,858,Nevada
9 | "Private for-profit, less-than 2-year",European Massage Therapy School-Las Vegas,2016,85,Nevada
10 | "Private for-profit, less-than 2-year",Institute of Professional Careers,2016,24,Nevada
11 | "Public, 4-year or above",Nevada State College,2016,420,Nevada
12 | "Private for-profit, less-than 2-year",Milan Institute-Sparks,2016,271,Nevada
13 | "Public, 4-year or above",University of Nevada-Las Vegas,2016,5367,Nevada
14 | "Private for-profit, less-than 2-year",Academy of Hair Design-Las Vegas,2016,124,Nevada
15 | "Private for-profit, 2-year",Northwest Career College,2016,208,Nevada
16 | "Public, 4-year or above",University of Nevada-Reno,2016,4309,Nevada
17 | "Private for-profit, 2-year",Le Cordon Bleu College of Culinary Arts-Las Vegas,2016,222,Nevada
18 | "Private not-for-profit, 4-year or above",Sierra Nevada College,2016,261,Nevada
19 | "Private not-for-profit, 4-year or above",Wongu University of Oriental Medicine,2016,0,Nevada
20 | "Private for-profit, 2-year",Carrington College-Reno,2016,165,Nevada
21 | "Private for-profit, 2-year",Carrington College-Las Vegas,2016,210,Nevada
22 | "Private not-for-profit, 4-year or above",Touro University Nevada,2016,356,Nevada
23 | "Public, 4-year or above",College of Southern Nevada,2016,4763,Nevada
24 | "Private not-for-profit, 4-year or above",Roseman University of Health Sciences,2016,591,Nevada
25 | "Private for-profit, 2-year",Brightwood College-Las Vegas,2016,581,Nevada
26 | "Private for-profit, 2-year",Career College of Northern Nevada,2016,299,Nevada
27 | "Private for-profit, 4-year or above",University of Phoenix-Nevada,2016,423,Nevada
28 | "Private for-profit, 4-year or above",Chamberlain College of Nursing-Nevada,2016,0,Nevada
29 | "Private for-profit, 4-year or above",Arizona College-Las Vegas,2016,0,Nevada
30 | "Private for-profit, 2-year",Aviation Institute of Maintenance-Las Vegas,2016,83,Nevada
31 | "Private for-profit, 2-year",Paul Mitchell the School-Reno,2016,74,Nevada
32 | "Private for-profit, 2-year",Paul Mitchell the School-Las Vegas,2016,156,Nevada
33 | "Private for-profit, 4-year or above",DeVry University-Nevada,2016,99,Nevada
34 | "Private for-profit, 2-year",International Academy of Style,2016,71,Nevada
35 | "Private for-profit, 4-year or above",The Art Institute of Las Vegas,2016,135,Nevada
36 | "Private for-profit, 2-year",Casal Institute of Nevada,2016,109,Nevada
37 | "Private for-profit, 2-year",Milan Institute of Cosmetology-Reno,2016,83,Nevada
38 | "Private for-profit, 4-year or above",Sanford-Brown College-Las Vegas,2016,91,Nevada
39 | "Private for-profit, 2-year",Euphoria Institute of Beauty Arts & Sciences-Green Valley,2016,96,Nevada
40 | "Private for-profit, 2-year",Euphoria Institute of Beauty Arts & Sciences-Summerlin,2016,187,Nevada
41 | "Public, 2-year",Truckee Meadows Community College,2016,2431,Nevada
42 | "Private for-profit, 2-year",Nevada Career Institute,2016,151,Nevada
43 | "Private not-for-profit, 2-year",Everest College-Henderson,2016,233,Nevada
44 | "Private not-for-profit, 2-year",Expertise Cosmetology Institute,2016,89,Nevada
45 | "Private for-profit, 2-year",Pima Medical Institute-Las Vegas,2015,597,Nevada
46 | "Private not-for-profit, 4-year or above",Roseman University of Health Sciences,2015,517,Nevada
47 | "Private for-profit, less-than 2-year",Milan Institute-Sparks,2015,320,Nevada
48 | "Public, 4-year or above",University of Nevada-Las Vegas,2015,5335,Nevada
49 | "Private for-profit, 2-year",Brightwood College-Las Vegas,2015,721,Nevada
50 | "Private for-profit, less-than 2-year",Healthcare Preparatory Institute,2015,38,Nevada
51 | "Private for-profit, 4-year or above",ITT Technical Institute-Las Vegas,2015,197,Nevada
52 | "Private for-profit, 2-year",Career College of Northern Nevada,2015,317,Nevada
53 | "Private for-profit, 4-year or above",University of Phoenix-Nevada,2015,600,Nevada
54 | "Private for-profit, less-than 2-year",Advanced Training Institute,2015,266,Nevada
55 | "Private for-profit, 4-year or above",Chamberlain College of Nursing-Nevada,2015,0,Nevada
56 | "Private for-profit, less-than 2-year",Academy of Hair Design-Las Vegas,2015,180,Nevada
57 | "Private for-profit, 4-year or above",Arizona College-Las Vegas,2015,0,Nevada
58 | "Public, 4-year or above",Great Basin College,2015,769,Nevada
59 | "Public, 4-year or above",University of Nevada-Reno,2015,4004,Nevada
60 | "Private for-profit, 2-year",Aviation Institute of Maintenance-Las Vegas,2015,29,Nevada
61 | "Private for-profit, less-than 2-year",Milan Institute-Las Vegas,2015,417,Nevada
62 | "Private for-profit, 4-year or above",ITT Technical Institute-Henderson,2015,127,Nevada
63 | "Private for-profit, 2-year",Paul Mitchell the School-Reno,2015,83,Nevada
64 | "Private for-profit, 2-year",Northwest Career College,2015,184,Nevada
65 | "Private for-profit, 4-year or above",DeVry University-Nevada,2015,108,Nevada
66 | "Public, 4-year or above",College of Southern Nevada,2015,4630,Nevada
67 | "Private for-profit, 2-year",Paul Mitchell the School-Las Vegas,2015,120,Nevada
68 | "Private for-profit, 2-year",Le Cordon Bleu College of Culinary Arts-Las Vegas,2015,138,Nevada
69 | "Private for-profit, 2-year",International Academy of Style,2015,84,Nevada
70 | "Private for-profit, 4-year or above",The Art Institute of Las Vegas,2015,185,Nevada
71 | "Private not-for-profit, 4-year or above",Sierra Nevada College,2015,309,Nevada
72 | "Private for-profit, less-than 2-year",European Massage Therapy School-Las Vegas,2015,67,Nevada
73 | "Private for-profit, 2-year",Casal Institute of Nevada,2015,108,Nevada
74 | "Public, 4-year or above",Western Nevada College,2015,925,Nevada
75 | "Private for-profit, 4-year or above",Sanford-Brown College-Las Vegas,2015,89,Nevada
76 | "Public, 4-year or above",Nevada State College,2015,393,Nevada
77 | "Private for-profit, 2-year",Milan Institute of Cosmetology-Reno,2015,82,Nevada
78 | "Private for-profit, 2-year",Carrington College-Reno,2015,205,Nevada
79 | "Private for-profit, 2-year",Euphoria Institute of Beauty Arts & Sciences-Green Valley,2015,78,Nevada
80 | "Public, 2-year",Truckee Meadows Community College,2015,2355,Nevada
81 | "Private not-for-profit, 4-year or above",Touro University Nevada,2015,402,Nevada
82 | "Private for-profit, 2-year",Euphoria Institute of Beauty Arts & Sciences-Summerlin,2015,162,Nevada
83 | "Private for-profit, less-than 2-year",Institute of Professional Careers,2015,25,Nevada
84 | "Private for-profit, 2-year",Nevada Career Institute,2015,169,Nevada
85 | "Private not-for-profit, 2-year",Everest College-Henderson,2015,357,Nevada
86 | "Private for-profit, 2-year",Carrington College-Las Vegas,2015,203,Nevada
87 | "Private for-profit, less-than 2-year",Utah College of Massage Therapy-Vegas,2015,316,Nevada
88 | "Private not-for-profit, 2-year",Expertise Cosmetology Institute,2015,68,Nevada
89 | "Private not-for-profit, 4-year or above",Roseman University of Health Sciences,2014,418,Nevada
90 | "Private not-for-profit, 2-year",Expertise Cosmetology Institute,2014,75,Nevada
91 | "Public, 4-year or above",College of Southern Nevada,2014,4608,Nevada
92 | "Private for-profit, less-than 2-year",Healthcare Preparatory Institute,2014,8,Nevada
93 | "Private for-profit, less-than 2-year",Milan Institute-Las Vegas,2014,224,Nevada
94 | "Private for-profit, 2-year",Nevada Career Institute,2014,130,Nevada
95 | "Private not-for-profit, 2-year",Everest College-Henderson,2014,374,Nevada
96 | "Public, 4-year or above",Western Nevada College,2014,842,Nevada
97 | "Private for-profit, less-than 2-year",Utah College of Massage Therapy-Vegas,2014,290,Nevada
98 | "Public, 4-year or above",Great Basin College,2014,704,Nevada
99 | "Private for-profit, 2-year",Euphoria Institute of Beauty Arts & Sciences-Summerlin,2014,82,Nevada
100 | "Private for-profit, less-than 2-year",Advanced Training Institute,2014,147,Nevada
101 | "Public, 2-year",Truckee Meadows Community College,2014,2286,Nevada
102 | "Private for-profit, less-than 2-year",European Massage Therapy School-Las Vegas,2014,83,Nevada
103 | "Public, 4-year or above",Nevada State College,2014,365,Nevada
104 | "Private for-profit, 2-year",Euphoria Institute of Beauty Arts & Sciences-Green Valley,2014,104,Nevada
105 | "Private for-profit, less-than 2-year",Institute of Professional Careers,2014,10,Nevada
106 | "Public, 4-year or above",University of Nevada-Las Vegas,2014,5093,Nevada
107 | "Private for-profit, less-than 2-year",Milan Institute-Sparks,2014,310,Nevada
108 | "Private for-profit, less-than 2-year",Academy of Hair Design-Las Vegas,2014,256,Nevada
109 | "Private for-profit, 2-year",Milan Institute of Cosmetology-Reno,2014,106,Nevada
110 | "Public, 4-year or above",University of Nevada-Reno,2014,3550,Nevada
111 | "Private for-profit, 4-year or above",Sanford-Brown College-Las Vegas,2014,81,Nevada
112 | "Private for-profit, 2-year",Northwest Career College,2014,164,Nevada
113 | "Private not-for-profit, 4-year or above",Sierra Nevada College,2014,275,Nevada
114 | "Private for-profit, 2-year",Casal Institute of Nevada,2014,94,Nevada
115 | "Private for-profit, 2-year",Le Cordon Bleu College of Culinary Arts-Las Vegas,2014,277,Nevada
116 | "Private for-profit, 2-year",Carrington College-Reno,2014,157,Nevada
117 | "Private not-for-profit, 4-year or above",Touro University Nevada,2014,349,Nevada
118 | "Private for-profit, 2-year",Carrington College-Las Vegas,2014,113,Nevada
119 | "Private for-profit, 2-year",International Academy of Style,2014,69,Nevada
120 | "Private for-profit, 4-year or above",The Art Institute of Las Vegas,2014,189,Nevada
121 | "Private for-profit, 2-year",Pima Medical Institute-Las Vegas,2014,567,Nevada
122 | "Private for-profit, 2-year",Brightwood College-Las Vegas,2014,624,Nevada
123 | "Private for-profit, 4-year or above",ITT Technical Institute-Las Vegas,2014,218,Nevada
124 | "Private for-profit, 2-year",Paul Mitchell the School-Las Vegas,2014,138,Nevada
125 | "Private for-profit, 4-year or above",University of Phoenix-Nevada,2014,708,Nevada
126 | "Private for-profit, 4-year or above",DeVry University-Nevada,2014,127,Nevada
127 | "Private for-profit, 2-year",Career College of Northern Nevada,2014,239,Nevada
128 | "Private for-profit, 2-year",Aviation Institute of Maintenance-Las Vegas,2014,0,Nevada
129 | "Private for-profit, 2-year",Paul Mitchell the School-Reno,2014,93,Nevada
130 | "Private for-profit, 4-year or above",ITT Technical Institute-Henderson,2014,183,Nevada
131 | "Private for-profit, 2-year",Aviation Institute of Maintenance-Las Vegas,2013,0,Nevada
132 | "Private for-profit, 4-year or above",DeVry University-Nevada,2013,97,Nevada
133 | "Private for-profit, 4-year or above",ITT Technical Institute-Henderson,2013,217,Nevada
134 | "Private for-profit, 2-year",Career College of Northern Nevada,2013,275,Nevada
135 | "Private for-profit, 2-year",Paul Mitchell the School-Las Vegas,2013,128,Nevada
136 | "Private for-profit, 2-year",Brightwood College-Las Vegas,2013,575,Nevada
137 | "Private for-profit, 4-year or above",ITT Technical Institute-Las Vegas,2013,168,Nevada
138 | "Private for-profit, 2-year",Pima Medical Institute-Las Vegas,2013,588,Nevada
139 | "Private for-profit, 4-year or above",The Art Institute of Las Vegas,2013,194,Nevada
140 | "Private not-for-profit, 2-year",Expertise Cosmetology Institute,2013,55,Nevada
141 | "Private not-for-profit, 4-year or above",Roseman University of Health Sciences,2013,412,Nevada
142 | "Private for-profit, 2-year",Carrington College-Las Vegas,2013,77,Nevada
143 | "Private for-profit, 2-year",International Academy of Style,2013,55,Nevada
144 | "Private for-profit, 2-year",Carrington College-Reno,2013,135,Nevada
145 | "Private not-for-profit, 4-year or above",Touro University Nevada,2013,372,Nevada
146 | "Private for-profit, 2-year",Le Cordon Bleu College of Culinary Arts-Las Vegas,2013,438,Nevada
147 | "Private for-profit, 4-year or above",Sanford-Brown College-Las Vegas,2013,99,Nevada
148 | "Private for-profit, 2-year",Casal Institute of Nevada,2013,65,Nevada
149 | "Private not-for-profit, 4-year or above",Sierra Nevada College,2013,232,Nevada
150 | "Private for-profit, 2-year",Northwest Career College,2013,116,Nevada
151 | "Private for-profit, 2-year",Paul Mitchell the School-Reno,2013,91,Nevada
152 | "Private for-profit, less-than 2-year",Academy of Hair Design-Las Vegas,2013,84,Nevada
153 | "Private for-profit, 2-year",Milan Institute of Cosmetology-Reno,2013,111,Nevada
154 | "Public, 4-year or above",University of Nevada-Reno,2013,3551,Nevada
155 | "Private for-profit, less-than 2-year",Milan Institute-Sparks,2013,293,Nevada
156 | "Public, 2-year",Truckee Meadows Community College,2013,1633,Nevada
157 | "Public, 4-year or above",University of Nevada-Las Vegas,2013,5278,Nevada
158 | "Private for-profit, less-than 2-year",Institute of Professional Careers,2013,8,Nevada
159 | "Public, 4-year or above",College of Southern Nevada,2013,2741,Nevada
160 | "Private for-profit, 2-year",Euphoria Institute of Beauty Arts & Sciences-Green Valley,2013,105,Nevada
161 | "Private for-profit, less-than 2-year",European Massage Therapy School-Las Vegas,2013,63,Nevada
162 | "Public, 4-year or above",Nevada State College,2013,303,Nevada
163 | "Private for-profit, less-than 2-year",Advanced Training Institute,2013,157,Nevada
164 | "Private for-profit, 2-year",Euphoria Institute of Beauty Arts & Sciences-Summerlin,2013,110,Nevada
165 | "Public, 4-year or above",Great Basin College,2013,422,Nevada
166 | "Private for-profit, less-than 2-year",Utah College of Massage Therapy-Vegas,2013,372,Nevada
167 | "Private not-for-profit, 2-year",Everest College-Henderson,2013,416,Nevada
168 | "Private for-profit, less-than 2-year",Milan Institute-Las Vegas,2013,304,Nevada
169 | "Private for-profit, 2-year",Nevada Career Institute,2013,184,Nevada
170 | "Public, 4-year or above",Western Nevada College,2013,522,Nevada
171 | "Private for-profit, less-than 2-year",Academy of Hair Design-Las Vegas,2012,110,Nevada
172 | "Private for-profit, 2-year",Career College of Northern Nevada,2012,333,Nevada
173 | "Private for-profit, 2-year",Paul Mitchell the School-Las Vegas,2012,78,Nevada
174 | "Private not-for-profit, 4-year or above",Roseman University of Health Sciences,2012,388,Nevada
175 | "Public, 4-year or above",University of Nevada-Reno,2012,3453,Nevada
176 | "Private for-profit, less-than 2-year",Milan Institute-Sparks,2012,248,Nevada
177 | "Private for-profit, 2-year",International Academy of Style,2012,75,Nevada
178 | "Private for-profit, 2-year",Milan Institute of Cosmetology-Reno,2012,122,Nevada
179 | "Private for-profit, 2-year",Carrington College-Reno,2012,145,Nevada
180 | "Public, 4-year or above",College of Southern Nevada,2012,2348,Nevada
181 | "Private for-profit, less-than 2-year",Institute of Professional Careers,2012,13,Nevada
182 | "Private for-profit, 4-year or above",Sanford-Brown College-Las Vegas,2012,51,Nevada
183 | "Private for-profit, 4-year or above",ITT Technical Institute-Las Vegas,2012,118,Nevada
184 | "Public, 4-year or above",University of Nevada-Las Vegas,2012,5388,Nevada
185 | "Private not-for-profit, 4-year or above",Touro University Nevada,2012,430,Nevada
186 | "Private for-profit, less-than 2-year",European Massage Therapy School-Las Vegas,2012,21,Nevada
187 | "Private for-profit, 2-year",Le Cordon Bleu College of Culinary Arts-Las Vegas,2012,368,Nevada
188 | "Private for-profit, 2-year",Euphoria Institute of Beauty Arts & Sciences-Green Valley,2012,153,Nevada
189 | "Private for-profit, 2-year",Pima Medical Institute-Las Vegas,2012,593,Nevada
190 | "Public, 4-year or above",Nevada State College,2012,272,Nevada
191 | "Private for-profit, less-than 2-year",Advanced Training Institute,2012,218,Nevada
192 | "Private for-profit, 2-year",Paul Mitchell the School-Reno,2012,78,Nevada
193 | "Private not-for-profit, 2-year",Everest College-Henderson,2012,536,Nevada
194 | "Private for-profit, 4-year or above",The Art Institute of Las Vegas,2012,200,Nevada
195 | "Private for-profit, 4-year or above",ITT Technical Institute-Henderson,2012,263,Nevada
196 | "Private for-profit, less-than 2-year",Utah College of Massage Therapy-Vegas,2012,392,Nevada
197 | "Private for-profit, 2-year",Northwest Career College,2012,138,Nevada
198 | "Private for-profit, 2-year",Euphoria Institute of Beauty Arts & Sciences-Summerlin,2012,113,Nevada
199 | "Public, 4-year or above",Great Basin College,2012,452,Nevada
200 | "Private for-profit, 2-year",Brightwood College-Las Vegas,2012,568,Nevada
201 | "Private for-profit, less-than 2-year",Milan Institute-Las Vegas,2012,325,Nevada
202 | "Private for-profit, 2-year",Casal Institute of Nevada,2012,87,Nevada
203 | "Private not-for-profit, 4-year or above",Sierra Nevada College,2012,241,Nevada
204 | "Private for-profit, 2-year",Carrington College-Las Vegas,2012,120,Nevada
205 | "Public, 4-year or above",Western Nevada College,2012,495,Nevada
206 | "Private for-profit, 2-year",Nevada Career Institute,2012,101,Nevada
207 | "Private not-for-profit, 2-year",Expertise Cosmetology Institute,2012,129,Nevada
208 | "Public, 2-year",Truckee Meadows Community College,2012,1170,Nevada
209 |
--------------------------------------------------------------------------------
/Exercise Notebooks/Data/Yasin Rezvani.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YasinRezvani/Hands_On_Machine_Learning_and_Deep_Learning_with_Python/0f1876aa3e18636857a38aac46fc2f0843a009f8/Exercise Notebooks/Data/Yasin Rezvani.jpg
--------------------------------------------------------------------------------
/Exercise Notebooks/Data/Yasin Rezvani_grayscale.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YasinRezvani/Hands_On_Machine_Learning_and_Deep_Learning_with_Python/0f1876aa3e18636857a38aac46fc2f0843a009f8/Exercise Notebooks/Data/Yasin Rezvani_grayscale.jpg
--------------------------------------------------------------------------------
/Exercise Notebooks/Data/Yasin Rezvani_resized.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YasinRezvani/Hands_On_Machine_Learning_and_Deep_Learning_with_Python/0f1876aa3e18636857a38aac46fc2f0843a009f8/Exercise Notebooks/Data/Yasin Rezvani_resized.jpg
--------------------------------------------------------------------------------
/Exercise Notebooks/Data/face_from_scipy_misc_library.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YasinRezvani/Hands_On_Machine_Learning_and_Deep_Learning_with_Python/0f1876aa3e18636857a38aac46fc2f0843a009f8/Exercise Notebooks/Data/face_from_scipy_misc_library.png
--------------------------------------------------------------------------------
/Exercise Notebooks/Data/heart.csv:
--------------------------------------------------------------------------------
1 | age,sex,cp,trestbps,chol,fbs,restecg,thalach,exang,oldpeak,slope,ca,thal,target
2 | 63,1,3,145,233,1,0,150,0,2.3,0,0,1,1
3 | 37,1,2,130,250,0,1,187,0,3.5,0,0,2,1
4 | 41,0,1,130,204,0,0,172,0,1.4,2,0,2,1
5 | 56,1,1,120,236,0,1,178,0,0.8,2,0,2,1
6 | 57,0,0,120,354,0,1,163,1,0.6,2,0,2,1
7 | 57,1,0,140,192,0,1,148,0,0.4,1,0,1,1
8 | 56,0,1,140,294,0,0,153,0,1.3,1,0,2,1
9 | 44,1,1,120,263,0,1,173,0,0,2,0,3,1
10 | 52,1,2,172,199,1,1,162,0,0.5,2,0,3,1
11 | 57,1,2,150,168,0,1,174,0,1.6,2,0,2,1
12 | 54,1,0,140,239,0,1,160,0,1.2,2,0,2,1
13 | 48,0,2,130,275,0,1,139,0,0.2,2,0,2,1
14 | 49,1,1,130,266,0,1,171,0,0.6,2,0,2,1
15 | 64,1,3,110,211,0,0,144,1,1.8,1,0,2,1
16 | 58,0,3,150,283,1,0,162,0,1,2,0,2,1
17 | 50,0,2,120,219,0,1,158,0,1.6,1,0,2,1
18 | 58,0,2,120,340,0,1,172,0,0,2,0,2,1
19 | 66,0,3,150,226,0,1,114,0,2.6,0,0,2,1
20 | 43,1,0,150,247,0,1,171,0,1.5,2,0,2,1
21 | 69,0,3,140,239,0,1,151,0,1.8,2,2,2,1
22 | 59,1,0,135,234,0,1,161,0,0.5,1,0,3,1
23 | 44,1,2,130,233,0,1,179,1,0.4,2,0,2,1
24 | 42,1,0,140,226,0,1,178,0,0,2,0,2,1
25 | 61,1,2,150,243,1,1,137,1,1,1,0,2,1
26 | 40,1,3,140,199,0,1,178,1,1.4,2,0,3,1
27 | 71,0,1,160,302,0,1,162,0,0.4,2,2,2,1
28 | 59,1,2,150,212,1,1,157,0,1.6,2,0,2,1
29 | 51,1,2,110,175,0,1,123,0,0.6,2,0,2,1
30 | 65,0,2,140,417,1,0,157,0,0.8,2,1,2,1
31 | 53,1,2,130,197,1,0,152,0,1.2,0,0,2,1
32 | 41,0,1,105,198,0,1,168,0,0,2,1,2,1
33 | 65,1,0,120,177,0,1,140,0,0.4,2,0,3,1
34 | 44,1,1,130,219,0,0,188,0,0,2,0,2,1
35 | 54,1,2,125,273,0,0,152,0,0.5,0,1,2,1
36 | 51,1,3,125,213,0,0,125,1,1.4,2,1,2,1
37 | 46,0,2,142,177,0,0,160,1,1.4,0,0,2,1
38 | 54,0,2,135,304,1,1,170,0,0,2,0,2,1
39 | 54,1,2,150,232,0,0,165,0,1.6,2,0,3,1
40 | 65,0,2,155,269,0,1,148,0,0.8,2,0,2,1
41 | 65,0,2,160,360,0,0,151,0,0.8,2,0,2,1
42 | 51,0,2,140,308,0,0,142,0,1.5,2,1,2,1
43 | 48,1,1,130,245,0,0,180,0,0.2,1,0,2,1
44 | 45,1,0,104,208,0,0,148,1,3,1,0,2,1
45 | 53,0,0,130,264,0,0,143,0,0.4,1,0,2,1
46 | 39,1,2,140,321,0,0,182,0,0,2,0,2,1
47 | 52,1,1,120,325,0,1,172,0,0.2,2,0,2,1
48 | 44,1,2,140,235,0,0,180,0,0,2,0,2,1
49 | 47,1,2,138,257,0,0,156,0,0,2,0,2,1
50 | 53,0,2,128,216,0,0,115,0,0,2,0,0,1
51 | 53,0,0,138,234,0,0,160,0,0,2,0,2,1
52 | 51,0,2,130,256,0,0,149,0,0.5,2,0,2,1
53 | 66,1,0,120,302,0,0,151,0,0.4,1,0,2,1
54 | 62,1,2,130,231,0,1,146,0,1.8,1,3,3,1
55 | 44,0,2,108,141,0,1,175,0,0.6,1,0,2,1
56 | 63,0,2,135,252,0,0,172,0,0,2,0,2,1
57 | 52,1,1,134,201,0,1,158,0,0.8,2,1,2,1
58 | 48,1,0,122,222,0,0,186,0,0,2,0,2,1
59 | 45,1,0,115,260,0,0,185,0,0,2,0,2,1
60 | 34,1,3,118,182,0,0,174,0,0,2,0,2,1
61 | 57,0,0,128,303,0,0,159,0,0,2,1,2,1
62 | 71,0,2,110,265,1,0,130,0,0,2,1,2,1
63 | 54,1,1,108,309,0,1,156,0,0,2,0,3,1
64 | 52,1,3,118,186,0,0,190,0,0,1,0,1,1
65 | 41,1,1,135,203,0,1,132,0,0,1,0,1,1
66 | 58,1,2,140,211,1,0,165,0,0,2,0,2,1
67 | 35,0,0,138,183,0,1,182,0,1.4,2,0,2,1
68 | 51,1,2,100,222,0,1,143,1,1.2,1,0,2,1
69 | 45,0,1,130,234,0,0,175,0,0.6,1,0,2,1
70 | 44,1,1,120,220,0,1,170,0,0,2,0,2,1
71 | 62,0,0,124,209,0,1,163,0,0,2,0,2,1
72 | 54,1,2,120,258,0,0,147,0,0.4,1,0,3,1
73 | 51,1,2,94,227,0,1,154,1,0,2,1,3,1
74 | 29,1,1,130,204,0,0,202,0,0,2,0,2,1
75 | 51,1,0,140,261,0,0,186,1,0,2,0,2,1
76 | 43,0,2,122,213,0,1,165,0,0.2,1,0,2,1
77 | 55,0,1,135,250,0,0,161,0,1.4,1,0,2,1
78 | 51,1,2,125,245,1,0,166,0,2.4,1,0,2,1
79 | 59,1,1,140,221,0,1,164,1,0,2,0,2,1
80 | 52,1,1,128,205,1,1,184,0,0,2,0,2,1
81 | 58,1,2,105,240,0,0,154,1,0.6,1,0,3,1
82 | 41,1,2,112,250,0,1,179,0,0,2,0,2,1
83 | 45,1,1,128,308,0,0,170,0,0,2,0,2,1
84 | 60,0,2,102,318,0,1,160,0,0,2,1,2,1
85 | 52,1,3,152,298,1,1,178,0,1.2,1,0,3,1
86 | 42,0,0,102,265,0,0,122,0,0.6,1,0,2,1
87 | 67,0,2,115,564,0,0,160,0,1.6,1,0,3,1
88 | 68,1,2,118,277,0,1,151,0,1,2,1,3,1
89 | 46,1,1,101,197,1,1,156,0,0,2,0,3,1
90 | 54,0,2,110,214,0,1,158,0,1.6,1,0,2,1
91 | 58,0,0,100,248,0,0,122,0,1,1,0,2,1
92 | 48,1,2,124,255,1,1,175,0,0,2,2,2,1
93 | 57,1,0,132,207,0,1,168,1,0,2,0,3,1
94 | 52,1,2,138,223,0,1,169,0,0,2,4,2,1
95 | 54,0,1,132,288,1,0,159,1,0,2,1,2,1
96 | 45,0,1,112,160,0,1,138,0,0,1,0,2,1
97 | 53,1,0,142,226,0,0,111,1,0,2,0,3,1
98 | 62,0,0,140,394,0,0,157,0,1.2,1,0,2,1
99 | 52,1,0,108,233,1,1,147,0,0.1,2,3,3,1
100 | 43,1,2,130,315,0,1,162,0,1.9,2,1,2,1
101 | 53,1,2,130,246,1,0,173,0,0,2,3,2,1
102 | 42,1,3,148,244,0,0,178,0,0.8,2,2,2,1
103 | 59,1,3,178,270,0,0,145,0,4.2,0,0,3,1
104 | 63,0,1,140,195,0,1,179,0,0,2,2,2,1
105 | 42,1,2,120,240,1,1,194,0,0.8,0,0,3,1
106 | 50,1,2,129,196,0,1,163,0,0,2,0,2,1
107 | 68,0,2,120,211,0,0,115,0,1.5,1,0,2,1
108 | 69,1,3,160,234,1,0,131,0,0.1,1,1,2,1
109 | 45,0,0,138,236,0,0,152,1,0.2,1,0,2,1
110 | 50,0,1,120,244,0,1,162,0,1.1,2,0,2,1
111 | 50,0,0,110,254,0,0,159,0,0,2,0,2,1
112 | 64,0,0,180,325,0,1,154,1,0,2,0,2,1
113 | 57,1,2,150,126,1,1,173,0,0.2,2,1,3,1
114 | 64,0,2,140,313,0,1,133,0,0.2,2,0,3,1
115 | 43,1,0,110,211,0,1,161,0,0,2,0,3,1
116 | 55,1,1,130,262,0,1,155,0,0,2,0,2,1
117 | 37,0,2,120,215,0,1,170,0,0,2,0,2,1
118 | 41,1,2,130,214,0,0,168,0,2,1,0,2,1
119 | 56,1,3,120,193,0,0,162,0,1.9,1,0,3,1
120 | 46,0,1,105,204,0,1,172,0,0,2,0,2,1
121 | 46,0,0,138,243,0,0,152,1,0,1,0,2,1
122 | 64,0,0,130,303,0,1,122,0,2,1,2,2,1
123 | 59,1,0,138,271,0,0,182,0,0,2,0,2,1
124 | 41,0,2,112,268,0,0,172,1,0,2,0,2,1
125 | 54,0,2,108,267,0,0,167,0,0,2,0,2,1
126 | 39,0,2,94,199,0,1,179,0,0,2,0,2,1
127 | 34,0,1,118,210,0,1,192,0,0.7,2,0,2,1
128 | 47,1,0,112,204,0,1,143,0,0.1,2,0,2,1
129 | 67,0,2,152,277,0,1,172,0,0,2,1,2,1
130 | 52,0,2,136,196,0,0,169,0,0.1,1,0,2,1
131 | 74,0,1,120,269,0,0,121,1,0.2,2,1,2,1
132 | 54,0,2,160,201,0,1,163,0,0,2,1,2,1
133 | 49,0,1,134,271,0,1,162,0,0,1,0,2,1
134 | 42,1,1,120,295,0,1,162,0,0,2,0,2,1
135 | 41,1,1,110,235,0,1,153,0,0,2,0,2,1
136 | 41,0,1,126,306,0,1,163,0,0,2,0,2,1
137 | 49,0,0,130,269,0,1,163,0,0,2,0,2,1
138 | 60,0,2,120,178,1,1,96,0,0,2,0,2,1
139 | 62,1,1,128,208,1,0,140,0,0,2,0,2,1
140 | 57,1,0,110,201,0,1,126,1,1.5,1,0,1,1
141 | 64,1,0,128,263,0,1,105,1,0.2,1,1,3,1
142 | 51,0,2,120,295,0,0,157,0,0.6,2,0,2,1
143 | 43,1,0,115,303,0,1,181,0,1.2,1,0,2,1
144 | 42,0,2,120,209,0,1,173,0,0,1,0,2,1
145 | 67,0,0,106,223,0,1,142,0,0.3,2,2,2,1
146 | 76,0,2,140,197,0,2,116,0,1.1,1,0,2,1
147 | 70,1,1,156,245,0,0,143,0,0,2,0,2,1
148 | 44,0,2,118,242,0,1,149,0,0.3,1,1,2,1
149 | 60,0,3,150,240,0,1,171,0,0.9,2,0,2,1
150 | 44,1,2,120,226,0,1,169,0,0,2,0,2,1
151 | 42,1,2,130,180,0,1,150,0,0,2,0,2,1
152 | 66,1,0,160,228,0,0,138,0,2.3,2,0,1,1
153 | 71,0,0,112,149,0,1,125,0,1.6,1,0,2,1
154 | 64,1,3,170,227,0,0,155,0,0.6,1,0,3,1
155 | 66,0,2,146,278,0,0,152,0,0,1,1,2,1
156 | 39,0,2,138,220,0,1,152,0,0,1,0,2,1
157 | 58,0,0,130,197,0,1,131,0,0.6,1,0,2,1
158 | 47,1,2,130,253,0,1,179,0,0,2,0,2,1
159 | 35,1,1,122,192,0,1,174,0,0,2,0,2,1
160 | 58,1,1,125,220,0,1,144,0,0.4,1,4,3,1
161 | 56,1,1,130,221,0,0,163,0,0,2,0,3,1
162 | 56,1,1,120,240,0,1,169,0,0,0,0,2,1
163 | 55,0,1,132,342,0,1,166,0,1.2,2,0,2,1
164 | 41,1,1,120,157,0,1,182,0,0,2,0,2,1
165 | 38,1,2,138,175,0,1,173,0,0,2,4,2,1
166 | 38,1,2,138,175,0,1,173,0,0,2,4,2,1
167 | 67,1,0,160,286,0,0,108,1,1.5,1,3,2,0
168 | 67,1,0,120,229,0,0,129,1,2.6,1,2,3,0
169 | 62,0,0,140,268,0,0,160,0,3.6,0,2,2,0
170 | 63,1,0,130,254,0,0,147,0,1.4,1,1,3,0
171 | 53,1,0,140,203,1,0,155,1,3.1,0,0,3,0
172 | 56,1,2,130,256,1,0,142,1,0.6,1,1,1,0
173 | 48,1,1,110,229,0,1,168,0,1,0,0,3,0
174 | 58,1,1,120,284,0,0,160,0,1.8,1,0,2,0
175 | 58,1,2,132,224,0,0,173,0,3.2,2,2,3,0
176 | 60,1,0,130,206,0,0,132,1,2.4,1,2,3,0
177 | 40,1,0,110,167,0,0,114,1,2,1,0,3,0
178 | 60,1,0,117,230,1,1,160,1,1.4,2,2,3,0
179 | 64,1,2,140,335,0,1,158,0,0,2,0,2,0
180 | 43,1,0,120,177,0,0,120,1,2.5,1,0,3,0
181 | 57,1,0,150,276,0,0,112,1,0.6,1,1,1,0
182 | 55,1,0,132,353,0,1,132,1,1.2,1,1,3,0
183 | 65,0,0,150,225,0,0,114,0,1,1,3,3,0
184 | 61,0,0,130,330,0,0,169,0,0,2,0,2,0
185 | 58,1,2,112,230,0,0,165,0,2.5,1,1,3,0
186 | 50,1,0,150,243,0,0,128,0,2.6,1,0,3,0
187 | 44,1,0,112,290,0,0,153,0,0,2,1,2,0
188 | 60,1,0,130,253,0,1,144,1,1.4,2,1,3,0
189 | 54,1,0,124,266,0,0,109,1,2.2,1,1,3,0
190 | 50,1,2,140,233,0,1,163,0,0.6,1,1,3,0
191 | 41,1,0,110,172,0,0,158,0,0,2,0,3,0
192 | 51,0,0,130,305,0,1,142,1,1.2,1,0,3,0
193 | 58,1,0,128,216,0,0,131,1,2.2,1,3,3,0
194 | 54,1,0,120,188,0,1,113,0,1.4,1,1,3,0
195 | 60,1,0,145,282,0,0,142,1,2.8,1,2,3,0
196 | 60,1,2,140,185,0,0,155,0,3,1,0,2,0
197 | 59,1,0,170,326,0,0,140,1,3.4,0,0,3,0
198 | 46,1,2,150,231,0,1,147,0,3.6,1,0,2,0
199 | 67,1,0,125,254,1,1,163,0,0.2,1,2,3,0
200 | 62,1,0,120,267,0,1,99,1,1.8,1,2,3,0
201 | 65,1,0,110,248,0,0,158,0,0.6,2,2,1,0
202 | 44,1,0,110,197,0,0,177,0,0,2,1,2,0
203 | 60,1,0,125,258,0,0,141,1,2.8,1,1,3,0
204 | 58,1,0,150,270,0,0,111,1,0.8,2,0,3,0
205 | 68,1,2,180,274,1,0,150,1,1.6,1,0,3,0
206 | 62,0,0,160,164,0,0,145,0,6.2,0,3,3,0
207 | 52,1,0,128,255,0,1,161,1,0,2,1,3,0
208 | 59,1,0,110,239,0,0,142,1,1.2,1,1,3,0
209 | 60,0,0,150,258,0,0,157,0,2.6,1,2,3,0
210 | 49,1,2,120,188,0,1,139,0,2,1,3,3,0
211 | 59,1,0,140,177,0,1,162,1,0,2,1,3,0
212 | 57,1,2,128,229,0,0,150,0,0.4,1,1,3,0
213 | 61,1,0,120,260,0,1,140,1,3.6,1,1,3,0
214 | 39,1,0,118,219,0,1,140,0,1.2,1,0,3,0
215 | 61,0,0,145,307,0,0,146,1,1,1,0,3,0
216 | 56,1,0,125,249,1,0,144,1,1.2,1,1,2,0
217 | 43,0,0,132,341,1,0,136,1,3,1,0,3,0
218 | 62,0,2,130,263,0,1,97,0,1.2,1,1,3,0
219 | 63,1,0,130,330,1,0,132,1,1.8,2,3,3,0
220 | 65,1,0,135,254,0,0,127,0,2.8,1,1,3,0
221 | 48,1,0,130,256,1,0,150,1,0,2,2,3,0
222 | 63,0,0,150,407,0,0,154,0,4,1,3,3,0
223 | 55,1,0,140,217,0,1,111,1,5.6,0,0,3,0
224 | 65,1,3,138,282,1,0,174,0,1.4,1,1,2,0
225 | 56,0,0,200,288,1,0,133,1,4,0,2,3,0
226 | 54,1,0,110,239,0,1,126,1,2.8,1,1,3,0
227 | 70,1,0,145,174,0,1,125,1,2.6,0,0,3,0
228 | 62,1,1,120,281,0,0,103,0,1.4,1,1,3,0
229 | 35,1,0,120,198,0,1,130,1,1.6,1,0,3,0
230 | 59,1,3,170,288,0,0,159,0,0.2,1,0,3,0
231 | 64,1,2,125,309,0,1,131,1,1.8,1,0,3,0
232 | 47,1,2,108,243,0,1,152,0,0,2,0,2,0
233 | 57,1,0,165,289,1,0,124,0,1,1,3,3,0
234 | 55,1,0,160,289,0,0,145,1,0.8,1,1,3,0
235 | 64,1,0,120,246,0,0,96,1,2.2,0,1,2,0
236 | 70,1,0,130,322,0,0,109,0,2.4,1,3,2,0
237 | 51,1,0,140,299,0,1,173,1,1.6,2,0,3,0
238 | 58,1,0,125,300,0,0,171,0,0,2,2,3,0
239 | 60,1,0,140,293,0,0,170,0,1.2,1,2,3,0
240 | 77,1,0,125,304,0,0,162,1,0,2,3,2,0
241 | 35,1,0,126,282,0,0,156,1,0,2,0,3,0
242 | 70,1,2,160,269,0,1,112,1,2.9,1,1,3,0
243 | 59,0,0,174,249,0,1,143,1,0,1,0,2,0
244 | 64,1,0,145,212,0,0,132,0,2,1,2,1,0
245 | 57,1,0,152,274,0,1,88,1,1.2,1,1,3,0
246 | 56,1,0,132,184,0,0,105,1,2.1,1,1,1,0
247 | 48,1,0,124,274,0,0,166,0,0.5,1,0,3,0
248 | 56,0,0,134,409,0,0,150,1,1.9,1,2,3,0
249 | 66,1,1,160,246,0,1,120,1,0,1,3,1,0
250 | 54,1,1,192,283,0,0,195,0,0,2,1,3,0
251 | 69,1,2,140,254,0,0,146,0,2,1,3,3,0
252 | 51,1,0,140,298,0,1,122,1,4.2,1,3,3,0
253 | 43,1,0,132,247,1,0,143,1,0.1,1,4,3,0
254 | 62,0,0,138,294,1,1,106,0,1.9,1,3,2,0
255 | 67,1,0,100,299,0,0,125,1,0.9,1,2,2,0
256 | 59,1,3,160,273,0,0,125,0,0,2,0,2,0
257 | 45,1,0,142,309,0,0,147,1,0,1,3,3,0
258 | 58,1,0,128,259,0,0,130,1,3,1,2,3,0
259 | 50,1,0,144,200,0,0,126,1,0.9,1,0,3,0
260 | 62,0,0,150,244,0,1,154,1,1.4,1,0,2,0
261 | 38,1,3,120,231,0,1,182,1,3.8,1,0,3,0
262 | 66,0,0,178,228,1,1,165,1,1,1,2,3,0
263 | 52,1,0,112,230,0,1,160,0,0,2,1,2,0
264 | 53,1,0,123,282,0,1,95,1,2,1,2,3,0
265 | 63,0,0,108,269,0,1,169,1,1.8,1,2,2,0
266 | 54,1,0,110,206,0,0,108,1,0,1,1,2,0
267 | 66,1,0,112,212,0,0,132,1,0.1,2,1,2,0
268 | 55,0,0,180,327,0,2,117,1,3.4,1,0,2,0
269 | 49,1,2,118,149,0,0,126,0,0.8,2,3,2,0
270 | 54,1,0,122,286,0,0,116,1,3.2,1,2,2,0
271 | 56,1,0,130,283,1,0,103,1,1.6,0,0,3,0
272 | 46,1,0,120,249,0,0,144,0,0.8,2,0,3,0
273 | 61,1,3,134,234,0,1,145,0,2.6,1,2,2,0
274 | 67,1,0,120,237,0,1,71,0,1,1,0,2,0
275 | 58,1,0,100,234,0,1,156,0,0.1,2,1,3,0
276 | 47,1,0,110,275,0,0,118,1,1,1,1,2,0
277 | 52,1,0,125,212,0,1,168,0,1,2,2,3,0
278 | 58,1,0,146,218,0,1,105,0,2,1,1,3,0
279 | 57,1,1,124,261,0,1,141,0,0.3,2,0,3,0
280 | 58,0,1,136,319,1,0,152,0,0,2,2,2,0
281 | 61,1,0,138,166,0,0,125,1,3.6,1,1,2,0
282 | 42,1,0,136,315,0,1,125,1,1.8,1,0,1,0
283 | 52,1,0,128,204,1,1,156,1,1,1,0,0,0
284 | 59,1,2,126,218,1,1,134,0,2.2,1,1,1,0
285 | 40,1,0,152,223,0,1,181,0,0,2,0,3,0
286 | 61,1,0,140,207,0,0,138,1,1.9,2,1,3,0
287 | 46,1,0,140,311,0,1,120,1,1.8,1,2,3,0
288 | 59,1,3,134,204,0,1,162,0,0.8,2,2,2,0
289 | 57,1,1,154,232,0,0,164,0,0,2,1,2,0
290 | 57,1,0,110,335,0,1,143,1,3,1,1,3,0
291 | 55,0,0,128,205,0,2,130,1,2,1,1,3,0
292 | 61,1,0,148,203,0,1,161,0,0,2,1,3,0
293 | 58,1,0,114,318,0,2,140,0,4.4,0,3,1,0
294 | 58,0,0,170,225,1,0,146,1,2.8,1,2,1,0
295 | 67,1,2,152,212,0,0,150,0,0.8,1,0,3,0
296 | 44,1,0,120,169,0,1,144,1,2.8,0,0,1,0
297 | 63,1,0,140,187,0,0,144,1,4,2,2,3,0
298 | 63,0,0,124,197,0,1,136,1,0,1,0,2,0
299 | 59,1,0,164,176,1,0,90,0,1,1,2,1,0
300 | 57,0,0,140,241,0,1,123,1,0.2,1,0,3,0
301 | 45,1,3,110,264,0,1,132,0,1.2,1,0,3,0
302 | 68,1,0,144,193,1,1,141,0,3.4,1,2,3,0
303 | 57,1,0,130,131,0,1,115,1,1.2,1,1,3,0
304 | 57,0,1,130,236,0,0,174,0,0,1,1,2,0
305 |
--------------------------------------------------------------------------------
/Exercise Notebooks/Data/iris.csv:
--------------------------------------------------------------------------------
1 | sepal_length,sepal_width,petal_length,petal_width,species
2 | 5.1,3.5,1.4,0.2,setosa
3 | 4.9,3.0,1.4,0.2,setosa
4 | 4.7,3.2,1.3,0.2,setosa
5 | 4.6,3.1,1.5,0.2,setosa
6 | 5.0,3.6,1.4,0.2,setosa
7 | 5.4,3.9,1.7,0.4,setosa
8 | 4.6,3.4,1.4,0.3,setosa
9 | 5.0,3.4,1.5,0.2,setosa
10 | 4.4,2.9,1.4,0.2,setosa
11 | 4.9,3.1,1.5,0.1,setosa
12 | 5.4,3.7,1.5,0.2,setosa
13 | 4.8,3.4,1.6,0.2,setosa
14 | 4.8,3.0,1.4,0.1,setosa
15 | 4.3,3.0,1.1,0.1,setosa
16 | 5.8,4.0,1.2,0.2,setosa
17 | 5.7,4.4,1.5,0.4,setosa
18 | 5.4,3.9,1.3,0.4,setosa
19 | 5.1,3.5,1.4,0.3,setosa
20 | 5.7,3.8,1.7,0.3,setosa
21 | 5.1,3.8,1.5,0.3,setosa
22 | 5.4,3.4,1.7,0.2,setosa
23 | 5.1,3.7,1.5,0.4,setosa
24 | 4.6,3.6,1.0,0.2,setosa
25 | 5.1,3.3,1.7,0.5,setosa
26 | 4.8,3.4,1.9,0.2,setosa
27 | 5.0,3.0,1.6,0.2,setosa
28 | 5.0,3.4,1.6,0.4,setosa
29 | 5.2,3.5,1.5,0.2,setosa
30 | 5.2,3.4,1.4,0.2,setosa
31 | 4.7,3.2,1.6,0.2,setosa
32 | 4.8,3.1,1.6,0.2,setosa
33 | 5.4,3.4,1.5,0.4,setosa
34 | 5.2,4.1,1.5,0.1,setosa
35 | 5.5,4.2,1.4,0.2,setosa
36 | 4.9,3.1,1.5,0.2,setosa
37 | 5.0,3.2,1.2,0.2,setosa
38 | 5.5,3.5,1.3,0.2,setosa
39 | 4.9,3.6,1.4,0.1,setosa
40 | 4.4,3.0,1.3,0.2,setosa
41 | 5.1,3.4,1.5,0.2,setosa
42 | 5.0,3.5,1.3,0.3,setosa
43 | 4.5,2.3,1.3,0.3,setosa
44 | 4.4,3.2,1.3,0.2,setosa
45 | 5.0,3.5,1.6,0.6,setosa
46 | 5.1,3.8,1.9,0.4,setosa
47 | 4.8,3.0,1.4,0.3,setosa
48 | 5.1,3.8,1.6,0.2,setosa
49 | 4.6,3.2,1.4,0.2,setosa
50 | 5.3,3.7,1.5,0.2,setosa
51 | 5.0,3.3,1.4,0.2,setosa
52 | 7.0,3.2,4.7,1.4,versicolor
53 | 6.4,3.2,4.5,1.5,versicolor
54 | 6.9,3.1,4.9,1.5,versicolor
55 | 5.5,2.3,4.0,1.3,versicolor
56 | 6.5,2.8,4.6,1.5,versicolor
57 | 5.7,2.8,4.5,1.3,versicolor
58 | 6.3,3.3,4.7,1.6,versicolor
59 | 4.9,2.4,3.3,1.0,versicolor
60 | 6.6,2.9,4.6,1.3,versicolor
61 | 5.2,2.7,3.9,1.4,versicolor
62 | 5.0,2.0,3.5,1.0,versicolor
63 | 5.9,3.0,4.2,1.5,versicolor
64 | 6.0,2.2,4.0,1.0,versicolor
65 | 6.1,2.9,4.7,1.4,versicolor
66 | 5.6,2.9,3.6,1.3,versicolor
67 | 6.7,3.1,4.4,1.4,versicolor
68 | 5.6,3.0,4.5,1.5,versicolor
69 | 5.8,2.7,4.1,1.0,versicolor
70 | 6.2,2.2,4.5,1.5,versicolor
71 | 5.6,2.5,3.9,1.1,versicolor
72 | 5.9,3.2,4.8,1.8,versicolor
73 | 6.1,2.8,4.0,1.3,versicolor
74 | 6.3,2.5,4.9,1.5,versicolor
75 | 6.1,2.8,4.7,1.2,versicolor
76 | 6.4,2.9,4.3,1.3,versicolor
77 | 6.6,3.0,4.4,1.4,versicolor
78 | 6.8,2.8,4.8,1.4,versicolor
79 | 6.7,3.0,5.0,1.7,versicolor
80 | 6.0,2.9,4.5,1.5,versicolor
81 | 5.7,2.6,3.5,1.0,versicolor
82 | 5.5,2.4,3.8,1.1,versicolor
83 | 5.5,2.4,3.7,1.0,versicolor
84 | 5.8,2.7,3.9,1.2,versicolor
85 | 6.0,2.7,5.1,1.6,versicolor
86 | 5.4,3.0,4.5,1.5,versicolor
87 | 6.0,3.4,4.5,1.6,versicolor
88 | 6.7,3.1,4.7,1.5,versicolor
89 | 6.3,2.3,4.4,1.3,versicolor
90 | 5.6,3.0,4.1,1.3,versicolor
91 | 5.5,2.5,4.0,1.3,versicolor
92 | 5.5,2.6,4.4,1.2,versicolor
93 | 6.1,3.0,4.6,1.4,versicolor
94 | 5.8,2.6,4.0,1.2,versicolor
95 | 5.0,2.3,3.3,1.0,versicolor
96 | 5.6,2.7,4.2,1.3,versicolor
97 | 5.7,3.0,4.2,1.2,versicolor
98 | 5.7,2.9,4.2,1.3,versicolor
99 | 6.2,2.9,4.3,1.3,versicolor
100 | 5.1,2.5,3.0,1.1,versicolor
101 | 5.7,2.8,4.1,1.3,versicolor
102 | 6.3,3.3,6.0,2.5,virginica
103 | 5.8,2.7,5.1,1.9,virginica
104 | 7.1,3.0,5.9,2.1,virginica
105 | 6.3,2.9,5.6,1.8,virginica
106 | 6.5,3.0,5.8,2.2,virginica
107 | 7.6,3.0,6.6,2.1,virginica
108 | 4.9,2.5,4.5,1.7,virginica
109 | 7.3,2.9,6.3,1.8,virginica
110 | 6.7,2.5,5.8,1.8,virginica
111 | 7.2,3.6,6.1,2.5,virginica
112 | 6.5,3.2,5.1,2.0,virginica
113 | 6.4,2.7,5.3,1.9,virginica
114 | 6.8,3.0,5.5,2.1,virginica
115 | 5.7,2.5,5.0,2.0,virginica
116 | 5.8,2.8,5.1,2.4,virginica
117 | 6.4,3.2,5.3,2.3,virginica
118 | 6.5,3.0,5.5,1.8,virginica
119 | 7.7,3.8,6.7,2.2,virginica
120 | 7.7,2.6,6.9,2.3,virginica
121 | 6.0,2.2,5.0,1.5,virginica
122 | 6.9,3.2,5.7,2.3,virginica
123 | 5.6,2.8,4.9,2.0,virginica
124 | 7.7,2.8,6.7,2.0,virginica
125 | 6.3,2.7,4.9,1.8,virginica
126 | 6.7,3.3,5.7,2.1,virginica
127 | 7.2,3.2,6.0,1.8,virginica
128 | 6.2,2.8,4.8,1.8,virginica
129 | 6.1,3.0,4.9,1.8,virginica
130 | 6.4,2.8,5.6,2.1,virginica
131 | 7.2,3.0,5.8,1.6,virginica
132 | 7.4,2.8,6.1,1.9,virginica
133 | 7.9,3.8,6.4,2.0,virginica
134 | 6.4,2.8,5.6,2.2,virginica
135 | 6.3,2.8,5.1,1.5,virginica
136 | 6.1,2.6,5.6,1.4,virginica
137 | 7.7,3.0,6.1,2.3,virginica
138 | 6.3,3.4,5.6,2.4,virginica
139 | 6.4,3.1,5.5,1.8,virginica
140 | 6.0,3.0,4.8,1.8,virginica
141 | 6.9,3.1,5.4,2.1,virginica
142 | 6.7,3.1,5.6,2.4,virginica
143 | 6.9,3.1,5.1,2.3,virginica
144 | 5.8,2.7,5.1,1.9,virginica
145 | 6.8,3.2,5.9,2.3,virginica
146 | 6.7,3.3,5.7,2.5,virginica
147 | 6.7,3.0,5.2,2.3,virginica
148 | 6.3,2.5,5.0,1.9,virginica
149 | 6.5,3.0,5.2,2.0,virginica
150 | 6.2,3.4,5.4,2.3,virginica
151 | 5.9,3.0,5.1,1.8,virginica
152 |
--------------------------------------------------------------------------------
/Exercise Notebooks/Data/model.h5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YasinRezvani/Hands_On_Machine_Learning_and_Deep_Learning_with_Python/0f1876aa3e18636857a38aac46fc2f0843a009f8/Exercise Notebooks/Data/model.h5
--------------------------------------------------------------------------------
/Exercise Notebooks/Data/model.json:
--------------------------------------------------------------------------------
1 | {"class_name": "Sequential", "config": {"name": "sequential_1", "layers": [{"module": "keras.layers", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 28, 28], "dtype": "float32", "sparse": false, "ragged": false, "name": "input_2"}, "registered_name": null}, {"module": "keras.layers", "class_name": "Flatten", "config": {"name": "flatten_1", "trainable": true, "dtype": "float32", "data_format": "channels_last"}, "registered_name": null, "build_config": {"input_shape": [null, 28, 28]}}, {"module": "keras.layers", "class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "dtype": "float32", "units": 10, "activation": "softmax", "use_bias": true, "kernel_initializer": {"module": "keras.initializers", "class_name": "GlorotUniform", "config": {"seed": null}, "registered_name": null}, "bias_initializer": {"module": "keras.initializers", "class_name": "Zeros", "config": {}, "registered_name": null}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "registered_name": null, "build_config": {"input_shape": [null, 784]}}]}, "keras_version": "2.13.1", "backend": "tensorflow"}
--------------------------------------------------------------------------------
/Exercise Notebooks/Data/outputfromDataFrame.csv:
--------------------------------------------------------------------------------
1 | W,E,R,T,new columns
2 | 0.0,-75.0,-42,-32,37
3 | 0.0,35.0,58,-73,-47
4 | 0.0,-20.0,-46,28,49
5 | 26.0,-20.0,-34,6,-22
6 |
--------------------------------------------------------------------------------
/Exercise Notebooks/Data/outputfromDataFramewithindex.csv:
--------------------------------------------------------------------------------
1 | States,W,E,R,T,new columns
2 | Bastam,0.0,-75.0,-42,-32,37
3 | Shahrood,0.0,35.0,58,-73,-47
4 | Bonab,0.0,-20.0,-46,28,49
5 | Tabriz,26.0,-20.0,-34,6,-22
6 |
--------------------------------------------------------------------------------
/Exercise Notebooks/NumPy_Exercises_From_Udemy_Course.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "___\n",
8 | "\n",
9 | "
\n",
10 | "___\n",
11 | "Copyright Pierian Data\n",
12 | "For more information, visit us at www.pieriandata.com"
13 | ]
14 | },
15 | {
16 | "cell_type": "markdown",
17 | "metadata": {},
18 | "source": [
19 | "# NumPy Exercises\n",
20 | "\n",
21 | "Now that we've learned about NumPy let's test your knowledge. We'll start off with a few simple tasks and then you'll be asked some more complicated questions.\n",
22 | "\n",
23 | "IMPORTANT NOTE! Make sure you don't run the cells directly above the example output shown,
otherwise you will end up writing over the example output!
"
24 | ]
25 | },
26 | {
27 | "cell_type": "markdown",
28 | "metadata": {},
29 | "source": [
30 | "#### 1. Import NumPy as np"
31 | ]
32 | },
33 | {
34 | "cell_type": "code",
35 | "execution_count": 2,
36 | "metadata": {},
37 | "outputs": [],
38 | "source": [
39 | "import numpy as np"
40 | ]
41 | },
42 | {
43 | "cell_type": "markdown",
44 | "metadata": {},
45 | "source": [
46 | "#### 2. Create an array of 10 zeros "
47 | ]
48 | },
49 | {
50 | "cell_type": "code",
51 | "execution_count": 2,
52 | "metadata": {},
53 | "outputs": [
54 | {
55 | "data": {
56 | "text/plain": [
57 | "array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])"
58 | ]
59 | },
60 | "execution_count": 2,
61 | "metadata": {},
62 | "output_type": "execute_result"
63 | }
64 | ],
65 | "source": [
66 | "# CODE HERE\n",
67 | "np.zeros(10)"
68 | ]
69 | },
70 | {
71 | "cell_type": "code",
72 | "execution_count": 2,
73 | "metadata": {},
74 | "outputs": [
75 | {
76 | "data": {
77 | "text/plain": [
78 | "array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])"
79 | ]
80 | },
81 | "execution_count": 2,
82 | "metadata": {},
83 | "output_type": "execute_result"
84 | }
85 | ],
86 | "source": [
87 | "# DON'T WRITE HERE"
88 | ]
89 | },
90 | {
91 | "cell_type": "markdown",
92 | "metadata": {},
93 | "source": [
94 | "#### 3. Create an array of 10 ones"
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": 3,
100 | "metadata": {},
101 | "outputs": [
102 | {
103 | "data": {
104 | "text/plain": [
105 | "array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])"
106 | ]
107 | },
108 | "execution_count": 3,
109 | "metadata": {},
110 | "output_type": "execute_result"
111 | }
112 | ],
113 | "source": [
114 | "np.ones(10)"
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": 3,
120 | "metadata": {},
121 | "outputs": [
122 | {
123 | "data": {
124 | "text/plain": [
125 | "array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])"
126 | ]
127 | },
128 | "execution_count": 3,
129 | "metadata": {},
130 | "output_type": "execute_result"
131 | }
132 | ],
133 | "source": [
134 | "# DON'T WRITE HERE"
135 | ]
136 | },
137 | {
138 | "cell_type": "markdown",
139 | "metadata": {},
140 | "source": [
141 | "#### 4. Create an array of 10 fives"
142 | ]
143 | },
144 | {
145 | "cell_type": "code",
146 | "execution_count": 7,
147 | "metadata": {},
148 | "outputs": [
149 | {
150 | "data": {
151 | "text/plain": [
152 | "array([5., 5., 5., 5., 5., 5., 5., 5., 5., 5.])"
153 | ]
154 | },
155 | "execution_count": 7,
156 | "metadata": {},
157 | "output_type": "execute_result"
158 | }
159 | ],
160 | "source": [
161 | "np.zeros(10) + 5"
162 | ]
163 | },
164 | {
165 | "cell_type": "code",
166 | "execution_count": 4,
167 | "metadata": {},
168 | "outputs": [
169 | {
170 | "data": {
171 | "text/plain": [
172 | "array([5., 5., 5., 5., 5., 5., 5., 5., 5., 5.])"
173 | ]
174 | },
175 | "execution_count": 4,
176 | "metadata": {},
177 | "output_type": "execute_result"
178 | }
179 | ],
180 | "source": [
181 | "# DON'T WRITE HERE"
182 | ]
183 | },
184 | {
185 | "cell_type": "markdown",
186 | "metadata": {},
187 | "source": [
188 | "#### 5. Create an array of the integers from 10 to 50"
189 | ]
190 | },
191 | {
192 | "cell_type": "code",
193 | "execution_count": 8,
194 | "metadata": {},
195 | "outputs": [
196 | {
197 | "data": {
198 | "text/plain": [
199 | "array([10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,\n",
200 | " 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,\n",
201 | " 44, 45, 46, 47, 48, 49, 50])"
202 | ]
203 | },
204 | "execution_count": 8,
205 | "metadata": {},
206 | "output_type": "execute_result"
207 | }
208 | ],
209 | "source": [
210 | "np.arange(10,51)"
211 | ]
212 | },
213 | {
214 | "cell_type": "code",
215 | "execution_count": 5,
216 | "metadata": {},
217 | "outputs": [
218 | {
219 | "data": {
220 | "text/plain": [
221 | "array([10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,\n",
222 | " 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,\n",
223 | " 44, 45, 46, 47, 48, 49, 50])"
224 | ]
225 | },
226 | "execution_count": 5,
227 | "metadata": {},
228 | "output_type": "execute_result"
229 | }
230 | ],
231 | "source": [
232 | "# DON'T WRITE HERE"
233 | ]
234 | },
235 | {
236 | "cell_type": "markdown",
237 | "metadata": {},
238 | "source": [
239 | "#### 6. Create an array of all the even integers from 10 to 50"
240 | ]
241 | },
242 | {
243 | "cell_type": "code",
244 | "execution_count": 9,
245 | "metadata": {},
246 | "outputs": [
247 | {
248 | "data": {
249 | "text/plain": [
250 | "array([10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42,\n",
251 | " 44, 46, 48, 50])"
252 | ]
253 | },
254 | "execution_count": 9,
255 | "metadata": {},
256 | "output_type": "execute_result"
257 | }
258 | ],
259 | "source": [
260 | "np.arange(10,51,2)"
261 | ]
262 | },
263 | {
264 | "cell_type": "code",
265 | "execution_count": 6,
266 | "metadata": {},
267 | "outputs": [
268 | {
269 | "data": {
270 | "text/plain": [
271 | "array([10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42,\n",
272 | " 44, 46, 48, 50])"
273 | ]
274 | },
275 | "execution_count": 6,
276 | "metadata": {},
277 | "output_type": "execute_result"
278 | }
279 | ],
280 | "source": [
281 | "# DON'T WRITE HERE"
282 | ]
283 | },
284 | {
285 | "cell_type": "markdown",
286 | "metadata": {},
287 | "source": [
288 | "#### 7. Create a 3x3 matrix with values ranging from 0 to 8"
289 | ]
290 | },
291 | {
292 | "cell_type": "code",
293 | "execution_count": 11,
294 | "metadata": {},
295 | "outputs": [
296 | {
297 | "data": {
298 | "text/plain": [
299 | "array([[0, 1, 2],\n",
300 | " [3, 4, 5],\n",
301 | " [6, 7, 8]])"
302 | ]
303 | },
304 | "execution_count": 11,
305 | "metadata": {},
306 | "output_type": "execute_result"
307 | }
308 | ],
309 | "source": [
310 | "np.arange(0,9).reshape(3,3)"
311 | ]
312 | },
313 | {
314 | "cell_type": "code",
315 | "execution_count": 7,
316 | "metadata": {},
317 | "outputs": [
318 | {
319 | "data": {
320 | "text/plain": [
321 | "array([[0, 1, 2],\n",
322 | " [3, 4, 5],\n",
323 | " [6, 7, 8]])"
324 | ]
325 | },
326 | "execution_count": 7,
327 | "metadata": {},
328 | "output_type": "execute_result"
329 | }
330 | ],
331 | "source": [
332 | "# DON'T WRITE HERE"
333 | ]
334 | },
335 | {
336 | "cell_type": "markdown",
337 | "metadata": {},
338 | "source": [
339 | "#### 8. Create a 3x3 identity matrix"
340 | ]
341 | },
342 | {
343 | "cell_type": "code",
344 | "execution_count": 12,
345 | "metadata": {},
346 | "outputs": [
347 | {
348 | "data": {
349 | "text/plain": [
350 | "array([[1., 0., 0.],\n",
351 | " [0., 1., 0.],\n",
352 | " [0., 0., 1.]])"
353 | ]
354 | },
355 | "execution_count": 12,
356 | "metadata": {},
357 | "output_type": "execute_result"
358 | }
359 | ],
360 | "source": [
361 | "np.eye(3,3)"
362 | ]
363 | },
364 | {
365 | "cell_type": "code",
366 | "execution_count": 8,
367 | "metadata": {},
368 | "outputs": [
369 | {
370 | "data": {
371 | "text/plain": [
372 | "array([[1., 0., 0.],\n",
373 | " [0., 1., 0.],\n",
374 | " [0., 0., 1.]])"
375 | ]
376 | },
377 | "execution_count": 8,
378 | "metadata": {},
379 | "output_type": "execute_result"
380 | }
381 | ],
382 | "source": [
383 | "# DON'T WRITE HERE"
384 | ]
385 | },
386 | {
387 | "cell_type": "markdown",
388 | "metadata": {},
389 | "source": [
390 | "#### 9. Use NumPy to generate a random number between 0 and 1
NOTE: Your result's value should be different from the one shown below."
391 | ]
392 | },
393 | {
394 | "cell_type": "code",
395 | "execution_count": 30,
396 | "metadata": {},
397 | "outputs": [
398 | {
399 | "data": {
400 | "text/plain": [
401 | "array([0.37454012])"
402 | ]
403 | },
404 | "execution_count": 30,
405 | "metadata": {},
406 | "output_type": "execute_result"
407 | }
408 | ],
409 | "source": [
410 | "np.random.seed(42)\n",
411 | "np.random.rand(1)"
412 | ]
413 | },
414 | {
415 | "cell_type": "code",
416 | "execution_count": 28,
417 | "metadata": {},
418 | "outputs": [],
419 | "source": [
420 | "# DON'T WRITE HERE"
421 | ]
422 | },
423 | {
424 | "cell_type": "markdown",
425 | "metadata": {},
426 | "source": [
427 | "#### 10. Use NumPy to generate an array of 25 random numbers sampled from a standard normal distribution
NOTE: Your result's values should be different from the ones shown below."
428 | ]
429 | },
430 | {
431 | "cell_type": "code",
432 | "execution_count": 33,
433 | "metadata": {},
434 | "outputs": [
435 | {
436 | "data": {
437 | "text/plain": [
438 | "array([ 0.49671415, -0.1382643 , 0.64768854, 1.52302986, -0.23415337,\n",
439 | " -0.23413696, 1.57921282, 0.76743473, -0.46947439, 0.54256004,\n",
440 | " -0.46341769, -0.46572975, 0.24196227, -1.91328024, -1.72491783,\n",
441 | " -0.56228753, -1.01283112, 0.31424733, -0.90802408, -1.4123037 ,\n",
442 | " 1.46564877, -0.2257763 , 0.0675282 , -1.42474819, -0.54438272])"
443 | ]
444 | },
445 | "execution_count": 33,
446 | "metadata": {},
447 | "output_type": "execute_result"
448 | }
449 | ],
450 | "source": [
451 | "np.random.seed(42)\n",
452 | "np.random.randn(25)"
453 | ]
454 | },
455 | {
456 | "cell_type": "code",
457 | "execution_count": 10,
458 | "metadata": {},
459 | "outputs": [
460 | {
461 | "data": {
462 | "text/plain": [
463 | "array([ 1.80076712, -1.12375847, -0.98524305, 0.11673573, 1.96346762,\n",
464 | " 1.81378592, -0.33790771, 0.85012656, 0.0100703 , -0.91005957,\n",
465 | " 0.29064366, 0.69906357, 0.1774377 , -0.61958694, -0.45498611,\n",
466 | " -2.0804685 , -0.06778549, 1.06403819, 0.4311884 , -1.09853837,\n",
467 | " 1.11980469, -0.48751963, 1.32517611, -0.61775122, -0.00622865])"
468 | ]
469 | },
470 | "execution_count": 10,
471 | "metadata": {},
472 | "output_type": "execute_result"
473 | }
474 | ],
475 | "source": [
476 | "# DON'T WRITE HERE"
477 | ]
478 | },
479 | {
480 | "cell_type": "markdown",
481 | "metadata": {},
482 | "source": [
483 | "#### 11. Create the following matrix:"
484 | ]
485 | },
486 | {
487 | "cell_type": "code",
488 | "execution_count": 5,
489 | "metadata": {},
490 | "outputs": [
491 | {
492 | "data": {
493 | "text/plain": [
494 | "array([[0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1 ],\n",
495 | " [0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2 ],\n",
496 | " [0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3 ],\n",
497 | " [0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4 ],\n",
498 | " [0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5 ],\n",
499 | " [0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6 ],\n",
500 | " [0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7 ],\n",
501 | " [0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8 ],\n",
502 | " [0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9 ],\n",
503 | " [0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1. ]])"
504 | ]
505 | },
506 | "execution_count": 5,
507 | "metadata": {},
508 | "output_type": "execute_result"
509 | }
510 | ],
511 | "source": [
512 | "np.arange(0.01,1.01,0.01,dtype=float).reshape(10,10)\n",
513 | "np.arange(1,101).reshape(10,10) / 100"
514 | ]
515 | },
516 | {
517 | "cell_type": "code",
518 | "execution_count": 11,
519 | "metadata": {},
520 | "outputs": [
521 | {
522 | "data": {
523 | "text/plain": [
524 | "array([[0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1 ],\n",
525 | " [0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2 ],\n",
526 | " [0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3 ],\n",
527 | " [0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4 ],\n",
528 | " [0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5 ],\n",
529 | " [0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6 ],\n",
530 | " [0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7 ],\n",
531 | " [0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8 ],\n",
532 | " [0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9 ],\n",
533 | " [0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1. ]])"
534 | ]
535 | },
536 | "execution_count": 11,
537 | "metadata": {},
538 | "output_type": "execute_result"
539 | }
540 | ],
541 | "source": [
542 | "# DON'T WRITE HERE"
543 | ]
544 | },
545 | {
546 | "cell_type": "markdown",
547 | "metadata": {},
548 | "source": [
549 | "#### 12. Create an array of 20 linearly spaced points between 0 and 1:"
550 | ]
551 | },
552 | {
553 | "cell_type": "code",
554 | "execution_count": 46,
555 | "metadata": {},
556 | "outputs": [
557 | {
558 | "data": {
559 | "text/plain": [
560 | "array([0. , 0.05263158, 0.10526316, 0.15789474, 0.21052632,\n",
561 | " 0.26315789, 0.31578947, 0.36842105, 0.42105263, 0.47368421,\n",
562 | " 0.52631579, 0.57894737, 0.63157895, 0.68421053, 0.73684211,\n",
563 | " 0.78947368, 0.84210526, 0.89473684, 0.94736842, 1. ])"
564 | ]
565 | },
566 | "execution_count": 46,
567 | "metadata": {},
568 | "output_type": "execute_result"
569 | }
570 | ],
571 | "source": [
572 | "np.linspace(0,1,20)"
573 | ]
574 | },
575 | {
576 | "cell_type": "code",
577 | "execution_count": 12,
578 | "metadata": {},
579 | "outputs": [
580 | {
581 | "data": {
582 | "text/plain": [
583 | "array([0. , 0.05263158, 0.10526316, 0.15789474, 0.21052632,\n",
584 | " 0.26315789, 0.31578947, 0.36842105, 0.42105263, 0.47368421,\n",
585 | " 0.52631579, 0.57894737, 0.63157895, 0.68421053, 0.73684211,\n",
586 | " 0.78947368, 0.84210526, 0.89473684, 0.94736842, 1. ])"
587 | ]
588 | },
589 | "execution_count": 12,
590 | "metadata": {},
591 | "output_type": "execute_result"
592 | }
593 | ],
594 | "source": [
595 | "# DON'T WRITE HERE"
596 | ]
597 | },
598 | {
599 | "cell_type": "markdown",
600 | "metadata": {},
601 | "source": [
602 | "## Numpy Indexing and Selection\n",
603 | "\n",
604 | "Now you will be given a starting matrix (be sure to run the cell below!), and be asked to replicate the resulting matrix outputs:"
605 | ]
606 | },
607 | {
608 | "cell_type": "code",
609 | "execution_count": 48,
610 | "metadata": {},
611 | "outputs": [
612 | {
613 | "data": {
614 | "text/plain": [
615 | "array([[ 1, 2, 3, 4, 5],\n",
616 | " [ 6, 7, 8, 9, 10],\n",
617 | " [11, 12, 13, 14, 15],\n",
618 | " [16, 17, 18, 19, 20],\n",
619 | " [21, 22, 23, 24, 25]])"
620 | ]
621 | },
622 | "execution_count": 48,
623 | "metadata": {},
624 | "output_type": "execute_result"
625 | }
626 | ],
627 | "source": [
628 | "# RUN THIS CELL - THIS IS OUR STARTING MATRIX\n",
629 | "mat = np.arange(1,26).reshape(5,5)\n",
630 | "mat"
631 | ]
632 | },
633 | {
634 | "cell_type": "markdown",
635 | "metadata": {},
636 | "source": [
637 | "#### 13. Write code that reproduces the output shown below.
Be careful not to run the cell immediately above the output, otherwise you won't be able to see the output any more."
638 | ]
639 | },
640 | {
641 | "cell_type": "code",
642 | "execution_count": 56,
643 | "metadata": {},
644 | "outputs": [
645 | {
646 | "data": {
647 | "text/plain": [
648 | "array([[12, 13, 14, 15],\n",
649 | " [17, 18, 19, 20],\n",
650 | " [22, 23, 24, 25]])"
651 | ]
652 | },
653 | "execution_count": 56,
654 | "metadata": {},
655 | "output_type": "execute_result"
656 | }
657 | ],
658 | "source": [
659 | "# CODE HERE\n",
660 | "mat[2:,1:]"
661 | ]
662 | },
663 | {
664 | "cell_type": "code",
665 | "execution_count": 14,
666 | "metadata": {},
667 | "outputs": [
668 | {
669 | "data": {
670 | "text/plain": [
671 | "array([[12, 13, 14, 15],\n",
672 | " [17, 18, 19, 20],\n",
673 | " [22, 23, 24, 25]])"
674 | ]
675 | },
676 | "execution_count": 14,
677 | "metadata": {},
678 | "output_type": "execute_result"
679 | }
680 | ],
681 | "source": [
682 | "# DON'T WRITE HERE"
683 | ]
684 | },
685 | {
686 | "cell_type": "markdown",
687 | "metadata": {},
688 | "source": [
689 | "#### 14. Write code that reproduces the output shown below."
690 | ]
691 | },
692 | {
693 | "cell_type": "code",
694 | "execution_count": 57,
695 | "metadata": {},
696 | "outputs": [
697 | {
698 | "data": {
699 | "text/plain": [
700 | "20"
701 | ]
702 | },
703 | "execution_count": 57,
704 | "metadata": {},
705 | "output_type": "execute_result"
706 | }
707 | ],
708 | "source": [
709 | "mat[3,4]"
710 | ]
711 | },
712 | {
713 | "cell_type": "code",
714 | "execution_count": 15,
715 | "metadata": {},
716 | "outputs": [
717 | {
718 | "data": {
719 | "text/plain": [
720 | "20"
721 | ]
722 | },
723 | "execution_count": 15,
724 | "metadata": {},
725 | "output_type": "execute_result"
726 | }
727 | ],
728 | "source": [
729 | "# DON'T WRITE HERE"
730 | ]
731 | },
732 | {
733 | "cell_type": "markdown",
734 | "metadata": {},
735 | "source": [
736 | "#### 15. Write code that reproduces the output shown below."
737 | ]
738 | },
739 | {
740 | "cell_type": "code",
741 | "execution_count": 58,
742 | "metadata": {},
743 | "outputs": [
744 | {
745 | "data": {
746 | "text/plain": [
747 | "array([[ 2],\n",
748 | " [ 7],\n",
749 | " [12]])"
750 | ]
751 | },
752 | "execution_count": 58,
753 | "metadata": {},
754 | "output_type": "execute_result"
755 | }
756 | ],
757 | "source": [
758 | "mat[:3,1:2]"
759 | ]
760 | },
761 | {
762 | "cell_type": "code",
763 | "execution_count": 16,
764 | "metadata": {},
765 | "outputs": [
766 | {
767 | "data": {
768 | "text/plain": [
769 | "array([[ 2],\n",
770 | " [ 7],\n",
771 | " [12]])"
772 | ]
773 | },
774 | "execution_count": 16,
775 | "metadata": {},
776 | "output_type": "execute_result"
777 | }
778 | ],
779 | "source": [
780 | "# DON'T WRITE HERE"
781 | ]
782 | },
783 | {
784 | "cell_type": "markdown",
785 | "metadata": {},
786 | "source": [
787 | "#### 16. Write code that reproduces the output shown below."
788 | ]
789 | },
790 | {
791 | "cell_type": "code",
792 | "execution_count": 61,
793 | "metadata": {},
794 | "outputs": [
795 | {
796 | "data": {
797 | "text/plain": [
798 | "array([21, 22, 23, 24, 25])"
799 | ]
800 | },
801 | "execution_count": 61,
802 | "metadata": {},
803 | "output_type": "execute_result"
804 | }
805 | ],
806 | "source": [
807 | "mat[4]"
808 | ]
809 | },
810 | {
811 | "cell_type": "code",
812 | "execution_count": 17,
813 | "metadata": {},
814 | "outputs": [
815 | {
816 | "data": {
817 | "text/plain": [
818 | "array([21, 22, 23, 24, 25])"
819 | ]
820 | },
821 | "execution_count": 17,
822 | "metadata": {},
823 | "output_type": "execute_result"
824 | }
825 | ],
826 | "source": [
827 | "# DON'T WRITE HERE"
828 | ]
829 | },
830 | {
831 | "cell_type": "markdown",
832 | "metadata": {},
833 | "source": [
834 | "#### 17. Write code that reproduces the output shown below."
835 | ]
836 | },
837 | {
838 | "cell_type": "code",
839 | "execution_count": 62,
840 | "metadata": {},
841 | "outputs": [
842 | {
843 | "data": {
844 | "text/plain": [
845 | "array([[16, 17, 18, 19, 20],\n",
846 | " [21, 22, 23, 24, 25]])"
847 | ]
848 | },
849 | "execution_count": 62,
850 | "metadata": {},
851 | "output_type": "execute_result"
852 | }
853 | ],
854 | "source": [
855 | "mat[3:,:]"
856 | ]
857 | },
858 | {
859 | "cell_type": "code",
860 | "execution_count": 18,
861 | "metadata": {},
862 | "outputs": [
863 | {
864 | "data": {
865 | "text/plain": [
866 | "array([[16, 17, 18, 19, 20],\n",
867 | " [21, 22, 23, 24, 25]])"
868 | ]
869 | },
870 | "execution_count": 18,
871 | "metadata": {},
872 | "output_type": "execute_result"
873 | }
874 | ],
875 | "source": [
876 | "# DON'T WRITE HERE"
877 | ]
878 | },
879 | {
880 | "cell_type": "markdown",
881 | "metadata": {},
882 | "source": [
883 | "## NumPy Operations"
884 | ]
885 | },
886 | {
887 | "cell_type": "markdown",
888 | "metadata": {},
889 | "source": [
890 | "#### 18. Get the sum of all the values in mat"
891 | ]
892 | },
893 | {
894 | "cell_type": "code",
895 | "execution_count": 63,
896 | "metadata": {},
897 | "outputs": [
898 | {
899 | "data": {
900 | "text/plain": [
901 | "325"
902 | ]
903 | },
904 | "execution_count": 63,
905 | "metadata": {},
906 | "output_type": "execute_result"
907 | }
908 | ],
909 | "source": [
910 | "mat.sum()"
911 | ]
912 | },
913 | {
914 | "cell_type": "code",
915 | "execution_count": 19,
916 | "metadata": {},
917 | "outputs": [
918 | {
919 | "data": {
920 | "text/plain": [
921 | "325"
922 | ]
923 | },
924 | "execution_count": 19,
925 | "metadata": {},
926 | "output_type": "execute_result"
927 | }
928 | ],
929 | "source": [
930 | "# DON'T WRITE HERE"
931 | ]
932 | },
933 | {
934 | "cell_type": "markdown",
935 | "metadata": {},
936 | "source": [
937 | "#### 19. Get the standard deviation of the values in mat"
938 | ]
939 | },
940 | {
941 | "cell_type": "code",
942 | "execution_count": 65,
943 | "metadata": {},
944 | "outputs": [
945 | {
946 | "data": {
947 | "text/plain": [
948 | "7.211102550927978"
949 | ]
950 | },
951 | "execution_count": 65,
952 | "metadata": {},
953 | "output_type": "execute_result"
954 | }
955 | ],
956 | "source": [
957 | "mat.std()"
958 | ]
959 | },
960 | {
961 | "cell_type": "code",
962 | "execution_count": 20,
963 | "metadata": {},
964 | "outputs": [
965 | {
966 | "data": {
967 | "text/plain": [
968 | "7.211102550927978"
969 | ]
970 | },
971 | "execution_count": 20,
972 | "metadata": {},
973 | "output_type": "execute_result"
974 | }
975 | ],
976 | "source": [
977 | "# DON'T WRITE HERE"
978 | ]
979 | },
980 | {
981 | "cell_type": "markdown",
982 | "metadata": {},
983 | "source": [
984 | "#### 20. Get the sum of all the columns in mat"
985 | ]
986 | },
987 | {
988 | "cell_type": "code",
989 | "execution_count": 66,
990 | "metadata": {},
991 | "outputs": [
992 | {
993 | "data": {
994 | "text/plain": [
995 | "array([55, 60, 65, 70, 75])"
996 | ]
997 | },
998 | "execution_count": 66,
999 | "metadata": {},
1000 | "output_type": "execute_result"
1001 | }
1002 | ],
1003 | "source": [
1004 | "mat.sum(axis=0)"
1005 | ]
1006 | },
1007 | {
1008 | "cell_type": "code",
1009 | "execution_count": 21,
1010 | "metadata": {},
1011 | "outputs": [
1012 | {
1013 | "data": {
1014 | "text/plain": [
1015 | "array([55, 60, 65, 70, 75])"
1016 | ]
1017 | },
1018 | "execution_count": 21,
1019 | "metadata": {},
1020 | "output_type": "execute_result"
1021 | }
1022 | ],
1023 | "source": [
1024 | "# DON'T WRITE HERE"
1025 | ]
1026 | },
1027 | {
1028 | "cell_type": "markdown",
1029 | "metadata": {},
1030 | "source": [
1031 | "## Bonus Question\n",
1032 | "We worked a lot with random data with numpy, but is there a way we can insure that we always get the same random numbers? What does the seed value mean? Does it matter what the actual number is? [Click Here for a Hint](https://www.google.com/search?q=numpy+random+seed)"
1033 | ]
1034 | },
1035 | {
1036 | "cell_type": "code",
1037 | "execution_count": 11,
1038 | "metadata": {},
1039 | "outputs": [
1040 | {
1041 | "data": {
1042 | "text/plain": [
1043 | "array([0.37454012, 0.95071431])"
1044 | ]
1045 | },
1046 | "execution_count": 11,
1047 | "metadata": {},
1048 | "output_type": "execute_result"
1049 | }
1050 | ],
1051 | "source": [
1052 | "np.random.seed(42)\n",
1053 | "np.random.rand(2)"
1054 | ]
1055 | },
1056 | {
1057 | "cell_type": "markdown",
1058 | "metadata": {
1059 | "collapsed": true,
1060 | "jupyter": {
1061 | "outputs_hidden": true
1062 | }
1063 | },
1064 | "source": [
1065 | "# Great Job!"
1066 | ]
1067 | }
1068 | ],
1069 | "metadata": {
1070 | "anaconda-cloud": {},
1071 | "kernelspec": {
1072 | "display_name": "Python 3 (ipykernel)",
1073 | "language": "python",
1074 | "name": "python3"
1075 | },
1076 | "language_info": {
1077 | "codemirror_mode": {
1078 | "name": "ipython",
1079 | "version": 3
1080 | },
1081 | "file_extension": ".py",
1082 | "mimetype": "text/x-python",
1083 | "name": "python",
1084 | "nbconvert_exporter": "python",
1085 | "pygments_lexer": "ipython3",
1086 | "version": "3.8.10"
1087 | }
1088 | },
1089 | "nbformat": 4,
1090 | "nbformat_minor": 4
1091 | }
1092 |
--------------------------------------------------------------------------------
/Exercise Notebooks/Playing_With_Numpy_Library.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "id": "b9499a42-604e-41af-889d-140cec4baace",
7 | "metadata": {},
8 | "outputs": [],
9 | "source": [
10 | "import numpy as np"
11 | ]
12 | },
13 | {
14 | "cell_type": "code",
15 | "execution_count": 2,
16 | "id": "38d272a3-447f-4636-8341-76827f10a53a",
17 | "metadata": {},
18 | "outputs": [],
19 | "source": [
20 | "first_array = np.array([[10,20,30],[40,50,60]])"
21 | ]
22 | },
23 | {
24 | "cell_type": "code",
25 | "execution_count": 3,
26 | "id": "454e89e1-c805-4845-9e84-0ae931dfd351",
27 | "metadata": {},
28 | "outputs": [
29 | {
30 | "name": "stdout",
31 | "output_type": "stream",
32 | "text": [
33 | "[[10 20 30]\n",
34 | " [40 50 60]]\n"
35 | ]
36 | }
37 | ],
38 | "source": [
39 | "print(first_array)"
40 | ]
41 | },
42 | {
43 | "cell_type": "code",
44 | "execution_count": 4,
45 | "id": "087623e2-973f-4208-9335-5557b11d42c6",
46 | "metadata": {},
47 | "outputs": [
48 | {
49 | "name": "stdout",
50 | "output_type": "stream",
51 | "text": [
52 | "[10 20 30]\n",
53 | "[40 50 60]\n"
54 | ]
55 | }
56 | ],
57 | "source": [
58 | "for i in first_array:\n",
59 | " print(i)"
60 | ]
61 | },
62 | {
63 | "cell_type": "code",
64 | "execution_count": 5,
65 | "id": "ce319ee7-24f1-4446-aaa8-90d8b548cefd",
66 | "metadata": {},
67 | "outputs": [
68 | {
69 | "name": "stdout",
70 | "output_type": "stream",
71 | "text": [
72 | "10\n",
73 | "20\n",
74 | "30\n",
75 | "40\n",
76 | "50\n",
77 | "60\n"
78 | ]
79 | }
80 | ],
81 | "source": [
82 | "for i in first_array:\n",
83 | " for j in i: \n",
84 | " print(j)"
85 | ]
86 | },
87 | {
88 | "cell_type": "code",
89 | "execution_count": 6,
90 | "id": "b6f37ae7-e18a-46ca-8945-16beed12a5cf",
91 | "metadata": {},
92 | "outputs": [
93 | {
94 | "data": {
95 | "text/plain": [
96 | "numpy.ndarray"
97 | ]
98 | },
99 | "execution_count": 6,
100 | "metadata": {},
101 | "output_type": "execute_result"
102 | }
103 | ],
104 | "source": [
105 | "type(first_array)"
106 | ]
107 | },
108 | {
109 | "cell_type": "code",
110 | "execution_count": 7,
111 | "id": "8df5ae2f-4686-4ea3-a1c6-5399d4baa8f7",
112 | "metadata": {},
113 | "outputs": [],
114 | "source": [
115 | "second_array = np.array(range(100))"
116 | ]
117 | },
118 | {
119 | "cell_type": "code",
120 | "execution_count": 8,
121 | "id": "2fe72892-2c3c-4511-ac1c-3c448c5c06c5",
122 | "metadata": {},
123 | "outputs": [
124 | {
125 | "name": "stdout",
126 | "output_type": "stream",
127 | "text": [
128 | "[[ 0 1 2 3 4 5 6 7 8 9]\n",
129 | " [10 11 12 13 14 15 16 17 18 19]\n",
130 | " [20 21 22 23 24 25 26 27 28 29]\n",
131 | " [30 31 32 33 34 35 36 37 38 39]\n",
132 | " [40 41 42 43 44 45 46 47 48 49]\n",
133 | " [50 51 52 53 54 55 56 57 58 59]\n",
134 | " [60 61 62 63 64 65 66 67 68 69]\n",
135 | " [70 71 72 73 74 75 76 77 78 79]\n",
136 | " [80 81 82 83 84 85 86 87 88 89]\n",
137 | " [90 91 92 93 94 95 96 97 98 99]]\n"
138 | ]
139 | }
140 | ],
141 | "source": [
142 | "print(second_array.reshape(10,10))"
143 | ]
144 | },
145 | {
146 | "cell_type": "code",
147 | "execution_count": 9,
148 | "id": "063b49a8-c352-4551-8a27-27287ca1d8df",
149 | "metadata": {},
150 | "outputs": [],
151 | "source": [
152 | "third_array = np.array([[[0,1],[2,3]],[[4,5],[6,7]]])"
153 | ]
154 | },
155 | {
156 | "cell_type": "code",
157 | "execution_count": 10,
158 | "id": "75c84eba-6475-4b62-8268-448d1c54f44b",
159 | "metadata": {},
160 | "outputs": [
161 | {
162 | "name": "stdout",
163 | "output_type": "stream",
164 | "text": [
165 | "0\n",
166 | "1\n",
167 | "2\n",
168 | "3\n",
169 | "4\n",
170 | "5\n",
171 | "6\n",
172 | "7\n"
173 | ]
174 | }
175 | ],
176 | "source": [
177 | "for i in third_array:\n",
178 | " for j in i:\n",
179 | " for k in j:\n",
180 | " print(k)"
181 | ]
182 | },
183 | {
184 | "cell_type": "code",
185 | "execution_count": 11,
186 | "id": "a115da36-4f4f-46fa-acd0-e6b0adb34b3d",
187 | "metadata": {},
188 | "outputs": [
189 | {
190 | "name": "stdout",
191 | "output_type": "stream",
192 | "text": [
193 | "0\n",
194 | "1\n",
195 | "2\n",
196 | "3\n",
197 | "4\n",
198 | "5\n",
199 | "6\n",
200 | "7\n"
201 | ]
202 | }
203 | ],
204 | "source": [
205 | "for i in np.nditer(third_array):\n",
206 | " print(i)"
207 | ]
208 | },
209 | {
210 | "cell_type": "code",
211 | "execution_count": 12,
212 | "id": "743b8459-08b7-47e7-ad8b-d62a953ac6df",
213 | "metadata": {},
214 | "outputs": [
215 | {
216 | "name": "stdout",
217 | "output_type": "stream",
218 | "text": [
219 | "(0, 0, 0) 0\n",
220 | "(0, 0, 1) 1\n",
221 | "(0, 1, 0) 2\n",
222 | "(0, 1, 1) 3\n",
223 | "(1, 0, 0) 4\n",
224 | "(1, 0, 1) 5\n",
225 | "(1, 1, 0) 6\n",
226 | "(1, 1, 1) 7\n"
227 | ]
228 | }
229 | ],
230 | "source": [
231 | "# hey, binary to decimal system, I'm lucky :)\n",
232 | "for i,j in np.ndenumerate(third_array):\n",
233 | " print(i,j)"
234 | ]
235 | },
236 | {
237 | "cell_type": "code",
238 | "execution_count": 13,
239 | "id": "9dfdf998-bc9f-420f-b9bb-32644c931ab7",
240 | "metadata": {},
241 | "outputs": [],
242 | "source": [
243 | "python_list = [[1,2] , [3,4] , [5,6]]"
244 | ]
245 | },
246 | {
247 | "cell_type": "code",
248 | "execution_count": 14,
249 | "id": "eaf4b23c-b1ab-4d0f-8b12-07a12cf5b8a5",
250 | "metadata": {},
251 | "outputs": [
252 | {
253 | "data": {
254 | "text/plain": [
255 | "array([[1, 2],\n",
256 | " [3, 4],\n",
257 | " [5, 6]])"
258 | ]
259 | },
260 | "execution_count": 14,
261 | "metadata": {},
262 | "output_type": "execute_result"
263 | }
264 | ],
265 | "source": [
266 | "np.array(python_list)"
267 | ]
268 | },
269 | {
270 | "cell_type": "code",
271 | "execution_count": 15,
272 | "id": "e56dbf39-4f4a-42ff-80fb-bb66001a4565",
273 | "metadata": {},
274 | "outputs": [
275 | {
276 | "data": {
277 | "text/plain": [
278 | "array([ 0, 2, 4, 6, 8, 10])"
279 | ]
280 | },
281 | "execution_count": 15,
282 | "metadata": {},
283 | "output_type": "execute_result"
284 | }
285 | ],
286 | "source": [
287 | "np.arange(0,11,2)"
288 | ]
289 | },
290 | {
291 | "cell_type": "code",
292 | "execution_count": 16,
293 | "id": "99989246-c773-4893-b9c6-1b4c9d27c2fe",
294 | "metadata": {},
295 | "outputs": [
296 | {
297 | "data": {
298 | "text/plain": [
299 | "array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])"
300 | ]
301 | },
302 | "execution_count": 16,
303 | "metadata": {},
304 | "output_type": "execute_result"
305 | }
306 | ],
307 | "source": [
308 | "np.zeros(10 , int)"
309 | ]
310 | },
311 | {
312 | "cell_type": "code",
313 | "execution_count": 17,
314 | "id": "fca3b98f-0da3-4c82-ae40-300f132603e8",
315 | "metadata": {},
316 | "outputs": [
317 | {
318 | "data": {
319 | "text/plain": [
320 | "array([[0, 0, 0],\n",
321 | " [0, 0, 0],\n",
322 | " [0, 0, 0]])"
323 | ]
324 | },
325 | "execution_count": 17,
326 | "metadata": {},
327 | "output_type": "execute_result"
328 | }
329 | ],
330 | "source": [
331 | "np.zeros((3,3) , int)"
332 | ]
333 | },
334 | {
335 | "cell_type": "code",
336 | "execution_count": 18,
337 | "id": "e268c25d-4581-4441-9c4f-e956316e9bfc",
338 | "metadata": {},
339 | "outputs": [
340 | {
341 | "data": {
342 | "text/plain": [
343 | "array([[[1., 1., 1., 1.],\n",
344 | " [1., 1., 1., 1.]],\n",
345 | "\n",
346 | " [[1., 1., 1., 1.],\n",
347 | " [1., 1., 1., 1.]],\n",
348 | "\n",
349 | " [[1., 1., 1., 1.],\n",
350 | " [1., 1., 1., 1.]],\n",
351 | "\n",
352 | " [[1., 1., 1., 1.],\n",
353 | " [1., 1., 1., 1.]],\n",
354 | "\n",
355 | " [[1., 1., 1., 1.],\n",
356 | " [1., 1., 1., 1.]]])"
357 | ]
358 | },
359 | "execution_count": 18,
360 | "metadata": {},
361 | "output_type": "execute_result"
362 | }
363 | ],
364 | "source": [
365 | "np.ones((5,2,4))"
366 | ]
367 | },
368 | {
369 | "cell_type": "code",
370 | "execution_count": 19,
371 | "id": "3b116d19-1650-46c5-8257-369c50b23cf2",
372 | "metadata": {},
373 | "outputs": [
374 | {
375 | "data": {
376 | "text/plain": [
377 | "array([[1, 0, 0],\n",
378 | " [0, 1, 0],\n",
379 | " [0, 0, 1]])"
380 | ]
381 | },
382 | "execution_count": 19,
383 | "metadata": {},
384 | "output_type": "execute_result"
385 | }
386 | ],
387 | "source": [
388 | "#diagonal matrices\n",
389 | "np.eye(3,dtype=int)"
390 | ]
391 | },
392 | {
393 | "cell_type": "code",
394 | "execution_count": 20,
395 | "id": "14348881-36f8-4385-929a-767be93da987",
396 | "metadata": {},
397 | "outputs": [
398 | {
399 | "data": {
400 | "text/plain": [
401 | "array([[0.23125289, 0.17657115, 0.73858594],\n",
402 | " [0.34483192, 0.40058807, 0.39550327],\n",
403 | " [0.37153114, 0.40700279, 0.77381529]])"
404 | ]
405 | },
406 | "execution_count": 20,
407 | "metadata": {},
408 | "output_type": "execute_result"
409 | }
410 | ],
411 | "source": [
412 | "#between 0 and 1\n",
413 | "np.random.rand(3,3)"
414 | ]
415 | },
416 | {
417 | "cell_type": "code",
418 | "execution_count": 21,
419 | "id": "90199006-29a6-489c-ae4a-589652d6292d",
420 | "metadata": {},
421 | "outputs": [
422 | {
423 | "data": {
424 | "text/plain": [
425 | "array([[ 0.43468629, 0.77698343, -0.26364651, 0.71574969],\n",
426 | " [-0.4778537 , -1.68156296, 0.85724506, 0.54020524]])"
427 | ]
428 | },
429 | "execution_count": 21,
430 | "metadata": {},
431 | "output_type": "execute_result"
432 | }
433 | ],
434 | "source": [
435 | "# standard distribution contain variance number(negetive)\n",
436 | "np.random.randn(2,4)"
437 | ]
438 | },
439 | {
440 | "cell_type": "code",
441 | "execution_count": 22,
442 | "id": "47667242-00bb-40d2-b3a7-2632f4190950",
443 | "metadata": {},
444 | "outputs": [
445 | {
446 | "data": {
447 | "text/plain": [
448 | "array([[35, 47, 26, 4, 48],\n",
449 | " [42, 25, 16, 27, 10],\n",
450 | " [35, 27, 17, 31, 18]])"
451 | ]
452 | },
453 | "execution_count": 22,
454 | "metadata": {},
455 | "output_type": "execute_result"
456 | }
457 | ],
458 | "source": [
459 | "np.random.randint(0,50,(3,5))"
460 | ]
461 | },
462 | {
463 | "cell_type": "code",
464 | "execution_count": 23,
465 | "id": "e099b25c-c09a-403a-ad76-260fb4ebf380",
466 | "metadata": {},
467 | "outputs": [
468 | {
469 | "data": {
470 | "text/plain": [
471 | "array([51, 92, 14, 71, 60, 20, 82, 86, 74, 74])"
472 | ]
473 | },
474 | "execution_count": 23,
475 | "metadata": {},
476 | "output_type": "execute_result"
477 | }
478 | ],
479 | "source": [
480 | "# but this section doesn't change any compile and default value with np.random.seed()\n",
481 | "# especially in machine learning algorithms\n",
482 | "np.random.seed(42)\n",
483 | "np.random.randint(0,100,10)"
484 | ]
485 | },
486 | {
487 | "cell_type": "code",
488 | "execution_count": 24,
489 | "id": "33039e74-390f-4f16-a61e-e081aac46ead",
490 | "metadata": {},
491 | "outputs": [
492 | {
493 | "data": {
494 | "text/plain": [
495 | "array([87, 99, 23, 2, 21, 52, 1, 87, 29, 37])"
496 | ]
497 | },
498 | "execution_count": 24,
499 | "metadata": {},
500 | "output_type": "execute_result"
501 | }
502 | ],
503 | "source": [
504 | "# in any compile reproduce new value\n",
505 | "np.random.randint(0,100,10)"
506 | ]
507 | },
508 | {
509 | "cell_type": "code",
510 | "execution_count": 25,
511 | "id": "1b0e1455-9b5b-4b9d-b813-0395cbdac563",
512 | "metadata": {},
513 | "outputs": [],
514 | "source": [
515 | "ex_arr = np.random.randint(0,100,10)"
516 | ]
517 | },
518 | {
519 | "cell_type": "code",
520 | "execution_count": 26,
521 | "id": "12543062-2799-4d00-8280-3dbb20dc2345",
522 | "metadata": {},
523 | "outputs": [
524 | {
525 | "data": {
526 | "text/plain": [
527 | "numpy.ndarray"
528 | ]
529 | },
530 | "execution_count": 26,
531 | "metadata": {},
532 | "output_type": "execute_result"
533 | }
534 | ],
535 | "source": [
536 | "type(ex_arr)"
537 | ]
538 | },
539 | {
540 | "cell_type": "code",
541 | "execution_count": 27,
542 | "id": "29f55460-b5f3-4b10-af0a-96086e975a57",
543 | "metadata": {},
544 | "outputs": [
545 | {
546 | "data": {
547 | "text/plain": [
548 | "dtype('int32')"
549 | ]
550 | },
551 | "execution_count": 27,
552 | "metadata": {},
553 | "output_type": "execute_result"
554 | }
555 | ],
556 | "source": [
557 | "ex_arr.dtype"
558 | ]
559 | },
560 | {
561 | "cell_type": "code",
562 | "execution_count": 28,
563 | "id": "4e4f3fa4-059e-43b7-ac97-fa60aa53ba6f",
564 | "metadata": {},
565 | "outputs": [
566 | {
567 | "data": {
568 | "text/plain": [
569 | "(10,)"
570 | ]
571 | },
572 | "execution_count": 28,
573 | "metadata": {},
574 | "output_type": "execute_result"
575 | }
576 | ],
577 | "source": [
578 | "ex_arr.shape"
579 | ]
580 | },
581 | {
582 | "cell_type": "code",
583 | "execution_count": 29,
584 | "id": "7f1ffe8c-23a0-4d38-82d8-df14d8450f1a",
585 | "metadata": {},
586 | "outputs": [
587 | {
588 | "data": {
589 | "text/plain": [
590 | "array([[ 1, 63, 59, 20, 32],\n",
591 | " [75, 57, 21, 88, 48]])"
592 | ]
593 | },
594 | "execution_count": 29,
595 | "metadata": {},
596 | "output_type": "execute_result"
597 | }
598 | ],
599 | "source": [
600 | "ex_arr.reshape(2,5)"
601 | ]
602 | },
603 | {
604 | "cell_type": "code",
605 | "execution_count": 30,
606 | "id": "adc377f2-3d76-430c-bb28-f30e99e6494f",
607 | "metadata": {},
608 | "outputs": [
609 | {
610 | "data": {
611 | "text/plain": [
612 | "88"
613 | ]
614 | },
615 | "execution_count": 30,
616 | "metadata": {},
617 | "output_type": "execute_result"
618 | }
619 | ],
620 | "source": [
621 | "ex_arr.max()"
622 | ]
623 | },
624 | {
625 | "cell_type": "code",
626 | "execution_count": 31,
627 | "id": "63c679b1-d835-4235-906d-1394a39c2df5",
628 | "metadata": {},
629 | "outputs": [
630 | {
631 | "data": {
632 | "text/plain": [
633 | "8"
634 | ]
635 | },
636 | "execution_count": 31,
637 | "metadata": {},
638 | "output_type": "execute_result"
639 | }
640 | ],
641 | "source": [
642 | "ex_arr.argmax()"
643 | ]
644 | },
645 | {
646 | "cell_type": "code",
647 | "execution_count": 32,
648 | "id": "01281f3f-5c31-400e-bd6d-8ef06210b964",
649 | "metadata": {},
650 | "outputs": [],
651 | "source": [
652 | "arr_2d = np.array([[1,2,3],[4,5,6],[7,8,9]])"
653 | ]
654 | },
655 | {
656 | "cell_type": "code",
657 | "execution_count": 33,
658 | "id": "4acc3789-fcca-4b5c-85d8-e33468c908c1",
659 | "metadata": {},
660 | "outputs": [
661 | {
662 | "data": {
663 | "text/plain": [
664 | "(3, 3)"
665 | ]
666 | },
667 | "execution_count": 33,
668 | "metadata": {},
669 | "output_type": "execute_result"
670 | }
671 | ],
672 | "source": [
673 | "arr_2d.shape"
674 | ]
675 | },
676 | {
677 | "cell_type": "code",
678 | "execution_count": 34,
679 | "id": "fb9f7640-d7f7-4706-bde2-c336c792ee5f",
680 | "metadata": {},
681 | "outputs": [
682 | {
683 | "data": {
684 | "text/plain": [
685 | "array([[4, 5, 6]])"
686 | ]
687 | },
688 | "execution_count": 34,
689 | "metadata": {},
690 | "output_type": "execute_result"
691 | }
692 | ],
693 | "source": [
694 | "arr_2d[1:2]"
695 | ]
696 | },
697 | {
698 | "cell_type": "code",
699 | "execution_count": 35,
700 | "id": "7006585b-a31e-4bec-8504-672431ada2aa",
701 | "metadata": {},
702 | "outputs": [],
703 | "source": [
704 | "arr_copy = arr_2d.copy()"
705 | ]
706 | },
707 | {
708 | "cell_type": "code",
709 | "execution_count": 36,
710 | "id": "50733767-33f8-4665-8340-3fef829da337",
711 | "metadata": {},
712 | "outputs": [
713 | {
714 | "data": {
715 | "text/plain": [
716 | "array([[4, 5],\n",
717 | " [7, 8]])"
718 | ]
719 | },
720 | "execution_count": 36,
721 | "metadata": {},
722 | "output_type": "execute_result"
723 | }
724 | ],
725 | "source": [
726 | "arr_copy[1:,:2]"
727 | ]
728 | },
729 | {
730 | "cell_type": "code",
731 | "execution_count": 37,
732 | "id": "df1c8e69-8a8f-4c4a-9335-4eac25fe8bde",
733 | "metadata": {},
734 | "outputs": [],
735 | "source": [
736 | "arr_bool = arr_copy > 4"
737 | ]
738 | },
739 | {
740 | "cell_type": "code",
741 | "execution_count": 38,
742 | "id": "c9efd0d5-d984-4f91-b2d2-a46049540e07",
743 | "metadata": {},
744 | "outputs": [
745 | {
746 | "data": {
747 | "text/plain": [
748 | "array([5, 6, 7, 8, 9])"
749 | ]
750 | },
751 | "execution_count": 38,
752 | "metadata": {},
753 | "output_type": "execute_result"
754 | }
755 | ],
756 | "source": [
757 | "arr_copy[arr_bool]"
758 | ]
759 | },
760 | {
761 | "cell_type": "code",
762 | "execution_count": 39,
763 | "id": "4c753625-9fed-4846-a8db-fe8ab190eaae",
764 | "metadata": {},
765 | "outputs": [
766 | {
767 | "data": {
768 | "text/plain": [
769 | "45"
770 | ]
771 | },
772 | "execution_count": 39,
773 | "metadata": {},
774 | "output_type": "execute_result"
775 | }
776 | ],
777 | "source": [
778 | "arr_copy.sum()"
779 | ]
780 | },
781 | {
782 | "cell_type": "code",
783 | "execution_count": 40,
784 | "id": "eb4be50c-2fe0-4a58-81c0-54156e9aeb1d",
785 | "metadata": {},
786 | "outputs": [
787 | {
788 | "data": {
789 | "text/plain": [
790 | "5.0"
791 | ]
792 | },
793 | "execution_count": 40,
794 | "metadata": {},
795 | "output_type": "execute_result"
796 | }
797 | ],
798 | "source": [
799 | "arr_copy.mean()"
800 | ]
801 | },
802 | {
803 | "cell_type": "code",
804 | "execution_count": 41,
805 | "id": "279c5632-78aa-481c-b26e-54d4b1679a2c",
806 | "metadata": {},
807 | "outputs": [],
808 | "source": [
809 | "arr_5_5 = np.arange(25).reshape(5,5)"
810 | ]
811 | },
812 | {
813 | "cell_type": "code",
814 | "execution_count": 42,
815 | "id": "36d0b85e-30cf-471a-a032-cb0a2ebc5c66",
816 | "metadata": {},
817 | "outputs": [
818 | {
819 | "data": {
820 | "text/plain": [
821 | "array([[ 0, 1, 2, 3, 4],\n",
822 | " [ 5, 6, 7, 8, 9],\n",
823 | " [10, 11, 12, 13, 14],\n",
824 | " [15, 16, 17, 18, 19],\n",
825 | " [20, 21, 22, 23, 24]])"
826 | ]
827 | },
828 | "execution_count": 42,
829 | "metadata": {},
830 | "output_type": "execute_result"
831 | }
832 | ],
833 | "source": [
834 | "arr_5_5"
835 | ]
836 | },
837 | {
838 | "cell_type": "code",
839 | "execution_count": 43,
840 | "id": "0ef86885-5728-456b-a970-8d5cb2531147",
841 | "metadata": {},
842 | "outputs": [
843 | {
844 | "data": {
845 | "text/plain": [
846 | "array([50, 55, 60, 65, 70])"
847 | ]
848 | },
849 | "execution_count": 43,
850 | "metadata": {},
851 | "output_type": "execute_result"
852 | }
853 | ],
854 | "source": [
855 | "# column by column \n",
856 | "arr_5_5.sum(axis = 0)"
857 | ]
858 | },
859 | {
860 | "cell_type": "code",
861 | "execution_count": 44,
862 | "id": "c0f647f1-4f5d-43e0-b67d-4cf99c9ede17",
863 | "metadata": {},
864 | "outputs": [
865 | {
866 | "data": {
867 | "text/plain": [
868 | "array([ 10, 35, 60, 85, 110])"
869 | ]
870 | },
871 | "execution_count": 44,
872 | "metadata": {},
873 | "output_type": "execute_result"
874 | }
875 | ],
876 | "source": [
877 | "# row by row\n",
878 | "arr_5_5.sum(axis = 1)"
879 | ]
880 | },
881 | {
882 | "cell_type": "code",
883 | "execution_count": 45,
884 | "id": "057bff41-68bc-4f28-876f-f724e251ade3",
885 | "metadata": {},
886 | "outputs": [
887 | {
888 | "data": {
889 | "text/plain": [
890 | "array([ 2., 7., 12., 17., 22.])"
891 | ]
892 | },
893 | "execution_count": 45,
894 | "metadata": {},
895 | "output_type": "execute_result"
896 | }
897 | ],
898 | "source": [
899 | "# average of first row \n",
900 | "arr_5_5.mean(axis=1)"
901 | ]
902 | },
903 | {
904 | "cell_type": "code",
905 | "execution_count": 48,
906 | "id": "bbac4955-4e1b-47ff-9419-40f7804ef064",
907 | "metadata": {},
908 | "outputs": [
909 | {
910 | "data": {
911 | "text/plain": [
912 | "array([1, 2, 3, 4, 5, 6, 7, 8, 9])"
913 | ]
914 | },
915 | "execution_count": 48,
916 | "metadata": {},
917 | "output_type": "execute_result"
918 | }
919 | ],
920 | "source": [
921 | "# use in neural networks to flat the array \n",
922 | "arr_2d.flatten()"
923 | ]
924 | },
925 | {
926 | "cell_type": "code",
927 | "execution_count": 51,
928 | "id": "6206f7a9-d696-4ae6-bea5-6ec11165ee28",
929 | "metadata": {},
930 | "outputs": [
931 | {
932 | "data": {
933 | "text/plain": [
934 | "array([[1, 2, 3],\n",
935 | " [4, 5, 6],\n",
936 | " [7, 8, 9]])"
937 | ]
938 | },
939 | "execution_count": 51,
940 | "metadata": {},
941 | "output_type": "execute_result"
942 | }
943 | ],
944 | "source": [
945 | "arr_2d"
946 | ]
947 | },
948 | {
949 | "cell_type": "code",
950 | "execution_count": 53,
951 | "id": "9e912888-02c1-4549-b84f-ee4c99a55225",
952 | "metadata": {},
953 | "outputs": [
954 | {
955 | "data": {
956 | "text/plain": [
957 | "array([7, 8, 9])"
958 | ]
959 | },
960 | "execution_count": 53,
961 | "metadata": {},
962 | "output_type": "execute_result"
963 | }
964 | ],
965 | "source": [
966 | "arr_2d.max(axis=0)"
967 | ]
968 | },
969 | {
970 | "cell_type": "code",
971 | "execution_count": 55,
972 | "id": "9cca3470-c8fa-4719-9897-2b46e198fb47",
973 | "metadata": {},
974 | "outputs": [
975 | {
976 | "data": {
977 | "text/plain": [
978 | "array([1, 4, 7])"
979 | ]
980 | },
981 | "execution_count": 55,
982 | "metadata": {},
983 | "output_type": "execute_result"
984 | }
985 | ],
986 | "source": [
987 | "arr_2d.min(axis=1)"
988 | ]
989 | },
990 | {
991 | "cell_type": "code",
992 | "execution_count": 58,
993 | "id": "5448699e-68fd-4478-b023-d938f8c99625",
994 | "metadata": {},
995 | "outputs": [
996 | {
997 | "data": {
998 | "text/plain": [
999 | "array([[0, 0, 0],\n",
1000 | " [0, 1, 1],\n",
1001 | " [1, 1, 1]])"
1002 | ]
1003 | },
1004 | "execution_count": 58,
1005 | "metadata": {},
1006 | "output_type": "execute_result"
1007 | }
1008 | ],
1009 | "source": [
1010 | "# condition in array use np.where \n",
1011 | "np.where(arr_2d >= 5 , 1 , 0)"
1012 | ]
1013 | },
1014 | {
1015 | "cell_type": "code",
1016 | "execution_count": 73,
1017 | "id": "1d6157c6-e908-4dba-8c97-10ec4e7edb53",
1018 | "metadata": {},
1019 | "outputs": [],
1020 | "source": [
1021 | "np.random.shuffle(arr_5_5)\n",
1022 | "np.random.seed(55)"
1023 | ]
1024 | },
1025 | {
1026 | "cell_type": "code",
1027 | "execution_count": 74,
1028 | "id": "e483a583-ba09-4509-8766-a1dca3c61f46",
1029 | "metadata": {},
1030 | "outputs": [
1031 | {
1032 | "data": {
1033 | "text/plain": [
1034 | "array([[20, 21, 22, 23, 24],\n",
1035 | " [ 5, 6, 7, 8, 9],\n",
1036 | " [15, 16, 17, 18, 19],\n",
1037 | " [10, 11, 12, 13, 14],\n",
1038 | " [ 0, 1, 2, 3, 4]])"
1039 | ]
1040 | },
1041 | "execution_count": 74,
1042 | "metadata": {},
1043 | "output_type": "execute_result"
1044 | }
1045 | ],
1046 | "source": [
1047 | "arr_5_5"
1048 | ]
1049 | },
1050 | {
1051 | "cell_type": "code",
1052 | "execution_count": 83,
1053 | "id": "80241cb5-638a-4f07-be24-eb37d5ea4277",
1054 | "metadata": {},
1055 | "outputs": [
1056 | {
1057 | "data": {
1058 | "text/plain": [
1059 | "array([8, 1, 5, 0, 7, 2, 9, 4, 3, 6])"
1060 | ]
1061 | },
1062 | "execution_count": 83,
1063 | "metadata": {},
1064 | "output_type": "execute_result"
1065 | }
1066 | ],
1067 | "source": [
1068 | "np.random.seed(42)\n",
1069 | "np.random.permutation(10)"
1070 | ]
1071 | },
1072 | {
1073 | "cell_type": "code",
1074 | "execution_count": 85,
1075 | "id": "f5024991-565c-4aef-a7ad-903bc6825b84",
1076 | "metadata": {},
1077 | "outputs": [
1078 | {
1079 | "data": {
1080 | "text/plain": [
1081 | "array([[20, 21, 22, 23, 24],\n",
1082 | " [ 5, 6, 7, 8, 9],\n",
1083 | " [15, 16, 17, 18, 19],\n",
1084 | " [10, 11, 12, 13, 14],\n",
1085 | " [ 0, 1, 2, 3, 4]])"
1086 | ]
1087 | },
1088 | "execution_count": 85,
1089 | "metadata": {},
1090 | "output_type": "execute_result"
1091 | }
1092 | ],
1093 | "source": [
1094 | "np.random.permutation(arr_5_5)"
1095 | ]
1096 | },
1097 | {
1098 | "cell_type": "code",
1099 | "execution_count": 104,
1100 | "id": "ac266379-2e8e-42d7-a5ce-492bc9da32f9",
1101 | "metadata": {},
1102 | "outputs": [
1103 | {
1104 | "data": {
1105 | "text/plain": [
1106 | "[6, 7, 5]"
1107 | ]
1108 | },
1109 | "execution_count": 104,
1110 | "metadata": {},
1111 | "output_type": "execute_result"
1112 | }
1113 | ],
1114 | "source": [
1115 | "from random import sample \n",
1116 | "sample([2,5,6,7,8,9], 3)\n"
1117 | ]
1118 | }
1119 | ],
1120 | "metadata": {
1121 | "kernelspec": {
1122 | "display_name": "Python 3 (ipykernel)",
1123 | "language": "python",
1124 | "name": "python3"
1125 | },
1126 | "language_info": {
1127 | "codemirror_mode": {
1128 | "name": "ipython",
1129 | "version": 3
1130 | },
1131 | "file_extension": ".py",
1132 | "mimetype": "text/x-python",
1133 | "name": "python",
1134 | "nbconvert_exporter": "python",
1135 | "pygments_lexer": "ipython3",
1136 | "version": "3.8.10"
1137 | }
1138 | },
1139 | "nbformat": 4,
1140 | "nbformat_minor": 5
1141 | }
1142 |
--------------------------------------------------------------------------------
/Exercise Notebooks/Training_a_Convolutional_Layer_With_Recognition_Model_Using_Pytorch_on_the_MNIST_Dataset.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 9,
6 | "id": "12ffd64b-2022-4af4-98c8-1ef885cfb370",
7 | "metadata": {},
8 | "outputs": [],
9 | "source": [
10 | "# add requierment library to define & train model \n",
11 | "import torch\n",
12 | "import torch.nn as nn\n",
13 | "import torch.nn.functional as F\n",
14 | "from torch.utils.data import DataLoader\n",
15 | "from torchvision import datasets, transforms\n",
16 | "from torchvision.utils import make_grid\n",
17 | "\n",
18 | "import numpy as np\n",
19 | "import pandas as pd\n",
20 | "from sklearn.metrics import confusion_matrix\n",
21 | "import matplotlib.pyplot as plt"
22 | ]
23 | },
24 | {
25 | "cell_type": "code",
26 | "execution_count": 10,
27 | "id": "69bcc818-49f6-4d5a-85b5-096e39de7df7",
28 | "metadata": {},
29 | "outputs": [],
30 | "source": [
31 | "# download data train & test MNIST dataset from pytorchvision library \n",
32 | "transform = transforms.ToTensor()\n",
33 | "\n",
34 | "train_data = datasets.MNIST(root='/Data/MNIST_From_Download_Pytorchvision/train', train=True, download=True, transform=transform)\n",
35 | "test_data = datasets.MNIST(root='/Data/MNIST_From_Download_Pytorchvision/test', train=False, download=True, transform=transform)"
36 | ]
37 | },
38 | {
39 | "cell_type": "code",
40 | "execution_count": 12,
41 | "id": "65553a84-02ae-4961-982c-847bcf2ccc8f",
42 | "metadata": {},
43 | "outputs": [
44 | {
45 | "data": {
46 | "text/plain": [
47 | "Dataset MNIST\n",
48 | " Number of datapoints: 60000\n",
49 | " Root location: /Data/MNIST_From_Download_Pytorchvision/train\n",
50 | " Split: Train\n",
51 | " StandardTransform\n",
52 | "Transform: ToTensor()"
53 | ]
54 | },
55 | "execution_count": 12,
56 | "metadata": {},
57 | "output_type": "execute_result"
58 | }
59 | ],
60 | "source": [
61 | "# check amount of data train dataset\n",
62 | "train_data"
63 | ]
64 | },
65 | {
66 | "cell_type": "code",
67 | "execution_count": 13,
68 | "id": "9fb190dd-568f-47f9-8e54-c9115f2ce030",
69 | "metadata": {},
70 | "outputs": [
71 | {
72 | "data": {
73 | "text/plain": [
74 | "Dataset MNIST\n",
75 | " Number of datapoints: 10000\n",
76 | " Root location: /Data/MNIST_From_Download_Pytorchvision/test\n",
77 | " Split: Test\n",
78 | " StandardTransform\n",
79 | "Transform: ToTensor()"
80 | ]
81 | },
82 | "execution_count": 13,
83 | "metadata": {},
84 | "output_type": "execute_result"
85 | }
86 | ],
87 | "source": [
88 | "# check amount of data test dataset\n",
89 | "test_data"
90 | ]
91 | },
92 | {
93 | "cell_type": "code",
94 | "execution_count": 14,
95 | "id": "f1e648cb-a79c-42fa-ae74-5a1bf472ecd2",
96 | "metadata": {},
97 | "outputs": [],
98 | "source": [
99 | "# define train & test loader to load data to use it into model \n",
100 | "train_loader = DataLoader(train_data, batch_size=10, shuffle=True)\n",
101 | "test_loader = DataLoader(test_data, batch_size=10, shuffle=False)"
102 | ]
103 | },
104 | {
105 | "cell_type": "code",
106 | "execution_count": null,
107 | "id": "d5bf3328-2272-4ca1-9805-6664a04f7533",
108 | "metadata": {},
109 | "outputs": [],
110 | "source": []
111 | }
112 | ],
113 | "metadata": {
114 | "kernelspec": {
115 | "display_name": "Python 3 (ipykernel)",
116 | "language": "python",
117 | "name": "python3"
118 | },
119 | "language_info": {
120 | "codemirror_mode": {
121 | "name": "ipython",
122 | "version": 3
123 | },
124 | "file_extension": ".py",
125 | "mimetype": "text/x-python",
126 | "name": "python",
127 | "nbconvert_exporter": "python",
128 | "pygments_lexer": "ipython3",
129 | "version": "3.8.10"
130 | }
131 | },
132 | "nbformat": 4,
133 | "nbformat_minor": 5
134 | }
135 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Yasin Rezvani
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Hands_On_Machine_Learning_and_Deep_Learning_with_Python
2 | - **Supervisor:** [Dr. Mansoor Fateh](https://scholar.google.com/citations?user=ZHezeMIAAAAJ&hl=en)
3 | - **Organization:** [Computer Vision Lab at Shahrood University of Technology (CVLab SHUT)](https://github.com/CVLab-SHUT)
4 |
5 | This project was conducted under the supervision of Dr. Mansoor Fateh at CVLab SHUT, focusing on deep learning and computer vision research. The work utilized Python along with key libraries including NumPy, Pandas, Matplotlib, and Seaborn for data analysis and visualization, as well as Keras, TensorFlow, and PyTorch for implementing and training deep learning models on standard datasets (MNIST and CIFAR-10). The research aimed to develop practical skills in building and optimizing neural networks while adhering to academic methodologies.
6 | # Demo :tada:
7 | ## :fireworks: Loading_The_MNIST_Dataset :fireworks:
8 | https://github.com/YasinRezvani/Python_Learning_Practice_Notebooks/assets/77124662/416b0619-daa0-41d1-9a76-a0e3fa4b4e56
9 |
10 | ## :maple_leaf: Playing_With_Numpy_Library :maple_leaf:
11 | https://github.com/YasinRezvani/Python_Learning_Practice_Notebooks/assets/77124662/2c576aca-3831-4607-858e-dc6abdeae14a
12 |
13 | ## :gem: NumPy_Exercises_From_Udemy_Course :gem:
14 | https://github.com/YasinRezvani/Python_Learning_Practice_Notebooks/assets/77124662/3d409ede-ac5e-4c7e-ac47-2f898e2e3b82
15 |
16 | ## :v: Playing_With_Pandas_Library :v:
17 | https://github.com/YasinRezvani/Python_Learning_Practice_Notebooks/assets/77124662/b519cef7-d962-4f22-9ed0-6a6da0ef7762
18 |
19 | ## :muscle: Pandas_Exercises_From_Udemy_Course :muscle:
20 | https://github.com/YasinRezvani/Python_Learning_Practice_Notebooks/assets/77124662/92a618ca-9fd8-404e-8de9-fecf9962c2bb
21 |
22 | ## :sparkling_heart: Playing_With_Scipy_Library :sparkling_heart:
23 | https://github.com/YasinRezvani/Python_Learning_Practice_Notebooks/assets/77124662/454d1b23-94c4-4412-9c08-367e8a2b37de
24 |
25 | ## :airplane: Playing_With_Matplotlib_Library :airplane:
26 | https://github.com/YasinRezvani/Python_Learning_Practice_Notebooks/assets/77124662/095c7f36-3ad1-4bce-9114-b1a5ff51ebc6
27 |
28 | ## :rocket: Playing_With_Seaborn_Library :rocket:
29 | https://github.com/YasinRezvani/Python_Learning_Practice_Notebooks/assets/77124662/0c66a19f-b0ee-40f5-affe-cc24fcd9d3d6
30 |
31 | ## :christmas_tree: Training_a_Digit_Recognition_Model_Using_Keras_on_the_MNIST_Dataset :christmas_tree:
32 | https://github.com/YasinRezvani/Python_Learning_Practice_Notebooks/assets/77124662/cb97439a-66ff-44d0-92a4-f39808b4f353
33 |
34 | ## :chart_with_upwards_trend: Training_a_Recognition_Model_Using_Keras_on_the_CIFAR_10_Dataset :chart_with_upwards_trend:
35 | https://github.com/YasinRezvani/Python_Learning_Practice_Notebooks/assets/77124662/a53bce7d-0439-43a4-b378-20d0c399b17c
36 |
37 | ## :spades: Training_a_Convolution_Dense_Layer_With_Recognition_Model_Using_Keras_on_the_CIFAR_10_Dataset :spades:
38 | https://github.com/YasinRezvani/Python_Learning_Practice_Notebooks/assets/77124662/8afe3d84-148c-4f04-a8e0-09e67bc4703f
39 |
40 | ## :statue_of_liberty: How_to_Define_Functional_And_Sequential_Keras_Models :statue_of_liberty:
41 | https://github.com/YasinRezvani/Python_Learning_Practice_Notebooks/assets/77124662/a5dff226-5877-4e00-8a64-e12aeb9e4b60
42 |
43 | ## :bomb: Training_a_Digit_Recognition_Model_Using_Pytorch_Library_on_the_MNIST_Dataset :bomb:
44 | https://github.com/YasinRezvani/Python_Learning_Practice_Notebooks/assets/77124662/9520b1bf-1245-4d33-92b2-fcde703463bb
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------