├── .ipynb_checkpoints
└── Choropleth Maps (Plotly)-checkpoint.ipynb
├── BigData
├── .ipynb_checkpoints
│ └── Big Data Lecture-checkpoint.ipynb
└── Big Data Lecture.ipynb
├── Capstone Project 1
├── .ipynb_checkpoints
│ ├── 911 Calls Data Capstone Project -checkpoint.ipynb
│ └── Finance Project -checkpoint.ipynb
├── 911 Calls Data Capstone Project .ipynb
├── 911.csv
└── Finance Project .ipynb
├── Choropleth Maps (Plotly).ipynb
├── ML_KNN
├── .ipynb_checkpoints
│ ├── K Nearest Neighbors Project-checkpoint.ipynb
│ └── KNN Follow Lectures-checkpoint.ipynb
├── Classified Data
├── K Nearest Neighbors Project.ipynb
├── KNN Follow Lectures.ipynb
└── KNN_Project_Data
├── ML_Kmeans_Clustering
├── .ipynb_checkpoints
│ ├── K Means Clustering Project -checkpoint.ipynb
│ └── Kmeans Clustering Lectures-checkpoint.ipynb
├── College_Data
├── K Means Clustering Project .ipynb
└── Kmeans Clustering Lectures.ipynb
├── ML_Linear_Regression
├── .ipynb_checkpoints
│ ├── Linear Regression - Project Exercise -checkpoint.ipynb
│ └── Linear Regression with Python-checkpoint.ipynb
├── Ecommerce Customers
├── Linear Regression - Project Exercise .ipynb
├── Linear Regression Notes
├── Linear Regression with Python.ipynb
└── USA_Housing.csv
├── ML_Logistic_Regression
├── .ipynb_checkpoints
│ ├── Logistic Regression Lecture Notes-checkpoint.ipynb
│ └── Logistic Regression Project -checkpoint.ipynb
├── Logistic Regression Lecture Notes.ipynb
├── Logistic Regression Project - Solutions.ipynb
├── Logistic Regression Project .ipynb
├── Logistic Regression with Python.ipynb
├── advertising.csv
├── titanic_test.csv
└── titanic_train.csv
├── ML_PCA
├── .ipynb_checkpoints
│ └── PCA - Lecture Notes-checkpoint.ipynb
├── PCA - Lecture Notes.ipynb
└── PCA.png
├── ML_Recommender
├── .ipynb_checkpoints
│ └── Recommender System-checkpoint.ipynb
├── Movie_Id_Titles
├── Recommender System.ipynb
├── u.data
└── u.item
├── ML_SVM
├── .ipynb_checkpoints
│ ├── Lecture notes - SVM-checkpoint.ipynb
│ └── Support Vector Machines Project -checkpoint.ipynb
├── Lecture notes - SVM.ipynb
└── Support Vector Machines Project .ipynb
├── ML_TreeMethods
├── .ipynb_checkpoints
│ ├── Decision Trees and Random Forest Project -checkpoint.ipynb
│ └── Tree Methods Lecture Notes-checkpoint.ipynb
├── Decision Trees and Random Forest Project .ipynb
├── Tree Methods Lecture Notes.ipynb
├── kyphosis.csv
└── loan_data.csv
├── MatplotLIb
├── .ipynb_checkpoints
│ ├── MatplotLib-checkpoint.ipynb
│ └── Matplotlib Exercises -checkpoint.ipynb
├── MatplotLib.ipynb
├── Matplotlib Exercises .ipynb
└── my_first_fig_save.png
├── NLP
├── .ipynb_checkpoints
│ ├── NLP (Natural Language Processing) with Python-checkpoint.ipynb
│ ├── NLP Project -checkpoint.ipynb
│ └── NLP-checkpoint.ipynb
├── NLP (Natural Language Processing) with Python.ipynb
├── NLP Project .ipynb
├── NLP.ipynb
├── smsspamcollection
│ ├── SMSSpamCollection
│ └── readme
└── yelp.csv
├── Neural Networks
├── .ipynb_checkpoints
│ ├── Neural Network - TF Basics-checkpoint.ipynb
│ └── Tensorflow Project Exercise-checkpoint.ipynb
├── MNIST with Multi-Layer Perceptron.ipynb
├── Neural Network - TF Basics.ipynb
├── Tensorflow Basics.ipynb
├── Tensorflow Project Exercise.ipynb
├── Tensorflow with ContribLearn.ipynb
└── bank_note_data.csv
├── Numpy
├── .ipynb_checkpoints
│ ├── NumPy Notes-checkpoint.ipynb
│ └── Numpy Exercise -checkpoint.ipynb
├── NumPy Notes.ipynb
└── Numpy Exercise .ipynb
├── Pandas
├── .ipynb_checkpoints
│ └── Pandas-checkpoint.ipynb
├── Excel_Sample.xlsx
├── Output_Excel_Sample
├── Pandas Built-in Data Viz
│ ├── .ipynb_checkpoints
│ │ ├── Pandas Built-in Data Visualization-checkpoint.ipynb
│ │ ├── Pandas Data Visualization Exercise - Solutions-checkpoint.ipynb
│ │ └── Pandas Data Visualization Exercise -checkpoint.ipynb
│ ├── Pandas Built-in Data Visualization.ipynb
│ ├── Pandas Data Visualization Exercise .ipynb
│ ├── df1
│ ├── df2
│ └── df3
├── Pandas Exercises
│ ├── .ipynb_checkpoints
│ │ ├── Ecommerce Purchases Exercise -checkpoint.ipynb
│ │ └── SF Salaries Exercise-checkpoint.ipynb
│ ├── Ecommerce Purchases
│ ├── Ecommerce Purchases Exercise .ipynb
│ ├── SF Salaries Exercise.ipynb
│ └── Salaries.csv
└── Pandas.ipynb
└── Seaborn
├── .ipynb_checkpoints
├── Seaborn Exercises -checkpoint.ipynb
└── Seaborn Notes-checkpoint.ipynb
├── Seaborn Exercises .ipynb
└── Seaborn Notes.ipynb
/.ipynb_checkpoints/Choropleth Maps (Plotly)-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [],
10 | "source": [
11 | "import plotly.plotly as py"
12 | ]
13 | },
14 | {
15 | "cell_type": "code",
16 | "execution_count": 3,
17 | "metadata": {
18 | "collapsed": true
19 | },
20 | "outputs": [],
21 | "source": [
22 | "from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot"
23 | ]
24 | },
25 | {
26 | "cell_type": "code",
27 | "execution_count": 4,
28 | "metadata": {
29 | "collapsed": false
30 | },
31 | "outputs": [
32 | {
33 | "data": {
34 | "text/html": [
35 | ""
36 | ],
37 | "text/vnd.plotly.v1+html": [
38 | ""
39 | ]
40 | },
41 | "metadata": {},
42 | "output_type": "display_data"
43 | }
44 | ],
45 | "source": [
46 | "init_notebook_mode(connected=True)"
47 | ]
48 | },
49 | {
50 | "cell_type": "code",
51 | "execution_count": 5,
52 | "metadata": {
53 | "collapsed": true
54 | },
55 | "outputs": [],
56 | "source": [
57 | "# Previous line is so you can see in jupter"
58 | ]
59 | },
60 | {
61 | "cell_type": "code",
62 | "execution_count": 15,
63 | "metadata": {
64 | "collapsed": false
65 | },
66 | "outputs": [],
67 | "source": [
68 | "data = dict(type = 'choropleth',\n",
69 | " locations = ['AZ', 'CA','NY'],\n",
70 | " locationmode = 'USA-states',\n",
71 | " colorscale = 'Portland',\n",
72 | " text = ['Arizona','text 2','text 3'],\n",
73 | " z = [1.0, 2.0, 3.0],\n",
74 | " colorbar = {'title': 'Colorbar Title Goes Here'})\n",
75 | "\n",
76 | "#locaations are list of states\n",
77 | "#location mode is the country\n",
78 | "#text is same sedquence forthose countries\n",
79 | "#z is the VALUE of a color (ehnce color bar)"
80 | ]
81 | },
82 | {
83 | "cell_type": "code",
84 | "execution_count": 16,
85 | "metadata": {
86 | "collapsed": false
87 | },
88 | "outputs": [
89 | {
90 | "data": {
91 | "text/plain": [
92 | "{'colorbar': {'title': 'Colorbar Title Goes Here'},\n",
93 | " 'colorscale': 'Portland',\n",
94 | " 'locationmode': 'USA-states',\n",
95 | " 'locations': ['AZ', 'CA', 'NY'],\n",
96 | " 'text': ['Arizona', 'text 2', 'text 3'],\n",
97 | " 'type': 'choropleth',\n",
98 | " 'z': [1.0, 2.0, 3.0]}"
99 | ]
100 | },
101 | "execution_count": 16,
102 | "metadata": {},
103 | "output_type": "execute_result"
104 | }
105 | ],
106 | "source": [
107 | "data"
108 | ]
109 | },
110 | {
111 | "cell_type": "code",
112 | "execution_count": 17,
113 | "metadata": {
114 | "collapsed": true
115 | },
116 | "outputs": [],
117 | "source": [
118 | "layout = dict(geo = {'scope': 'usa'})"
119 | ]
120 | },
121 | {
122 | "cell_type": "code",
123 | "execution_count": 18,
124 | "metadata": {
125 | "collapsed": true
126 | },
127 | "outputs": [],
128 | "source": [
129 | "import plotly.graph_objs as go"
130 | ]
131 | },
132 | {
133 | "cell_type": "code",
134 | "execution_count": 19,
135 | "metadata": {
136 | "collapsed": false
137 | },
138 | "outputs": [],
139 | "source": [
140 | "choromap = go.Figure(data = [data],layout = layout)"
141 | ]
142 | },
143 | {
144 | "cell_type": "code",
145 | "execution_count": 20,
146 | "metadata": {
147 | "collapsed": false
148 | },
149 | "outputs": [
150 | {
151 | "data": {
152 | "application/vnd.plotly.v1+json": {
153 | "data": [
154 | {
155 | "colorbar": {
156 | "title": "Colorbar Title Goes Here"
157 | },
158 | "colorscale": "Portland",
159 | "locationmode": "USA-states",
160 | "locations": [
161 | "AZ",
162 | "CA",
163 | "NY"
164 | ],
165 | "text": [
166 | "Arizona",
167 | "text 2",
168 | "text 3"
169 | ],
170 | "type": "choropleth",
171 | "z": [
172 | 1,
173 | 2,
174 | 3
175 | ]
176 | }
177 | ],
178 | "layout": {
179 | "geo": {
180 | "scope": "usa"
181 | }
182 | }
183 | },
184 | "text/html": [
185 | "
"
186 | ],
187 | "text/vnd.plotly.v1+html": [
188 | ""
189 | ]
190 | },
191 | "metadata": {},
192 | "output_type": "display_data"
193 | }
194 | ],
195 | "source": [
196 | "iplot(choromap)"
197 | ]
198 | },
199 | {
200 | "cell_type": "code",
201 | "execution_count": null,
202 | "metadata": {
203 | "collapsed": true
204 | },
205 | "outputs": [],
206 | "source": []
207 | }
208 | ],
209 | "metadata": {
210 | "kernelspec": {
211 | "display_name": "Python 3",
212 | "language": "python",
213 | "name": "python3"
214 | },
215 | "language_info": {
216 | "codemirror_mode": {
217 | "name": "ipython",
218 | "version": 3
219 | },
220 | "file_extension": ".py",
221 | "mimetype": "text/x-python",
222 | "name": "python",
223 | "nbconvert_exporter": "python",
224 | "pygments_lexer": "ipython3",
225 | "version": "3.6.0"
226 | }
227 | },
228 | "nbformat": 4,
229 | "nbformat_minor": 2
230 | }
231 |
--------------------------------------------------------------------------------
/BigData/.ipynb_checkpoints/Big Data Lecture-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 2
6 | }
7 |
--------------------------------------------------------------------------------
/BigData/Big Data Lecture.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# Hadoop\n",
8 | "- Distrubute large files across MULTIPLE machines\n",
9 | "- SO there are smaller blocks which are split\n",
10 | "- SPARK is a way to handle big data.\n",
11 | "- SPARK RDDS: Collect, Count, First, Take "
12 | ]
13 | }
14 | ],
15 | "metadata": {
16 | "kernelspec": {
17 | "display_name": "Python 3",
18 | "language": "python",
19 | "name": "python3"
20 | },
21 | "language_info": {
22 | "codemirror_mode": {
23 | "name": "ipython",
24 | "version": 3
25 | },
26 | "file_extension": ".py",
27 | "mimetype": "text/x-python",
28 | "name": "python",
29 | "nbconvert_exporter": "python",
30 | "pygments_lexer": "ipython3",
31 | "version": "3.6.1"
32 | }
33 | },
34 | "nbformat": 4,
35 | "nbformat_minor": 2
36 | }
37 |
--------------------------------------------------------------------------------
/Choropleth Maps (Plotly).ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [],
10 | "source": [
11 | "import plotly.plotly as py"
12 | ]
13 | },
14 | {
15 | "cell_type": "code",
16 | "execution_count": 3,
17 | "metadata": {
18 | "collapsed": true
19 | },
20 | "outputs": [],
21 | "source": [
22 | "from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot"
23 | ]
24 | },
25 | {
26 | "cell_type": "code",
27 | "execution_count": 4,
28 | "metadata": {
29 | "collapsed": false
30 | },
31 | "outputs": [
32 | {
33 | "data": {
34 | "text/html": [
35 | ""
36 | ],
37 | "text/vnd.plotly.v1+html": [
38 | ""
39 | ]
40 | },
41 | "metadata": {},
42 | "output_type": "display_data"
43 | }
44 | ],
45 | "source": [
46 | "init_notebook_mode(connected=True)"
47 | ]
48 | },
49 | {
50 | "cell_type": "code",
51 | "execution_count": 5,
52 | "metadata": {
53 | "collapsed": true
54 | },
55 | "outputs": [],
56 | "source": [
57 | "# Previous line is so you can see in jupter"
58 | ]
59 | },
60 | {
61 | "cell_type": "code",
62 | "execution_count": 15,
63 | "metadata": {
64 | "collapsed": false
65 | },
66 | "outputs": [],
67 | "source": [
68 | "data = dict(type = 'choropleth',\n",
69 | " locations = ['AZ', 'CA','NY'],\n",
70 | " locationmode = 'USA-states',\n",
71 | " colorscale = 'Portland',\n",
72 | " text = ['Arizona','text 2','text 3'],\n",
73 | " z = [1.0, 2.0, 3.0],\n",
74 | " colorbar = {'title': 'Colorbar Title Goes Here'})\n",
75 | "\n",
76 | "#locaations are list of states\n",
77 | "#location mode is the country\n",
78 | "#text is same sedquence forthose countries\n",
79 | "#z is the VALUE of a color (ehnce color bar)"
80 | ]
81 | },
82 | {
83 | "cell_type": "code",
84 | "execution_count": 16,
85 | "metadata": {
86 | "collapsed": false
87 | },
88 | "outputs": [
89 | {
90 | "data": {
91 | "text/plain": [
92 | "{'colorbar': {'title': 'Colorbar Title Goes Here'},\n",
93 | " 'colorscale': 'Portland',\n",
94 | " 'locationmode': 'USA-states',\n",
95 | " 'locations': ['AZ', 'CA', 'NY'],\n",
96 | " 'text': ['Arizona', 'text 2', 'text 3'],\n",
97 | " 'type': 'choropleth',\n",
98 | " 'z': [1.0, 2.0, 3.0]}"
99 | ]
100 | },
101 | "execution_count": 16,
102 | "metadata": {},
103 | "output_type": "execute_result"
104 | }
105 | ],
106 | "source": [
107 | "data"
108 | ]
109 | },
110 | {
111 | "cell_type": "code",
112 | "execution_count": 17,
113 | "metadata": {
114 | "collapsed": true
115 | },
116 | "outputs": [],
117 | "source": [
118 | "layout = dict(geo = {'scope': 'usa'})"
119 | ]
120 | },
121 | {
122 | "cell_type": "code",
123 | "execution_count": 18,
124 | "metadata": {
125 | "collapsed": true
126 | },
127 | "outputs": [],
128 | "source": [
129 | "import plotly.graph_objs as go"
130 | ]
131 | },
132 | {
133 | "cell_type": "code",
134 | "execution_count": 19,
135 | "metadata": {
136 | "collapsed": false
137 | },
138 | "outputs": [],
139 | "source": [
140 | "choromap = go.Figure(data = [data],layout = layout)"
141 | ]
142 | },
143 | {
144 | "cell_type": "code",
145 | "execution_count": 20,
146 | "metadata": {
147 | "collapsed": false
148 | },
149 | "outputs": [
150 | {
151 | "data": {
152 | "application/vnd.plotly.v1+json": {
153 | "data": [
154 | {
155 | "colorbar": {
156 | "title": "Colorbar Title Goes Here"
157 | },
158 | "colorscale": "Portland",
159 | "locationmode": "USA-states",
160 | "locations": [
161 | "AZ",
162 | "CA",
163 | "NY"
164 | ],
165 | "text": [
166 | "Arizona",
167 | "text 2",
168 | "text 3"
169 | ],
170 | "type": "choropleth",
171 | "z": [
172 | 1,
173 | 2,
174 | 3
175 | ]
176 | }
177 | ],
178 | "layout": {
179 | "geo": {
180 | "scope": "usa"
181 | }
182 | }
183 | },
184 | "text/html": [
185 | ""
186 | ],
187 | "text/vnd.plotly.v1+html": [
188 | ""
189 | ]
190 | },
191 | "metadata": {},
192 | "output_type": "display_data"
193 | }
194 | ],
195 | "source": [
196 | "iplot(choromap)"
197 | ]
198 | },
199 | {
200 | "cell_type": "code",
201 | "execution_count": null,
202 | "metadata": {
203 | "collapsed": true
204 | },
205 | "outputs": [],
206 | "source": []
207 | }
208 | ],
209 | "metadata": {
210 | "kernelspec": {
211 | "display_name": "Python 3",
212 | "language": "python",
213 | "name": "python3"
214 | },
215 | "language_info": {
216 | "codemirror_mode": {
217 | "name": "ipython",
218 | "version": 3
219 | },
220 | "file_extension": ".py",
221 | "mimetype": "text/x-python",
222 | "name": "python",
223 | "nbconvert_exporter": "python",
224 | "pygments_lexer": "ipython3",
225 | "version": "3.6.0"
226 | }
227 | },
228 | "nbformat": 4,
229 | "nbformat_minor": 2
230 | }
231 |
--------------------------------------------------------------------------------
/ML_KNN/.ipynb_checkpoints/KNN Follow Lectures-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 2
6 | }
7 |
--------------------------------------------------------------------------------
/ML_Kmeans_Clustering/.ipynb_checkpoints/Kmeans Clustering Lectures-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 2
6 | }
7 |
--------------------------------------------------------------------------------
/ML_Kmeans_Clustering/Kmeans Clustering Lectures.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# Chapter 10 - ISL\n",
8 | "\n",
9 | "- Basically attmpets to clutser the data, choosing a number of clusters \"K\"\n",
10 | "- randomly assign point to a cluster \n",
11 | "\n",
12 | "1. Each cluster takes a mean vector of oints in cluster\n",
13 | "2. asign each data point to which the point is closet to\n",
14 | "\n",
15 | "## UNSUPERVISED!"
16 | ]
17 | },
18 | {
19 | "cell_type": "code",
20 | "execution_count": 1,
21 | "metadata": {
22 | "collapsed": true
23 | },
24 | "outputs": [],
25 | "source": [
26 | "import seaborn as sns\n",
27 | "import matplotlib.pyplot as plt\n",
28 | "%matplotlib inline"
29 | ]
30 | },
31 | {
32 | "cell_type": "code",
33 | "execution_count": 3,
34 | "metadata": {
35 | "collapsed": true
36 | },
37 | "outputs": [],
38 | "source": [
39 | "# GENERATE Artificial DATA"
40 | ]
41 | },
42 | {
43 | "cell_type": "code",
44 | "execution_count": 4,
45 | "metadata": {
46 | "collapsed": true
47 | },
48 | "outputs": [],
49 | "source": [
50 | "from sklearn.datasets import make_blobs"
51 | ]
52 | },
53 | {
54 | "cell_type": "code",
55 | "execution_count": 7,
56 | "metadata": {},
57 | "outputs": [],
58 | "source": [
59 | "data =make_blobs(n_samples=200, n_features=2,centers=4, cluster_std = 1.8,\n",
60 | " random_state=101)"
61 | ]
62 | },
63 | {
64 | "cell_type": "code",
65 | "execution_count": 8,
66 | "metadata": {},
67 | "outputs": [
68 | {
69 | "data": {
70 | "text/plain": [
71 | ""
72 | ]
73 | },
74 | "execution_count": 8,
75 | "metadata": {},
76 | "output_type": "execute_result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8APGNzt+ziKwB+BsCHQvTLGzb3p5b8HYAXGGOfQMFi/7y93akpvwLwEGPsNQAeAPM14uNZAM8z\nxo4DyAPYO09XLLJQ6l2CIIg6wvHuF4IgCEI9JOoEQRB1BIk6QRBEHUGiThAEUUeQqBMEQdQRJOoE\nQRB1BIk6QRBEHfH/AUCp+4FsubOPAAAAAElFTkSuQmCC\n",
81 | "text/plain": [
82 | ""
83 | ]
84 | },
85 | "metadata": {},
86 | "output_type": "display_data"
87 | }
88 | ],
89 | "source": [
90 | "plt.scatter(data[0][:,0],data[0][:,1])"
91 | ]
92 | },
93 | {
94 | "cell_type": "code",
95 | "execution_count": 10,
96 | "metadata": {},
97 | "outputs": [],
98 | "source": [
99 | "from sklearn.cluster import KMeans"
100 | ]
101 | },
102 | {
103 | "cell_type": "code",
104 | "execution_count": 12,
105 | "metadata": {
106 | "collapsed": true
107 | },
108 | "outputs": [],
109 | "source": [
110 | "# UNSUPERVISED\n",
111 | "\n",
112 | "kmeans = KMeans(n_clusters=4)"
113 | ]
114 | },
115 | {
116 | "cell_type": "code",
117 | "execution_count": 13,
118 | "metadata": {},
119 | "outputs": [
120 | {
121 | "data": {
122 | "text/plain": [
123 | "KMeans(algorithm='auto', copy_x=True, init='k-means++', max_iter=300,\n",
124 | " n_clusters=4, n_init=10, n_jobs=1, precompute_distances='auto',\n",
125 | " random_state=None, tol=0.0001, verbose=0)"
126 | ]
127 | },
128 | "execution_count": 13,
129 | "metadata": {},
130 | "output_type": "execute_result"
131 | }
132 | ],
133 | "source": [
134 | "kmeans.fit(data[0])"
135 | ]
136 | },
137 | {
138 | "cell_type": "code",
139 | "execution_count": 22,
140 | "metadata": {},
141 | "outputs": [
142 | {
143 | "data": {
144 | "text/plain": [
145 | "array([[-0.0123077 , 2.13407664],\n",
146 | " [-9.46941837, -6.56081545],\n",
147 | " [ 3.71749226, 7.01388735],\n",
148 | " [-4.13591321, 7.95389851]])"
149 | ]
150 | },
151 | "execution_count": 22,
152 | "metadata": {},
153 | "output_type": "execute_result"
154 | }
155 | ],
156 | "source": [
157 | "kmeans.cluster_centers_"
158 | ]
159 | },
160 | {
161 | "cell_type": "code",
162 | "execution_count": null,
163 | "metadata": {},
164 | "outputs": [],
165 | "source": []
166 | },
167 | {
168 | "cell_type": "code",
169 | "execution_count": null,
170 | "metadata": {
171 | "collapsed": true
172 | },
173 | "outputs": [],
174 | "source": []
175 | }
176 | ],
177 | "metadata": {
178 | "kernelspec": {
179 | "display_name": "Python 3",
180 | "language": "python",
181 | "name": "python3"
182 | },
183 | "language_info": {
184 | "codemirror_mode": {
185 | "name": "ipython",
186 | "version": 3
187 | },
188 | "file_extension": ".py",
189 | "mimetype": "text/x-python",
190 | "name": "python",
191 | "nbconvert_exporter": "python",
192 | "pygments_lexer": "ipython3",
193 | "version": "3.6.1"
194 | }
195 | },
196 | "nbformat": 4,
197 | "nbformat_minor": 2
198 | }
199 |
--------------------------------------------------------------------------------
/ML_Linear_Regression/Linear Regression Notes:
--------------------------------------------------------------------------------
1 | from sklearn.family import Model(IN THIS CASE:)
2 | from sklearn.linear_model import LinearRegression
3 |
4 |
5 | # Linear Regression
6 |
7 | easy in that it assumes there is a linear relationship with Y + b + b1*X
8 | The best way to fit the required line to the data - is to find the line that has the least RSS (the residual distances between your prediction with ACTUAL points). Commonly known as the Least Squares Approach.
9 |
10 | Confidence Intervals
11 | - A 95% Confidence interval is a range of values such that 95% probability the range will continue true for UNKNOWN values of the parameter .
12 |
13 | Null Hypothesis
14 | As this is good for testing relationships between X and Y
15 | H0 - There is no relationship between X and Y
16 | >>> Alternative hypothesis: There is some relationship between X and Y
17 | So to do this, we need to use the a t-stat because we need to know HOW far it will differentiate between both.
18 | => t B1 -0 / SE(b1)
19 | - Measures the amount of standard deviations that b1 is away from 0
20 | The t statistic is a measure of how extreme a statistical estimate is. You compute this statistic by subtracting the hypothesized value from the statistical estimate and then dividing by the estimated standard error. In many, but not all situation, the hypothesized value would be zero.
21 |
22 |
23 | >>> P Value is the probability of observation any value assuming B1 = 0
24 | - Meaning a SMALL p-value, means a good relationship
25 | - typical cut offs of p-value are 5 or 1%
26 |
27 | *** SELF NOTE: B1 is the coefficient next to X. Given the formulation of Y = B1*x + B, if B1 = 0, then there would be literally no relationship between Y to X. Consequently, this is a null hypothesis. Also, given that B1 = 0, the p-value will be based on B1 = 0, meaning if this his high, there is no relationship given to Y and X. The T-state with all this in regards, is how far B1 AWAY from 0. So a really high t-stat means (relative to SD) - is not good.
28 |
29 | ASSESSING ACCURACY
30 | Residual Standard Error (RSE)
31 | Remember you can’t perfect predict things
32 | RSE = sqrt(RSS*1/(n-2))
33 | RSE is the LACK of fit of a model.
34 |
35 | R-squared
36 | Measure of lack of fit of model.
37 | - R-squared is a proportion
38 | R^2 - 1-(RSS/TSS)
39 |
40 | Regression with Classifiers
41 | Essentially if you have only two levels - you could make xi = 1 for female, xi = 0 for male
42 | - you effectively create dummy variables with value
43 |
44 | Problems
45 | 1. With regards to some items having a possible INTERACTION (in marketing this is known as SYNERGISM) - you can make some of the factors combined together. For example, X1 and X2 - in the formulation Y = aX1 + bX2 + cX1X2. Remembering that this is still a LINEAR model, but the variables so happy to represent the variables multiplied.
46 | 2. This is is the same with doubling up, doing X1X1 itself, as is simply REPRESENTS the square of the number
--------------------------------------------------------------------------------
/ML_PCA/.ipynb_checkpoints/PCA - Lecture Notes-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 2
6 | }
7 |
--------------------------------------------------------------------------------
/ML_PCA/PCA - Lecture Notes.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# PCA\n",
8 | "\n",
9 | "Unsupervised learning\n",
10 | "- Factor analysis determines several lines of best fit to a data\n",
11 | "- So you have a regression line of best fit. \n",
12 | "- Components are linear - choose a variable for the data set such that the greatest variance of the data set lie on the first axis\n",
13 | "\n",
14 | "FIRST PCA\n"
15 | ]
16 | },
17 | {
18 | "cell_type": "code",
19 | "execution_count": 3,
20 | "metadata": {},
21 | "outputs": [],
22 | "source": [
23 | "import matplotlib.pyplot as plt\n",
24 | "import pandas as pd\n",
25 | "import numpy as np\n",
26 | "import seaborn as sns\n",
27 | "%matplotlib inline"
28 | ]
29 | },
30 | {
31 | "cell_type": "code",
32 | "execution_count": 9,
33 | "metadata": {
34 | "collapsed": true
35 | },
36 | "outputs": [],
37 | "source": [
38 | "from sklearn.datasets import load_breast_cancer\n",
39 | "cancer = load_breast_cancer()"
40 | ]
41 | },
42 | {
43 | "cell_type": "code",
44 | "execution_count": 11,
45 | "metadata": {},
46 | "outputs": [
47 | {
48 | "name": "stdout",
49 | "output_type": "stream",
50 | "text": [
51 | "Breast Cancer Wisconsin (Diagnostic) Database\n",
52 | "=============================================\n",
53 | "\n",
54 | "Notes\n",
55 | "-----\n",
56 | "Data Set Characteristics:\n",
57 | " :Number of Instances: 569\n",
58 | "\n",
59 | " :Number of Attributes: 30 numeric, predictive attributes and the class\n",
60 | "\n",
61 | " :Attribute Information:\n",
62 | " - radius (mean of distances from center to points on the perimeter)\n",
63 | " - texture (standard deviation of gray-scale values)\n",
64 | " - perimeter\n",
65 | " - area\n",
66 | " - smoothness (local variation in radius lengths)\n",
67 | " - compactness (perimeter^2 / area - 1.0)\n",
68 | " - concavity (severity of concave portions of the contour)\n",
69 | " - concave points (number of concave portions of the contour)\n",
70 | " - symmetry \n",
71 | " - fractal dimension (\"coastline approximation\" - 1)\n",
72 | "\n",
73 | " The mean, standard error, and \"worst\" or largest (mean of the three\n",
74 | " largest values) of these features were computed for each image,\n",
75 | " resulting in 30 features. For instance, field 3 is Mean Radius, field\n",
76 | " 13 is Radius SE, field 23 is Worst Radius.\n",
77 | "\n",
78 | " - class:\n",
79 | " - WDBC-Malignant\n",
80 | " - WDBC-Benign\n",
81 | "\n",
82 | " :Summary Statistics:\n",
83 | "\n",
84 | " ===================================== ====== ======\n",
85 | " Min Max\n",
86 | " ===================================== ====== ======\n",
87 | " radius (mean): 6.981 28.11\n",
88 | " texture (mean): 9.71 39.28\n",
89 | " perimeter (mean): 43.79 188.5\n",
90 | " area (mean): 143.5 2501.0\n",
91 | " smoothness (mean): 0.053 0.163\n",
92 | " compactness (mean): 0.019 0.345\n",
93 | " concavity (mean): 0.0 0.427\n",
94 | " concave points (mean): 0.0 0.201\n",
95 | " symmetry (mean): 0.106 0.304\n",
96 | " fractal dimension (mean): 0.05 0.097\n",
97 | " radius (standard error): 0.112 2.873\n",
98 | " texture (standard error): 0.36 4.885\n",
99 | " perimeter (standard error): 0.757 21.98\n",
100 | " area (standard error): 6.802 542.2\n",
101 | " smoothness (standard error): 0.002 0.031\n",
102 | " compactness (standard error): 0.002 0.135\n",
103 | " concavity (standard error): 0.0 0.396\n",
104 | " concave points (standard error): 0.0 0.053\n",
105 | " symmetry (standard error): 0.008 0.079\n",
106 | " fractal dimension (standard error): 0.001 0.03\n",
107 | " radius (worst): 7.93 36.04\n",
108 | " texture (worst): 12.02 49.54\n",
109 | " perimeter (worst): 50.41 251.2\n",
110 | " area (worst): 185.2 4254.0\n",
111 | " smoothness (worst): 0.071 0.223\n",
112 | " compactness (worst): 0.027 1.058\n",
113 | " concavity (worst): 0.0 1.252\n",
114 | " concave points (worst): 0.0 0.291\n",
115 | " symmetry (worst): 0.156 0.664\n",
116 | " fractal dimension (worst): 0.055 0.208\n",
117 | " ===================================== ====== ======\n",
118 | "\n",
119 | " :Missing Attribute Values: None\n",
120 | "\n",
121 | " :Class Distribution: 212 - Malignant, 357 - Benign\n",
122 | "\n",
123 | " :Creator: Dr. William H. Wolberg, W. Nick Street, Olvi L. Mangasarian\n",
124 | "\n",
125 | " :Donor: Nick Street\n",
126 | "\n",
127 | " :Date: November, 1995\n",
128 | "\n",
129 | "This is a copy of UCI ML Breast Cancer Wisconsin (Diagnostic) datasets.\n",
130 | "https://goo.gl/U2Uwz2\n",
131 | "\n",
132 | "Features are computed from a digitized image of a fine needle\n",
133 | "aspirate (FNA) of a breast mass. They describe\n",
134 | "characteristics of the cell nuclei present in the image.\n",
135 | "\n",
136 | "Separating plane described above was obtained using\n",
137 | "Multisurface Method-Tree (MSM-T) [K. P. Bennett, \"Decision Tree\n",
138 | "Construction Via Linear Programming.\" Proceedings of the 4th\n",
139 | "Midwest Artificial Intelligence and Cognitive Science Society,\n",
140 | "pp. 97-101, 1992], a classification method which uses linear\n",
141 | "programming to construct a decision tree. Relevant features\n",
142 | "were selected using an exhaustive search in the space of 1-4\n",
143 | "features and 1-3 separating planes.\n",
144 | "\n",
145 | "The actual linear program used to obtain the separating plane\n",
146 | "in the 3-dimensional space is that described in:\n",
147 | "[K. P. Bennett and O. L. Mangasarian: \"Robust Linear\n",
148 | "Programming Discrimination of Two Linearly Inseparable Sets\",\n",
149 | "Optimization Methods and Software 1, 1992, 23-34].\n",
150 | "\n",
151 | "This database is also available through the UW CS ftp server:\n",
152 | "\n",
153 | "ftp ftp.cs.wisc.edu\n",
154 | "cd math-prog/cpo-dataset/machine-learn/WDBC/\n",
155 | "\n",
156 | "References\n",
157 | "----------\n",
158 | " - W.N. Street, W.H. Wolberg and O.L. Mangasarian. Nuclear feature extraction \n",
159 | " for breast tumor diagnosis. IS&T/SPIE 1993 International Symposium on \n",
160 | " Electronic Imaging: Science and Technology, volume 1905, pages 861-870,\n",
161 | " San Jose, CA, 1993.\n",
162 | " - O.L. Mangasarian, W.N. Street and W.H. Wolberg. Breast cancer diagnosis and \n",
163 | " prognosis via linear programming. Operations Research, 43(4), pages 570-577, \n",
164 | " July-August 1995.\n",
165 | " - W.H. Wolberg, W.N. Street, and O.L. Mangasarian. Machine learning techniques\n",
166 | " to diagnose breast cancer from fine-needle aspirates. Cancer Letters 77 (1994) \n",
167 | " 163-171.\n",
168 | "\n"
169 | ]
170 | }
171 | ],
172 | "source": [
173 | "print(cancer['DESCR'])"
174 | ]
175 | },
176 | {
177 | "cell_type": "code",
178 | "execution_count": 7,
179 | "metadata": {
180 | "collapsed": true
181 | },
182 | "outputs": [],
183 | "source": [
184 | "df = pd.DataFrame(cancer['data'], columns=cancer['feature_names'])"
185 | ]
186 | },
187 | {
188 | "cell_type": "code",
189 | "execution_count": 8,
190 | "metadata": {},
191 | "outputs": [
192 | {
193 | "data": {
194 | "text/html": [
195 | "\n",
196 | "\n",
209 | "
\n",
210 | " \n",
211 | " \n",
212 | " | \n",
213 | " mean radius | \n",
214 | " mean texture | \n",
215 | " mean perimeter | \n",
216 | " mean area | \n",
217 | " mean smoothness | \n",
218 | " mean compactness | \n",
219 | " mean concavity | \n",
220 | " mean concave points | \n",
221 | " mean symmetry | \n",
222 | " mean fractal dimension | \n",
223 | " ... | \n",
224 | " worst radius | \n",
225 | " worst texture | \n",
226 | " worst perimeter | \n",
227 | " worst area | \n",
228 | " worst smoothness | \n",
229 | " worst compactness | \n",
230 | " worst concavity | \n",
231 | " worst concave points | \n",
232 | " worst symmetry | \n",
233 | " worst fractal dimension | \n",
234 | "
\n",
235 | " \n",
236 | " \n",
237 | " \n",
238 | " 0 | \n",
239 | " 17.99 | \n",
240 | " 10.38 | \n",
241 | " 122.80 | \n",
242 | " 1001.0 | \n",
243 | " 0.11840 | \n",
244 | " 0.27760 | \n",
245 | " 0.3001 | \n",
246 | " 0.14710 | \n",
247 | " 0.2419 | \n",
248 | " 0.07871 | \n",
249 | " ... | \n",
250 | " 25.38 | \n",
251 | " 17.33 | \n",
252 | " 184.60 | \n",
253 | " 2019.0 | \n",
254 | " 0.1622 | \n",
255 | " 0.6656 | \n",
256 | " 0.7119 | \n",
257 | " 0.2654 | \n",
258 | " 0.4601 | \n",
259 | " 0.11890 | \n",
260 | "
\n",
261 | " \n",
262 | " 1 | \n",
263 | " 20.57 | \n",
264 | " 17.77 | \n",
265 | " 132.90 | \n",
266 | " 1326.0 | \n",
267 | " 0.08474 | \n",
268 | " 0.07864 | \n",
269 | " 0.0869 | \n",
270 | " 0.07017 | \n",
271 | " 0.1812 | \n",
272 | " 0.05667 | \n",
273 | " ... | \n",
274 | " 24.99 | \n",
275 | " 23.41 | \n",
276 | " 158.80 | \n",
277 | " 1956.0 | \n",
278 | " 0.1238 | \n",
279 | " 0.1866 | \n",
280 | " 0.2416 | \n",
281 | " 0.1860 | \n",
282 | " 0.2750 | \n",
283 | " 0.08902 | \n",
284 | "
\n",
285 | " \n",
286 | " 2 | \n",
287 | " 19.69 | \n",
288 | " 21.25 | \n",
289 | " 130.00 | \n",
290 | " 1203.0 | \n",
291 | " 0.10960 | \n",
292 | " 0.15990 | \n",
293 | " 0.1974 | \n",
294 | " 0.12790 | \n",
295 | " 0.2069 | \n",
296 | " 0.05999 | \n",
297 | " ... | \n",
298 | " 23.57 | \n",
299 | " 25.53 | \n",
300 | " 152.50 | \n",
301 | " 1709.0 | \n",
302 | " 0.1444 | \n",
303 | " 0.4245 | \n",
304 | " 0.4504 | \n",
305 | " 0.2430 | \n",
306 | " 0.3613 | \n",
307 | " 0.08758 | \n",
308 | "
\n",
309 | " \n",
310 | " 3 | \n",
311 | " 11.42 | \n",
312 | " 20.38 | \n",
313 | " 77.58 | \n",
314 | " 386.1 | \n",
315 | " 0.14250 | \n",
316 | " 0.28390 | \n",
317 | " 0.2414 | \n",
318 | " 0.10520 | \n",
319 | " 0.2597 | \n",
320 | " 0.09744 | \n",
321 | " ... | \n",
322 | " 14.91 | \n",
323 | " 26.50 | \n",
324 | " 98.87 | \n",
325 | " 567.7 | \n",
326 | " 0.2098 | \n",
327 | " 0.8663 | \n",
328 | " 0.6869 | \n",
329 | " 0.2575 | \n",
330 | " 0.6638 | \n",
331 | " 0.17300 | \n",
332 | "
\n",
333 | " \n",
334 | " 4 | \n",
335 | " 20.29 | \n",
336 | " 14.34 | \n",
337 | " 135.10 | \n",
338 | " 1297.0 | \n",
339 | " 0.10030 | \n",
340 | " 0.13280 | \n",
341 | " 0.1980 | \n",
342 | " 0.10430 | \n",
343 | " 0.1809 | \n",
344 | " 0.05883 | \n",
345 | " ... | \n",
346 | " 22.54 | \n",
347 | " 16.67 | \n",
348 | " 152.20 | \n",
349 | " 1575.0 | \n",
350 | " 0.1374 | \n",
351 | " 0.2050 | \n",
352 | " 0.4000 | \n",
353 | " 0.1625 | \n",
354 | " 0.2364 | \n",
355 | " 0.07678 | \n",
356 | "
\n",
357 | " \n",
358 | "
\n",
359 | "
5 rows × 30 columns
\n",
360 | "
"
361 | ],
362 | "text/plain": [
363 | " mean radius mean texture mean perimeter mean area mean smoothness \\\n",
364 | "0 17.99 10.38 122.80 1001.0 0.11840 \n",
365 | "1 20.57 17.77 132.90 1326.0 0.08474 \n",
366 | "2 19.69 21.25 130.00 1203.0 0.10960 \n",
367 | "3 11.42 20.38 77.58 386.1 0.14250 \n",
368 | "4 20.29 14.34 135.10 1297.0 0.10030 \n",
369 | "\n",
370 | " mean compactness mean concavity mean concave points mean symmetry \\\n",
371 | "0 0.27760 0.3001 0.14710 0.2419 \n",
372 | "1 0.07864 0.0869 0.07017 0.1812 \n",
373 | "2 0.15990 0.1974 0.12790 0.2069 \n",
374 | "3 0.28390 0.2414 0.10520 0.2597 \n",
375 | "4 0.13280 0.1980 0.10430 0.1809 \n",
376 | "\n",
377 | " mean fractal dimension ... worst radius \\\n",
378 | "0 0.07871 ... 25.38 \n",
379 | "1 0.05667 ... 24.99 \n",
380 | "2 0.05999 ... 23.57 \n",
381 | "3 0.09744 ... 14.91 \n",
382 | "4 0.05883 ... 22.54 \n",
383 | "\n",
384 | " worst texture worst perimeter worst area worst smoothness \\\n",
385 | "0 17.33 184.60 2019.0 0.1622 \n",
386 | "1 23.41 158.80 1956.0 0.1238 \n",
387 | "2 25.53 152.50 1709.0 0.1444 \n",
388 | "3 26.50 98.87 567.7 0.2098 \n",
389 | "4 16.67 152.20 1575.0 0.1374 \n",
390 | "\n",
391 | " worst compactness worst concavity worst concave points worst symmetry \\\n",
392 | "0 0.6656 0.7119 0.2654 0.4601 \n",
393 | "1 0.1866 0.2416 0.1860 0.2750 \n",
394 | "2 0.4245 0.4504 0.2430 0.3613 \n",
395 | "3 0.8663 0.6869 0.2575 0.6638 \n",
396 | "4 0.2050 0.4000 0.1625 0.2364 \n",
397 | "\n",
398 | " worst fractal dimension \n",
399 | "0 0.11890 \n",
400 | "1 0.08902 \n",
401 | "2 0.08758 \n",
402 | "3 0.17300 \n",
403 | "4 0.07678 \n",
404 | "\n",
405 | "[5 rows x 30 columns]"
406 | ]
407 | },
408 | "execution_count": 8,
409 | "metadata": {},
410 | "output_type": "execute_result"
411 | }
412 | ],
413 | "source": [
414 | "df.head()"
415 | ]
416 | },
417 | {
418 | "cell_type": "code",
419 | "execution_count": 12,
420 | "metadata": {
421 | "collapsed": true
422 | },
423 | "outputs": [],
424 | "source": [
425 | "from sklearn.preprocessing import StandardScaler"
426 | ]
427 | },
428 | {
429 | "cell_type": "code",
430 | "execution_count": 13,
431 | "metadata": {
432 | "collapsed": true
433 | },
434 | "outputs": [],
435 | "source": [
436 | "scaler = StandardScaler()"
437 | ]
438 | },
439 | {
440 | "cell_type": "code",
441 | "execution_count": 14,
442 | "metadata": {},
443 | "outputs": [
444 | {
445 | "data": {
446 | "text/plain": [
447 | "StandardScaler(copy=True, with_mean=True, with_std=True)"
448 | ]
449 | },
450 | "execution_count": 14,
451 | "metadata": {},
452 | "output_type": "execute_result"
453 | }
454 | ],
455 | "source": [
456 | "scaler.fit(df)"
457 | ]
458 | },
459 | {
460 | "cell_type": "code",
461 | "execution_count": 15,
462 | "metadata": {
463 | "collapsed": true
464 | },
465 | "outputs": [],
466 | "source": [
467 | "scaled_data = scaler.transform(df)"
468 | ]
469 | },
470 | {
471 | "cell_type": "code",
472 | "execution_count": 16,
473 | "metadata": {
474 | "collapsed": true
475 | },
476 | "outputs": [],
477 | "source": [
478 | "from sklearn.decomposition import PCA"
479 | ]
480 | },
481 | {
482 | "cell_type": "code",
483 | "execution_count": 18,
484 | "metadata": {
485 | "collapsed": true
486 | },
487 | "outputs": [],
488 | "source": [
489 | "pca = PCA(n_components=2)"
490 | ]
491 | },
492 | {
493 | "cell_type": "code",
494 | "execution_count": 19,
495 | "metadata": {},
496 | "outputs": [
497 | {
498 | "data": {
499 | "text/plain": [
500 | "PCA(copy=True, iterated_power='auto', n_components=2, random_state=None,\n",
501 | " svd_solver='auto', tol=0.0, whiten=False)"
502 | ]
503 | },
504 | "execution_count": 19,
505 | "metadata": {},
506 | "output_type": "execute_result"
507 | }
508 | ],
509 | "source": [
510 | "pca.fit(scaled_data)"
511 | ]
512 | },
513 | {
514 | "cell_type": "code",
515 | "execution_count": 20,
516 | "metadata": {
517 | "collapsed": true
518 | },
519 | "outputs": [],
520 | "source": [
521 | "x_pca = pca.transform(scaled_data)"
522 | ]
523 | },
524 | {
525 | "cell_type": "code",
526 | "execution_count": null,
527 | "metadata": {
528 | "collapsed": true
529 | },
530 | "outputs": [],
531 | "source": []
532 | }
533 | ],
534 | "metadata": {
535 | "kernelspec": {
536 | "display_name": "Python 3",
537 | "language": "python",
538 | "name": "python3"
539 | },
540 | "language_info": {
541 | "codemirror_mode": {
542 | "name": "ipython",
543 | "version": 3
544 | },
545 | "file_extension": ".py",
546 | "mimetype": "text/x-python",
547 | "name": "python",
548 | "nbconvert_exporter": "python",
549 | "pygments_lexer": "ipython3",
550 | "version": "3.6.1"
551 | }
552 | },
553 | "nbformat": 4,
554 | "nbformat_minor": 2
555 | }
556 |
--------------------------------------------------------------------------------
/ML_PCA/PCA.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pasteurtran/Udemy_Python_for_Data_Science/88988a2173bd8b68533109fc9543ca6b5332c67e/ML_PCA/PCA.png
--------------------------------------------------------------------------------
/ML_Recommender/.ipynb_checkpoints/Recommender System-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 2
6 | }
7 |
--------------------------------------------------------------------------------
/ML_Recommender/Recommender System.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": true
8 | },
9 | "outputs": [],
10 | "source": [
11 | "import numpy as np\n",
12 | "import pandas as pd"
13 | ]
14 | },
15 | {
16 | "cell_type": "code",
17 | "execution_count": 2,
18 | "metadata": {
19 | "collapsed": true
20 | },
21 | "outputs": [],
22 | "source": [
23 | "columns_names= ['user_id', 'item_id', 'rating','timestamp'] "
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 4,
29 | "metadata": {},
30 | "outputs": [],
31 | "source": [
32 | "df = pd.read_csv(\"u.data\", sep='\\t', names = columns_names)"
33 | ]
34 | },
35 | {
36 | "cell_type": "code",
37 | "execution_count": 5,
38 | "metadata": {},
39 | "outputs": [
40 | {
41 | "data": {
42 | "text/html": [
43 | "\n",
44 | "\n",
57 | "
\n",
58 | " \n",
59 | " \n",
60 | " | \n",
61 | " user_id | \n",
62 | " item_id | \n",
63 | " rating | \n",
64 | " timestamp | \n",
65 | "
\n",
66 | " \n",
67 | " \n",
68 | " \n",
69 | " 0 | \n",
70 | " 0 | \n",
71 | " 50 | \n",
72 | " 5 | \n",
73 | " 881250949 | \n",
74 | "
\n",
75 | " \n",
76 | " 1 | \n",
77 | " 0 | \n",
78 | " 172 | \n",
79 | " 5 | \n",
80 | " 881250949 | \n",
81 | "
\n",
82 | " \n",
83 | " 2 | \n",
84 | " 0 | \n",
85 | " 133 | \n",
86 | " 1 | \n",
87 | " 881250949 | \n",
88 | "
\n",
89 | " \n",
90 | " 3 | \n",
91 | " 196 | \n",
92 | " 242 | \n",
93 | " 3 | \n",
94 | " 881250949 | \n",
95 | "
\n",
96 | " \n",
97 | " 4 | \n",
98 | " 186 | \n",
99 | " 302 | \n",
100 | " 3 | \n",
101 | " 891717742 | \n",
102 | "
\n",
103 | " \n",
104 | "
\n",
105 | "
"
106 | ],
107 | "text/plain": [
108 | " user_id item_id rating timestamp\n",
109 | "0 0 50 5 881250949\n",
110 | "1 0 172 5 881250949\n",
111 | "2 0 133 1 881250949\n",
112 | "3 196 242 3 881250949\n",
113 | "4 186 302 3 891717742"
114 | ]
115 | },
116 | "execution_count": 5,
117 | "metadata": {},
118 | "output_type": "execute_result"
119 | }
120 | ],
121 | "source": [
122 | "df.head()"
123 | ]
124 | },
125 | {
126 | "cell_type": "code",
127 | "execution_count": 7,
128 | "metadata": {},
129 | "outputs": [],
130 | "source": [
131 | "movie_titles = pd.read_csv('Movie_Id_Titles')"
132 | ]
133 | },
134 | {
135 | "cell_type": "code",
136 | "execution_count": 9,
137 | "metadata": {},
138 | "outputs": [],
139 | "source": [
140 | "## MERGING DATA FRAMES\n",
141 | "df = pd.merge(df, movie_titles, on = 'item_id')"
142 | ]
143 | },
144 | {
145 | "cell_type": "code",
146 | "execution_count": 10,
147 | "metadata": {},
148 | "outputs": [
149 | {
150 | "data": {
151 | "text/html": [
152 | "\n",
153 | "\n",
166 | "
\n",
167 | " \n",
168 | " \n",
169 | " | \n",
170 | " user_id | \n",
171 | " item_id | \n",
172 | " rating | \n",
173 | " timestamp | \n",
174 | " title | \n",
175 | "
\n",
176 | " \n",
177 | " \n",
178 | " \n",
179 | " 0 | \n",
180 | " 0 | \n",
181 | " 50 | \n",
182 | " 5 | \n",
183 | " 881250949 | \n",
184 | " Star Wars (1977) | \n",
185 | "
\n",
186 | " \n",
187 | " 1 | \n",
188 | " 290 | \n",
189 | " 50 | \n",
190 | " 5 | \n",
191 | " 880473582 | \n",
192 | " Star Wars (1977) | \n",
193 | "
\n",
194 | " \n",
195 | " 2 | \n",
196 | " 79 | \n",
197 | " 50 | \n",
198 | " 4 | \n",
199 | " 891271545 | \n",
200 | " Star Wars (1977) | \n",
201 | "
\n",
202 | " \n",
203 | " 3 | \n",
204 | " 2 | \n",
205 | " 50 | \n",
206 | " 5 | \n",
207 | " 888552084 | \n",
208 | " Star Wars (1977) | \n",
209 | "
\n",
210 | " \n",
211 | " 4 | \n",
212 | " 8 | \n",
213 | " 50 | \n",
214 | " 5 | \n",
215 | " 879362124 | \n",
216 | " Star Wars (1977) | \n",
217 | "
\n",
218 | " \n",
219 | "
\n",
220 | "
"
221 | ],
222 | "text/plain": [
223 | " user_id item_id rating timestamp title\n",
224 | "0 0 50 5 881250949 Star Wars (1977)\n",
225 | "1 290 50 5 880473582 Star Wars (1977)\n",
226 | "2 79 50 4 891271545 Star Wars (1977)\n",
227 | "3 2 50 5 888552084 Star Wars (1977)\n",
228 | "4 8 50 5 879362124 Star Wars (1977)"
229 | ]
230 | },
231 | "execution_count": 10,
232 | "metadata": {},
233 | "output_type": "execute_result"
234 | }
235 | ],
236 | "source": [
237 | "df.head()"
238 | ]
239 | },
240 | {
241 | "cell_type": "code",
242 | "execution_count": 12,
243 | "metadata": {
244 | "collapsed": true
245 | },
246 | "outputs": [],
247 | "source": [
248 | "import matplotlib.pyplot as plt\n",
249 | "import seaborn as sns\n",
250 | "%matplotlib inline"
251 | ]
252 | },
253 | {
254 | "cell_type": "code",
255 | "execution_count": 14,
256 | "metadata": {},
257 | "outputs": [
258 | {
259 | "data": {
260 | "text/plain": [
261 | "title\n",
262 | "Marlene Dietrich: Shadow and Light (1996) 5.0\n",
263 | "Prefontaine (1997) 5.0\n",
264 | "Santa with Muscles (1996) 5.0\n",
265 | "Star Kid (1997) 5.0\n",
266 | "Someone Else's America (1995) 5.0\n",
267 | "Name: rating, dtype: float64"
268 | ]
269 | },
270 | "execution_count": 14,
271 | "metadata": {},
272 | "output_type": "execute_result"
273 | }
274 | ],
275 | "source": [
276 | "df.groupby('title')['rating'].mean().sort_values(ascending=False).head()"
277 | ]
278 | },
279 | {
280 | "cell_type": "code",
281 | "execution_count": 15,
282 | "metadata": {},
283 | "outputs": [
284 | {
285 | "data": {
286 | "text/plain": [
287 | "title\n",
288 | "Star Wars (1977) 584\n",
289 | "Contact (1997) 509\n",
290 | "Fargo (1996) 508\n",
291 | "Return of the Jedi (1983) 507\n",
292 | "Liar Liar (1997) 485\n",
293 | "Name: rating, dtype: int64"
294 | ]
295 | },
296 | "execution_count": 15,
297 | "metadata": {},
298 | "output_type": "execute_result"
299 | }
300 | ],
301 | "source": [
302 | "df.groupby('title')['rating'].count().sort_values(ascending=False).head()"
303 | ]
304 | },
305 | {
306 | "cell_type": "code",
307 | "execution_count": 16,
308 | "metadata": {
309 | "collapsed": true
310 | },
311 | "outputs": [],
312 | "source": [
313 | "ratings = pd.DataFrame(df.groupby('title')['rating'].mean())"
314 | ]
315 | },
316 | {
317 | "cell_type": "code",
318 | "execution_count": 19,
319 | "metadata": {},
320 | "outputs": [],
321 | "source": [
322 | "ratings['num of ratings'] = pd.DataFrame(df.groupby('title')['rating'].count())"
323 | ]
324 | },
325 | {
326 | "cell_type": "code",
327 | "execution_count": null,
328 | "metadata": {
329 | "collapsed": true
330 | },
331 | "outputs": [],
332 | "source": []
333 | }
334 | ],
335 | "metadata": {
336 | "kernelspec": {
337 | "display_name": "Python 3",
338 | "language": "python",
339 | "name": "python3"
340 | },
341 | "language_info": {
342 | "codemirror_mode": {
343 | "name": "ipython",
344 | "version": 3
345 | },
346 | "file_extension": ".py",
347 | "mimetype": "text/x-python",
348 | "name": "python",
349 | "nbconvert_exporter": "python",
350 | "pygments_lexer": "ipython3",
351 | "version": "3.6.1"
352 | }
353 | },
354 | "nbformat": 4,
355 | "nbformat_minor": 2
356 | }
357 |
--------------------------------------------------------------------------------
/ML_Recommender/u.item:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pasteurtran/Udemy_Python_for_Data_Science/88988a2173bd8b68533109fc9543ca6b5332c67e/ML_Recommender/u.item
--------------------------------------------------------------------------------
/ML_TreeMethods/.ipynb_checkpoints/Tree Methods Lecture Notes-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 2
6 | }
7 |
--------------------------------------------------------------------------------
/ML_TreeMethods/kyphosis.csv:
--------------------------------------------------------------------------------
1 | "Kyphosis","Age","Number","Start"
2 | "absent",71,3,5
3 | "absent",158,3,14
4 | "present",128,4,5
5 | "absent",2,5,1
6 | "absent",1,4,15
7 | "absent",1,2,16
8 | "absent",61,2,17
9 | "absent",37,3,16
10 | "absent",113,2,16
11 | "present",59,6,12
12 | "present",82,5,14
13 | "absent",148,3,16
14 | "absent",18,5,2
15 | "absent",1,4,12
16 | "absent",168,3,18
17 | "absent",1,3,16
18 | "absent",78,6,15
19 | "absent",175,5,13
20 | "absent",80,5,16
21 | "absent",27,4,9
22 | "absent",22,2,16
23 | "present",105,6,5
24 | "present",96,3,12
25 | "absent",131,2,3
26 | "present",15,7,2
27 | "absent",9,5,13
28 | "absent",8,3,6
29 | "absent",100,3,14
30 | "absent",4,3,16
31 | "absent",151,2,16
32 | "absent",31,3,16
33 | "absent",125,2,11
34 | "absent",130,5,13
35 | "absent",112,3,16
36 | "absent",140,5,11
37 | "absent",93,3,16
38 | "absent",1,3,9
39 | "present",52,5,6
40 | "absent",20,6,9
41 | "present",91,5,12
42 | "present",73,5,1
43 | "absent",35,3,13
44 | "absent",143,9,3
45 | "absent",61,4,1
46 | "absent",97,3,16
47 | "present",139,3,10
48 | "absent",136,4,15
49 | "absent",131,5,13
50 | "present",121,3,3
51 | "absent",177,2,14
52 | "absent",68,5,10
53 | "absent",9,2,17
54 | "present",139,10,6
55 | "absent",2,2,17
56 | "absent",140,4,15
57 | "absent",72,5,15
58 | "absent",2,3,13
59 | "present",120,5,8
60 | "absent",51,7,9
61 | "absent",102,3,13
62 | "present",130,4,1
63 | "present",114,7,8
64 | "absent",81,4,1
65 | "absent",118,3,16
66 | "absent",118,4,16
67 | "absent",17,4,10
68 | "absent",195,2,17
69 | "absent",159,4,13
70 | "absent",18,4,11
71 | "absent",15,5,16
72 | "absent",158,5,14
73 | "absent",127,4,12
74 | "absent",87,4,16
75 | "absent",206,4,10
76 | "absent",11,3,15
77 | "absent",178,4,15
78 | "present",157,3,13
79 | "absent",26,7,13
80 | "absent",120,2,13
81 | "present",42,7,6
82 | "absent",36,4,13
83 |
--------------------------------------------------------------------------------
/MatplotLIb/.ipynb_checkpoints/MatplotLib-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# Matplot Lib\n",
8 | "- Similar to Mat Lab - works well with pandas and numpy\n",
9 | "- Seaborn as well"
10 | ]
11 | },
12 | {
13 | "cell_type": "code",
14 | "execution_count": 1,
15 | "metadata": {
16 | "collapsed": true
17 | },
18 | "outputs": [],
19 | "source": [
20 | "import matplotlib.pyplot as plt"
21 | ]
22 | },
23 | {
24 | "cell_type": "code",
25 | "execution_count": 4,
26 | "metadata": {
27 | "collapsed": false
28 | },
29 | "outputs": [],
30 | "source": [
31 | "%matplotlib inline "
32 | ]
33 | },
34 | {
35 | "cell_type": "code",
36 | "execution_count": 5,
37 | "metadata": {
38 | "collapsed": true
39 | },
40 | "outputs": [],
41 | "source": [
42 | "#this is for jupyter to SEE the plot"
43 | ]
44 | },
45 | {
46 | "cell_type": "code",
47 | "execution_count": 6,
48 | "metadata": {
49 | "collapsed": true
50 | },
51 | "outputs": [],
52 | "source": [
53 | "import numpy as np\n",
54 | "x = np.linspace(0,5,11)\n",
55 | "y = x**2"
56 | ]
57 | },
58 | {
59 | "cell_type": "code",
60 | "execution_count": 7,
61 | "metadata": {
62 | "collapsed": false
63 | },
64 | "outputs": [
65 | {
66 | "data": {
67 | "text/plain": [
68 | "array([ 0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4.5, 5. ])"
69 | ]
70 | },
71 | "execution_count": 7,
72 | "metadata": {},
73 | "output_type": "execute_result"
74 | }
75 | ],
76 | "source": [
77 | "x"
78 | ]
79 | },
80 | {
81 | "cell_type": "code",
82 | "execution_count": 8,
83 | "metadata": {
84 | "collapsed": false
85 | },
86 | "outputs": [
87 | {
88 | "data": {
89 | "text/plain": [
90 | "array([ 0. , 0.25, 1. , 2.25, 4. , 6.25, 9. , 12.25,\n",
91 | " 16. , 20.25, 25. ])"
92 | ]
93 | },
94 | "execution_count": 8,
95 | "metadata": {},
96 | "output_type": "execute_result"
97 | }
98 | ],
99 | "source": [
100 | "y"
101 | ]
102 | },
103 | {
104 | "cell_type": "code",
105 | "execution_count": 12,
106 | "metadata": {
107 | "collapsed": false
108 | },
109 | "outputs": [
110 | {
111 | "data": {
112 | "text/plain": [
113 | ""
114 | ]
115 | },
116 | "execution_count": 12,
117 | "metadata": {},
118 | "output_type": "execute_result"
119 | },
120 | {
121 | "data": {
122 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHmJJREFUeJzt3XeYVdW5x/HvK2Kh2UAuFkRuiMYKZlR8LLGBWEG9GizY\nBVsUgy2WG7g2otixBEXFYBe4YkAEQUESQJoKCEYNqCBlBAlCFGaY9/6xDtcRmWFmmL3XKb/P85xn\nztn7zOz3YLJ/Z6+19lrm7oiISOHaLHYBIiISl4JARKTAKQhERAqcgkBEpMApCERECpyCQESkwCkI\nRKrIzG42s6cq2X+BmY1PsyaR2rB57AJEsoWZrSz3sh6wGlibed3N3e8q994WwFygrruXplWjSBIU\nBCIZ7t5g3XMzmwdc4u5vx6tIJB1qGhKpIjPraWYDMy/HZX4uN7OVZnbIBt6/p5mNMrNlZvaJmZ2Z\nXrUiVacgEKmZIzI/t3X3Bu4+ofxOM6sPjAJeAHYEOgOPmdle6ZYpsnEKApFknATMc/dn3L3U3acD\ng4AzItcl8jPqIxBJxm7AwWa2vNy2zYG/RKpHpEIKApGa2di0vV8BY929XRrFiGwKNQ2J1EwxUAa0\nrGD/X4FfmlkXM6ubeRxoZr9Kr0SRqlEQiNSAu/8buBP4m5ktN7O26+3/DmhP6CT+GlgE/AnYMu1a\nRTbGtDCNiEhh0xWBiEiBUxCIiBQ4BYGISIFTEIiIFLicuI+gcePG3qJFi9hliIjklKlTp37j7k02\n9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gCMJk8O9BVyUWTsBM9vZzHbchI8gUmvUNCSF6lLgS3df1xz0GHChmf3G\n3ceu9956Zja/3Ov7gZ7Aq2b2LTAG2L3c/o8I6wQ0Bm5396+Br83sV8CEkEGsBM4lrDImEpVmHxUR\nKXBqGhIRKXAKAhGRAqcgEBEpcAoCEZECpyAQESlwCgIRkQKnIBARKXD/B+nw7fo/0ED5AAAAAElF\nTkSuQmCC\n",
123 | "text/plain": [
124 | ""
125 | ]
126 | },
127 | "metadata": {},
128 | "output_type": "display_data"
129 | }
130 | ],
131 | "source": [
132 | "plt.plot(x,y,'r-') \n",
133 | "plt.xlabel('X Label')\n",
134 | "plt.ylabel('Y Label')\n",
135 | "plt.title('Title')\n",
136 | "# Basic Plot"
137 | ]
138 | },
139 | {
140 | "cell_type": "code",
141 | "execution_count": null,
142 | "metadata": {
143 | "collapsed": true
144 | },
145 | "outputs": [],
146 | "source": []
147 | }
148 | ],
149 | "metadata": {
150 | "kernelspec": {
151 | "display_name": "Python 3",
152 | "language": "python",
153 | "name": "python3"
154 | },
155 | "language_info": {
156 | "codemirror_mode": {
157 | "name": "ipython",
158 | "version": 3
159 | },
160 | "file_extension": ".py",
161 | "mimetype": "text/x-python",
162 | "name": "python",
163 | "nbconvert_exporter": "python",
164 | "pygments_lexer": "ipython3",
165 | "version": "3.6.0"
166 | }
167 | },
168 | "nbformat": 4,
169 | "nbformat_minor": 2
170 | }
171 |
--------------------------------------------------------------------------------
/MatplotLIb/my_first_fig_save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pasteurtran/Udemy_Python_for_Data_Science/88988a2173bd8b68533109fc9543ca6b5332c67e/MatplotLIb/my_first_fig_save.png
--------------------------------------------------------------------------------
/NLP/smsspamcollection/readme:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pasteurtran/Udemy_Python_for_Data_Science/88988a2173bd8b68533109fc9543ca6b5332c67e/NLP/smsspamcollection/readme
--------------------------------------------------------------------------------
/Neural Networks/.ipynb_checkpoints/Neural Network - TF Basics-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": true
8 | },
9 | "outputs": [],
10 | "source": [
11 | "import tensorflow as tf"
12 | ]
13 | },
14 | {
15 | "cell_type": "code",
16 | "execution_count": 3,
17 | "metadata": {},
18 | "outputs": [
19 | {
20 | "data": {
21 | "text/plain": [
22 | "tensorflow.python.framework.ops.Tensor"
23 | ]
24 | },
25 | "execution_count": 3,
26 | "metadata": {},
27 | "output_type": "execute_result"
28 | }
29 | ],
30 | "source": [
31 | "hellotest = tf.constant('Hello World')\n",
32 | "type(hellotest)"
33 | ]
34 | },
35 | {
36 | "cell_type": "code",
37 | "execution_count": 4,
38 | "metadata": {
39 | "collapsed": true
40 | },
41 | "outputs": [],
42 | "source": [
43 | "x = tf.constant(100)"
44 | ]
45 | },
46 | {
47 | "cell_type": "markdown",
48 | "metadata": {},
49 | "source": [
50 | "# Start a session"
51 | ]
52 | },
53 | {
54 | "cell_type": "code",
55 | "execution_count": 5,
56 | "metadata": {
57 | "collapsed": true
58 | },
59 | "outputs": [],
60 | "source": [
61 | "sess = tf.Session()"
62 | ]
63 | },
64 | {
65 | "cell_type": "code",
66 | "execution_count": 6,
67 | "metadata": {},
68 | "outputs": [
69 | {
70 | "data": {
71 | "text/plain": [
72 | "b'Hello World'"
73 | ]
74 | },
75 | "execution_count": 6,
76 | "metadata": {},
77 | "output_type": "execute_result"
78 | }
79 | ],
80 | "source": [
81 | "sess.run(hellotest)"
82 | ]
83 | },
84 | {
85 | "cell_type": "code",
86 | "execution_count": 7,
87 | "metadata": {},
88 | "outputs": [
89 | {
90 | "data": {
91 | "text/plain": [
92 | "100"
93 | ]
94 | },
95 | "execution_count": 7,
96 | "metadata": {},
97 | "output_type": "execute_result"
98 | }
99 | ],
100 | "source": [
101 | "sess.run(x)"
102 | ]
103 | },
104 | {
105 | "cell_type": "code",
106 | "execution_count": 8,
107 | "metadata": {
108 | "collapsed": true
109 | },
110 | "outputs": [],
111 | "source": [
112 | "# Operations"
113 | ]
114 | },
115 | {
116 | "cell_type": "markdown",
117 | "metadata": {},
118 | "source": [
119 | "x = tf.constant(2)"
120 | ]
121 | },
122 | {
123 | "cell_type": "code",
124 | "execution_count": 10,
125 | "metadata": {
126 | "collapsed": true
127 | },
128 | "outputs": [],
129 | "source": [
130 | "y = tf.constant(3)"
131 | ]
132 | },
133 | {
134 | "cell_type": "code",
135 | "execution_count": 11,
136 | "metadata": {},
137 | "outputs": [
138 | {
139 | "name": "stdout",
140 | "output_type": "stream",
141 | "text": [
142 | "Operations with constants\n",
143 | "5\n"
144 | ]
145 | }
146 | ],
147 | "source": [
148 | "with tf.Session() as sess:\n",
149 | " print('Operations with constants')\n",
150 | " print(sess.run(x+y))\n",
151 | " "
152 | ]
153 | },
154 | {
155 | "cell_type": "code",
156 | "execution_count": 12,
157 | "metadata": {
158 | "collapsed": true
159 | },
160 | "outputs": [],
161 | "source": [
162 | "x = tf.placeholder(tf.int32)\n",
163 | "y = tf.placeholder(tf.int32)\n"
164 | ]
165 | },
166 | {
167 | "cell_type": "code",
168 | "execution_count": 13,
169 | "metadata": {
170 | "collapsed": true
171 | },
172 | "outputs": [],
173 | "source": [
174 | "add = tf.add(x,y)"
175 | ]
176 | },
177 | {
178 | "cell_type": "code",
179 | "execution_count": 15,
180 | "metadata": {},
181 | "outputs": [],
182 | "source": [
183 | "import numpy as np"
184 | ]
185 | },
186 | {
187 | "cell_type": "code",
188 | "execution_count": 16,
189 | "metadata": {
190 | "collapsed": true
191 | },
192 | "outputs": [],
193 | "source": [
194 | "a = np.array([[5.0, 5.0]])\n",
195 | "b = np.array([[2.0], [2.0]])"
196 | ]
197 | },
198 | {
199 | "cell_type": "code",
200 | "execution_count": 17,
201 | "metadata": {
202 | "collapsed": true
203 | },
204 | "outputs": [],
205 | "source": [
206 | "mat1 = tf.constant(a)\n",
207 | "mat2 = tf.constant(b)"
208 | ]
209 | },
210 | {
211 | "cell_type": "code",
212 | "execution_count": 18,
213 | "metadata": {
214 | "collapsed": true
215 | },
216 | "outputs": [],
217 | "source": [
218 | "matrix_multi = tf.matmul(mat1, mat2)"
219 | ]
220 | },
221 | {
222 | "cell_type": "code",
223 | "execution_count": 19,
224 | "metadata": {},
225 | "outputs": [
226 | {
227 | "name": "stdout",
228 | "output_type": "stream",
229 | "text": [
230 | "[[ 20.]]\n"
231 | ]
232 | }
233 | ],
234 | "source": [
235 | "with tf.Session() as sess:\n",
236 | " result = sess.run(matrix_multi)\n",
237 | " print(result)"
238 | ]
239 | },
240 | {
241 | "cell_type": "markdown",
242 | "metadata": {},
243 | "source": [
244 | "# MNIST DATA"
245 | ]
246 | },
247 | {
248 | "cell_type": "code",
249 | "execution_count": 20,
250 | "metadata": {
251 | "collapsed": true
252 | },
253 | "outputs": [],
254 | "source": [
255 | "# MNIST\n",
256 | "from tensorflow.examples.tutorials.mnist import input_data"
257 | ]
258 | },
259 | {
260 | "cell_type": "code",
261 | "execution_count": 21,
262 | "metadata": {},
263 | "outputs": [
264 | {
265 | "name": "stdout",
266 | "output_type": "stream",
267 | "text": [
268 | "Extracting /tmp/data/train-images-idx3-ubyte.gz\n",
269 | "Extracting /tmp/data/train-labels-idx1-ubyte.gz\n",
270 | "Extracting /tmp/data/t10k-images-idx3-ubyte.gz\n",
271 | "Extracting /tmp/data/t10k-labels-idx1-ubyte.gz\n"
272 | ]
273 | }
274 | ],
275 | "source": [
276 | "mnist = input_data.read_data_sets(\"/tmp/data\", one_hot=True)"
277 | ]
278 | },
279 | {
280 | "cell_type": "code",
281 | "execution_count": 22,
282 | "metadata": {},
283 | "outputs": [
284 | {
285 | "data": {
286 | "text/plain": [
287 | "tensorflow.contrib.learn.python.learn.datasets.base.Datasets"
288 | ]
289 | },
290 | "execution_count": 22,
291 | "metadata": {},
292 | "output_type": "execute_result"
293 | }
294 | ],
295 | "source": [
296 | "type(mnist)"
297 | ]
298 | },
299 | {
300 | "cell_type": "code",
301 | "execution_count": 24,
302 | "metadata": {},
303 | "outputs": [
304 | {
305 | "data": {
306 | "text/plain": [
307 | "(55000, 784)"
308 | ]
309 | },
310 | "execution_count": 24,
311 | "metadata": {},
312 | "output_type": "execute_result"
313 | }
314 | ],
315 | "source": [
316 | "mnist.train.images.shape"
317 | ]
318 | },
319 | {
320 | "cell_type": "code",
321 | "execution_count": 25,
322 | "metadata": {
323 | "collapsed": true
324 | },
325 | "outputs": [],
326 | "source": [
327 | "import matplotlib.pyplot as plt\n",
328 | "%matplotlib inline"
329 | ]
330 | },
331 | {
332 | "cell_type": "code",
333 | "execution_count": 27,
334 | "metadata": {},
335 | "outputs": [
336 | {
337 | "data": {
338 | "text/plain": [
339 | ""
340 | ]
341 | },
342 | "execution_count": 27,
343 | "metadata": {},
344 | "output_type": "execute_result"
345 | },
346 | {
347 | "data": {
348 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP8AAAD8CAYAAAC4nHJkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADWVJREFUeJzt3X2IXfWdx/HPJw9FSBpiNrMxmuh0iwgiNFmGsFJdunQT\nrRaSgphGKRGliVB1C/nDMOvjX8bVpigulXQNjUvXVkhMAkq3bljQQgmOkvWh7m40TmhCHiamUGvQ\nbibf/WNOylTnnju599x77uT7fsEw957vefh6nE/Ovfd37/05IgQgn2l1NwCgHoQfSIrwA0kRfiAp\nwg8kRfiBpAg/kBThB5Ii/EBSM7p5sPnz50d/f383DwmkMjw8rBMnTngy67YVftvXS3pC0nRJ/xIR\nm8rW7+/v19DQUDuHBFBiYGBg0uu2/LDf9nRJ/yzpG5KulLTG9pWt7g9Ad7XznH+ZpPci4kBE/FHS\nzyStrKYtAJ3WTvgvkfTbcfcPFcv+jO11todsD42MjLRxOABV6vir/RGxJSIGImKgr6+v04cDMEnt\nhP+wpMXj7i8qlgGYAtoJ/2uSLrf9JdtfkPRtSburaQtAp7U81BcRp23fJ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AUo6I7h3MHpF0cNyi+ZJOdK2B\nc9OrvfVqXxK9tarK3i6LiEl9X15Xw/+5g9tDETFQWwMlerW3Xu1LordW1dUbD/uBpAg/kFTd4d9S\n8/HL9GpvvdqXRG+tqqW3Wp/zA6hP3Vd+ADWpJfy2r7f9P7bfs72xjh4asT1s+y3b+2wP1dzLVtvH\nbb89btk82y/b3l/8nnCatJp6e8j24eLc7bN9Q029Lbb9n7Z/Y/sd2/9QLK/13JX0Vct56/rDftvT\nJf2vpOWSDkl6TdKaiPhNVxtpwPawpIGIqH1M2PbfSvqDpGcj4qpi2T9JOhkRm4p/OC+MiHt7pLeH\nJP2h7pmbiwllFo6fWVrSKkm3qcZzV9LXzarhvNVx5V8m6b2IOBARf5T0M0kra+ij50XEK5I+O8H9\nSknbitvbNPbH03UNeusJEXEkIt4obn8k6ezM0rWeu5K+alFH+C+R9Ntx9w+pt6b8Dkm/tP267XV1\nNzOBBcW06ZJ0VNKCOpuZQNOZm7vpMzNL98y5a2XG66rxgt/nXRMRfy3pG5K+Vzy87Ukx9pytl4Zr\nJjVzc7dMMLP0n9R57lqd8bpqdYT/sKTF4+4vKpb1hIg4XPw+LukF9d7sw8fOTpJa/D5ecz9/0ksz\nN080s7R64Nz10ozXdYT/NUmX2/6S7S9I+rak3TX08Tm2ZxUvxMj2LEkr1HuzD++WtLa4vVbSrhp7\n+TO9MnNzo5mlVfO567kZryOi6z+SbtDYK/7vS/rHOnpo0NdfSfqv4uedunuT9JzGHgb+n8ZeG7lD\n0l9I2iNpv6T/kDSvh3r7V0lvSXpTY0FbWFNv12jsIf2bkvYVPzfUfe5K+qrlvPEOPyApXvADkiL8\nQFKEH0iK8ANJEX4gKcIPJEX4gaQIP5DU/wOtYgtial/6mwAAAABJRU5ErkJggg==\n",
349 | "text/plain": [
350 | ""
351 | ]
352 | },
353 | "metadata": {},
354 | "output_type": "display_data"
355 | }
356 | ],
357 | "source": [
358 | "sample = mnist.train.images[2].reshape(28,28)\n",
359 | "plt.imshow(sample, cmap='Greys')"
360 | ]
361 | },
362 | {
363 | "cell_type": "code",
364 | "execution_count": 28,
365 | "metadata": {
366 | "collapsed": true
367 | },
368 | "outputs": [],
369 | "source": [
370 | "learning_rate = 0.001\n",
371 | "training_epochs = 15 #cycles\n",
372 | "batch_sizze = 100\n"
373 | ]
374 | },
375 | {
376 | "cell_type": "code",
377 | "execution_count": 31,
378 | "metadata": {},
379 | "outputs": [
380 | {
381 | "name": "stdout",
382 | "output_type": "stream",
383 | "text": [
384 | "55000\n"
385 | ]
386 | }
387 | ],
388 | "source": [
389 | "n_classes = 10 #0-9 clases\n",
390 | "n_samples = mnist.train.num_examples\n",
391 | "print(n_samples)"
392 | ]
393 | },
394 | {
395 | "cell_type": "code",
396 | "execution_count": 32,
397 | "metadata": {},
398 | "outputs": [],
399 | "source": [
400 | "n_input = 784 # because we dealing by 28/28 "
401 | ]
402 | },
403 | {
404 | "cell_type": "code",
405 | "execution_count": 33,
406 | "metadata": {
407 | "collapsed": true
408 | },
409 | "outputs": [],
410 | "source": [
411 | "n_hidden_1 = 256\n",
412 | "n_hidden_2 = 256"
413 | ]
414 | },
415 | {
416 | "cell_type": "code",
417 | "execution_count": null,
418 | "metadata": {
419 | "collapsed": true
420 | },
421 | "outputs": [],
422 | "source": [
423 | "# Multilayer perception\n",
424 | "def multilayer_perceptron(x, weights, biases):\n",
425 | " \"\"\"\n",
426 | " x: Placeholder for Data Input\n",
427 | " weights: Dictionary of weights\n",
428 | " Biases: Dictionary of bias values\n",
429 | " \"\"\"\n",
430 | " \n",
431 | " #First Hidden Layer with RELU (rectifer activation function)\n",
432 | " # Multiply weight by input, then add bias\n",
433 | " # Then pass thruough a funciton RELU -> f(x) = max(0,x)\n",
434 | " layer_1 = tf.add(tf.matmul(x,weights['h1']), bias['b1'])\n",
435 | " layer_1 = tf.nn.relu(layer_1)\n",
436 | " \n",
437 | " \n",
438 | " \n",
439 | " "
440 | ]
441 | }
442 | ],
443 | "metadata": {
444 | "kernelspec": {
445 | "display_name": "Python 3",
446 | "language": "python",
447 | "name": "python3"
448 | },
449 | "language_info": {
450 | "codemirror_mode": {
451 | "name": "ipython",
452 | "version": 3
453 | },
454 | "file_extension": ".py",
455 | "mimetype": "text/x-python",
456 | "name": "python",
457 | "nbconvert_exporter": "python",
458 | "pygments_lexer": "ipython3",
459 | "version": "3.6.1"
460 | }
461 | },
462 | "nbformat": 4,
463 | "nbformat_minor": 2
464 | }
465 |
--------------------------------------------------------------------------------
/Neural Networks/Tensorflow Basics.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "___\n",
8 | "\n",
9 | "
\n",
10 | "___\n",
11 | "# Tensorflow Basics\n",
12 | "\n",
13 | "Remember to reference the video for full explanations, this is just a notebook for code reference.\n",
14 | "\n",
15 | "You can import the library:"
16 | ]
17 | },
18 | {
19 | "cell_type": "code",
20 | "execution_count": 1,
21 | "metadata": {
22 | "collapsed": true
23 | },
24 | "outputs": [],
25 | "source": [
26 | "import tensorflow as tf"
27 | ]
28 | },
29 | {
30 | "cell_type": "markdown",
31 | "metadata": {},
32 | "source": [
33 | "### Simple Constants\n",
34 | "\n",
35 | "Let's show how to create a simple constant with Tensorflow, which TF stores as a tensor object:"
36 | ]
37 | },
38 | {
39 | "cell_type": "code",
40 | "execution_count": 4,
41 | "metadata": {
42 | "collapsed": true
43 | },
44 | "outputs": [],
45 | "source": [
46 | "hello = tf.constant('Hello World')"
47 | ]
48 | },
49 | {
50 | "cell_type": "code",
51 | "execution_count": 6,
52 | "metadata": {
53 | "collapsed": false
54 | },
55 | "outputs": [
56 | {
57 | "data": {
58 | "text/plain": [
59 | "tensorflow.python.framework.ops.Tensor"
60 | ]
61 | },
62 | "execution_count": 6,
63 | "metadata": {},
64 | "output_type": "execute_result"
65 | }
66 | ],
67 | "source": [
68 | "type(hello)"
69 | ]
70 | },
71 | {
72 | "cell_type": "code",
73 | "execution_count": 7,
74 | "metadata": {
75 | "collapsed": true
76 | },
77 | "outputs": [],
78 | "source": [
79 | "x = tf.constant(100)"
80 | ]
81 | },
82 | {
83 | "cell_type": "code",
84 | "execution_count": 9,
85 | "metadata": {
86 | "collapsed": false
87 | },
88 | "outputs": [
89 | {
90 | "data": {
91 | "text/plain": [
92 | "tensorflow.python.framework.ops.Tensor"
93 | ]
94 | },
95 | "execution_count": 9,
96 | "metadata": {},
97 | "output_type": "execute_result"
98 | }
99 | ],
100 | "source": [
101 | "type(x)"
102 | ]
103 | },
104 | {
105 | "cell_type": "markdown",
106 | "metadata": {},
107 | "source": [
108 | "### Running Sessions\n",
109 | "\n",
110 | "Now you can create a TensorFlow Session, which is a class for running TensorFlow operations.\n",
111 | "\n",
112 | "A `Session` object encapsulates the environment in which `Operation`\n",
113 | "objects are executed, and `Tensor` objects are evaluated. For example:"
114 | ]
115 | },
116 | {
117 | "cell_type": "code",
118 | "execution_count": 10,
119 | "metadata": {
120 | "collapsed": true
121 | },
122 | "outputs": [],
123 | "source": [
124 | "sess = tf.Session()"
125 | ]
126 | },
127 | {
128 | "cell_type": "code",
129 | "execution_count": 15,
130 | "metadata": {
131 | "collapsed": false
132 | },
133 | "outputs": [
134 | {
135 | "data": {
136 | "text/plain": [
137 | "b'Hello World'"
138 | ]
139 | },
140 | "execution_count": 15,
141 | "metadata": {},
142 | "output_type": "execute_result"
143 | }
144 | ],
145 | "source": [
146 | "sess.run(hello)"
147 | ]
148 | },
149 | {
150 | "cell_type": "code",
151 | "execution_count": 16,
152 | "metadata": {
153 | "collapsed": false
154 | },
155 | "outputs": [
156 | {
157 | "data": {
158 | "text/plain": [
159 | "bytes"
160 | ]
161 | },
162 | "execution_count": 16,
163 | "metadata": {},
164 | "output_type": "execute_result"
165 | }
166 | ],
167 | "source": [
168 | "type(sess.run(hello))"
169 | ]
170 | },
171 | {
172 | "cell_type": "code",
173 | "execution_count": 17,
174 | "metadata": {
175 | "collapsed": false
176 | },
177 | "outputs": [
178 | {
179 | "data": {
180 | "text/plain": [
181 | "100"
182 | ]
183 | },
184 | "execution_count": 17,
185 | "metadata": {},
186 | "output_type": "execute_result"
187 | }
188 | ],
189 | "source": [
190 | "sess.run(x)"
191 | ]
192 | },
193 | {
194 | "cell_type": "code",
195 | "execution_count": 14,
196 | "metadata": {
197 | "collapsed": false
198 | },
199 | "outputs": [
200 | {
201 | "data": {
202 | "text/plain": [
203 | "numpy.int32"
204 | ]
205 | },
206 | "execution_count": 14,
207 | "metadata": {},
208 | "output_type": "execute_result"
209 | }
210 | ],
211 | "source": [
212 | "type(sess.run(x))"
213 | ]
214 | },
215 | {
216 | "cell_type": "markdown",
217 | "metadata": {},
218 | "source": [
219 | "## Operations\n",
220 | "\n",
221 | "You can line up multiple Tensorflow operations in to be run during a session:"
222 | ]
223 | },
224 | {
225 | "cell_type": "code",
226 | "execution_count": 33,
227 | "metadata": {
228 | "collapsed": true
229 | },
230 | "outputs": [],
231 | "source": [
232 | "x = tf.constant(2)\n",
233 | "y = tf.constant(3)"
234 | ]
235 | },
236 | {
237 | "cell_type": "code",
238 | "execution_count": 34,
239 | "metadata": {
240 | "collapsed": false
241 | },
242 | "outputs": [
243 | {
244 | "name": "stdout",
245 | "output_type": "stream",
246 | "text": [
247 | "Operations with Constants\n",
248 | "Addition 5\n",
249 | "Subtraction -1\n",
250 | "Multiplication 6\n",
251 | "Division 0.666666666667\n"
252 | ]
253 | }
254 | ],
255 | "source": [
256 | "with tf.Session() as sess:\n",
257 | " print('Operations with Constants')\n",
258 | " print('Addition',sess.run(x+y))\n",
259 | " print('Subtraction',sess.run(x-y))\n",
260 | " print('Multiplication',sess.run(x*y))\n",
261 | " print('Division',sess.run(x/y))"
262 | ]
263 | },
264 | {
265 | "cell_type": "markdown",
266 | "metadata": {},
267 | "source": [
268 | "#### Placeholder\n",
269 | "\n",
270 | "You may not always have the constants right away, and you may be waiting for a constant to appear after a cycle of operations. **tf.placeholder** is a tool for this. It inserts a placeholder for a tensor that will be always fed.\n",
271 | "\n",
272 | "**Important**: This tensor will produce an error if evaluated. Its value must be fed using the `feed_dict` optional argument to `Session.run()`,\n",
273 | "`Tensor.eval()`, or `Operation.run()`. For example, for a placeholder of a matrix of floating point numbers:\n",
274 | "\n",
275 | " x = tf.placeholder(tf.float32, shape=(1024, 1024))\n",
276 | "\n",
277 | "Here is an example for integer placeholders:"
278 | ]
279 | },
280 | {
281 | "cell_type": "code",
282 | "execution_count": 46,
283 | "metadata": {
284 | "collapsed": true
285 | },
286 | "outputs": [],
287 | "source": [
288 | "x = tf.placeholder(tf.int32)\n",
289 | "y = tf.placeholder(tf.int32)"
290 | ]
291 | },
292 | {
293 | "cell_type": "code",
294 | "execution_count": 47,
295 | "metadata": {
296 | "collapsed": false
297 | },
298 | "outputs": [
299 | {
300 | "data": {
301 | "text/plain": [
302 | " dtype=int16>"
303 | ]
304 | },
305 | "execution_count": 47,
306 | "metadata": {},
307 | "output_type": "execute_result"
308 | }
309 | ],
310 | "source": [
311 | "x"
312 | ]
313 | },
314 | {
315 | "cell_type": "code",
316 | "execution_count": 48,
317 | "metadata": {
318 | "collapsed": false
319 | },
320 | "outputs": [
321 | {
322 | "data": {
323 | "text/plain": [
324 | "tensorflow.python.framework.ops.Tensor"
325 | ]
326 | },
327 | "execution_count": 48,
328 | "metadata": {},
329 | "output_type": "execute_result"
330 | }
331 | ],
332 | "source": [
333 | "type(x)"
334 | ]
335 | },
336 | {
337 | "cell_type": "markdown",
338 | "metadata": {},
339 | "source": [
340 | "#### Defining Operations"
341 | ]
342 | },
343 | {
344 | "cell_type": "code",
345 | "execution_count": 30,
346 | "metadata": {
347 | "collapsed": true
348 | },
349 | "outputs": [],
350 | "source": [
351 | "add = tf.add(x,y)\n",
352 | "sub = tf.sub(x,y)\n",
353 | "mul = tf.mul(x,y)"
354 | ]
355 | },
356 | {
357 | "cell_type": "markdown",
358 | "metadata": {},
359 | "source": [
360 | "Running operations with variable input:"
361 | ]
362 | },
363 | {
364 | "cell_type": "code",
365 | "execution_count": 31,
366 | "metadata": {
367 | "collapsed": true
368 | },
369 | "outputs": [],
370 | "source": [
371 | "d = {x:20,y:30}"
372 | ]
373 | },
374 | {
375 | "cell_type": "code",
376 | "execution_count": 32,
377 | "metadata": {
378 | "collapsed": false
379 | },
380 | "outputs": [
381 | {
382 | "name": "stdout",
383 | "output_type": "stream",
384 | "text": [
385 | "Operations with Constants\n",
386 | "Addition 50\n",
387 | "Subtraction -10\n",
388 | "Multiplication 600\n"
389 | ]
390 | }
391 | ],
392 | "source": [
393 | "with tf.Session() as sess:\n",
394 | " print('Operations with Constants')\n",
395 | " print('Addition',sess.run(add,feed_dict=d))\n",
396 | " print('Subtraction',sess.run(sub,feed_dict=d))\n",
397 | " print('Multiplication',sess.run(mul,feed_dict=d))"
398 | ]
399 | },
400 | {
401 | "cell_type": "markdown",
402 | "metadata": {},
403 | "source": [
404 | "Now let's see an example of a more complex operation, using Matrix Multiplication. First we need to create the matrices:"
405 | ]
406 | },
407 | {
408 | "cell_type": "code",
409 | "execution_count": 69,
410 | "metadata": {
411 | "collapsed": true
412 | },
413 | "outputs": [],
414 | "source": [
415 | "import numpy as np\n",
416 | "# Make sure to use floats here, int64 will cause an error.\n",
417 | "a = np.array([[5.0,5.0]])\n",
418 | "b = np.array([[2.0],[2.0]])"
419 | ]
420 | },
421 | {
422 | "cell_type": "code",
423 | "execution_count": 75,
424 | "metadata": {
425 | "collapsed": false
426 | },
427 | "outputs": [
428 | {
429 | "data": {
430 | "text/plain": [
431 | "array([[ 5., 5.]])"
432 | ]
433 | },
434 | "execution_count": 75,
435 | "metadata": {},
436 | "output_type": "execute_result"
437 | }
438 | ],
439 | "source": [
440 | "a"
441 | ]
442 | },
443 | {
444 | "cell_type": "code",
445 | "execution_count": 76,
446 | "metadata": {
447 | "collapsed": false
448 | },
449 | "outputs": [
450 | {
451 | "data": {
452 | "text/plain": [
453 | "(1, 2)"
454 | ]
455 | },
456 | "execution_count": 76,
457 | "metadata": {},
458 | "output_type": "execute_result"
459 | }
460 | ],
461 | "source": [
462 | "a.shape"
463 | ]
464 | },
465 | {
466 | "cell_type": "code",
467 | "execution_count": 77,
468 | "metadata": {
469 | "collapsed": false
470 | },
471 | "outputs": [
472 | {
473 | "data": {
474 | "text/plain": [
475 | "array([[ 2.],\n",
476 | " [ 2.]])"
477 | ]
478 | },
479 | "execution_count": 77,
480 | "metadata": {},
481 | "output_type": "execute_result"
482 | }
483 | ],
484 | "source": [
485 | "b"
486 | ]
487 | },
488 | {
489 | "cell_type": "code",
490 | "execution_count": 78,
491 | "metadata": {
492 | "collapsed": false
493 | },
494 | "outputs": [
495 | {
496 | "data": {
497 | "text/plain": [
498 | "(2, 1)"
499 | ]
500 | },
501 | "execution_count": 78,
502 | "metadata": {},
503 | "output_type": "execute_result"
504 | }
505 | ],
506 | "source": [
507 | "b.shape"
508 | ]
509 | },
510 | {
511 | "cell_type": "code",
512 | "execution_count": 79,
513 | "metadata": {
514 | "collapsed": true
515 | },
516 | "outputs": [],
517 | "source": [
518 | "mat1 = tf.constant(a)"
519 | ]
520 | },
521 | {
522 | "cell_type": "code",
523 | "execution_count": 80,
524 | "metadata": {
525 | "collapsed": true
526 | },
527 | "outputs": [],
528 | "source": [
529 | "mat2 = tf.constant(b)"
530 | ]
531 | },
532 | {
533 | "cell_type": "markdown",
534 | "metadata": {},
535 | "source": [
536 | "The matrix multiplication operation:"
537 | ]
538 | },
539 | {
540 | "cell_type": "code",
541 | "execution_count": 81,
542 | "metadata": {
543 | "collapsed": false
544 | },
545 | "outputs": [],
546 | "source": [
547 | "matrix_multi = tf.matmul(mat1,mat2)"
548 | ]
549 | },
550 | {
551 | "cell_type": "markdown",
552 | "metadata": {},
553 | "source": [
554 | "Now run the session to perform the Operation:"
555 | ]
556 | },
557 | {
558 | "cell_type": "code",
559 | "execution_count": 82,
560 | "metadata": {
561 | "collapsed": false
562 | },
563 | "outputs": [
564 | {
565 | "name": "stdout",
566 | "output_type": "stream",
567 | "text": [
568 | "[[ 20.]]\n"
569 | ]
570 | }
571 | ],
572 | "source": [
573 | "with tf.Session() as sess:\n",
574 | " result = sess.run(matrix_multi)\n",
575 | " print(result)"
576 | ]
577 | },
578 | {
579 | "cell_type": "markdown",
580 | "metadata": {},
581 | "source": [
582 | "That is all for now! Next we will expand these basic concepts to construct out own Multi-Layer Perceptron model!"
583 | ]
584 | },
585 | {
586 | "cell_type": "markdown",
587 | "metadata": {},
588 | "source": [
589 | "# Great Job!"
590 | ]
591 | }
592 | ],
593 | "metadata": {
594 | "kernelspec": {
595 | "display_name": "Python 3",
596 | "language": "python",
597 | "name": "python3"
598 | },
599 | "language_info": {
600 | "codemirror_mode": {
601 | "name": "ipython",
602 | "version": 3
603 | },
604 | "file_extension": ".py",
605 | "mimetype": "text/x-python",
606 | "name": "python",
607 | "nbconvert_exporter": "python",
608 | "pygments_lexer": "ipython3",
609 | "version": "3.5.1"
610 | }
611 | },
612 | "nbformat": 4,
613 | "nbformat_minor": 0
614 | }
615 |
--------------------------------------------------------------------------------
/Neural Networks/Tensorflow with ContribLearn.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "___\n",
8 | "\n",
9 | "
\n",
10 | "___"
11 | ]
12 | },
13 | {
14 | "cell_type": "markdown",
15 | "metadata": {},
16 | "source": [
17 | "# Tensorflow with ContribLearn\n",
18 | "\n",
19 | "As we saw previously how to build a full Multi-Layer Perceptron model with full Sessions in Tensorflow. Unfortunately this was an extremely involved process. However developers have created ContribLearn (previously known as TKFlow or SciKit-Flow) which provides a SciKit Learn like interface for Tensorflow!\n",
20 | "\n",
21 | "It is much easier to use, but you sacrifice some level of customization of your model. Let's go ahead and explore it!"
22 | ]
23 | },
24 | {
25 | "cell_type": "markdown",
26 | "metadata": {},
27 | "source": [
28 | "## Get the Data\n",
29 | "\n",
30 | "We will the iris data set.\n",
31 | "\n",
32 | "Let's get the data:"
33 | ]
34 | },
35 | {
36 | "cell_type": "code",
37 | "execution_count": 1,
38 | "metadata": {
39 | "collapsed": false
40 | },
41 | "outputs": [],
42 | "source": [
43 | "from sklearn.datasets import load_iris"
44 | ]
45 | },
46 | {
47 | "cell_type": "code",
48 | "execution_count": 2,
49 | "metadata": {
50 | "collapsed": true
51 | },
52 | "outputs": [],
53 | "source": [
54 | "iris = load_iris()"
55 | ]
56 | },
57 | {
58 | "cell_type": "code",
59 | "execution_count": 3,
60 | "metadata": {
61 | "collapsed": false
62 | },
63 | "outputs": [],
64 | "source": [
65 | "X = iris['data']"
66 | ]
67 | },
68 | {
69 | "cell_type": "code",
70 | "execution_count": 4,
71 | "metadata": {
72 | "collapsed": true
73 | },
74 | "outputs": [],
75 | "source": [
76 | "y = iris['target']"
77 | ]
78 | },
79 | {
80 | "cell_type": "code",
81 | "execution_count": 5,
82 | "metadata": {
83 | "collapsed": false
84 | },
85 | "outputs": [
86 | {
87 | "data": {
88 | "text/plain": [
89 | "array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
90 | " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
91 | " 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
92 | " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
93 | " 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
94 | " 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
95 | " 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])"
96 | ]
97 | },
98 | "execution_count": 5,
99 | "metadata": {},
100 | "output_type": "execute_result"
101 | }
102 | ],
103 | "source": [
104 | "y"
105 | ]
106 | },
107 | {
108 | "cell_type": "code",
109 | "execution_count": 6,
110 | "metadata": {
111 | "collapsed": false
112 | },
113 | "outputs": [
114 | {
115 | "data": {
116 | "text/plain": [
117 | "dtype('int64')"
118 | ]
119 | },
120 | "execution_count": 6,
121 | "metadata": {},
122 | "output_type": "execute_result"
123 | }
124 | ],
125 | "source": [
126 | "y.dtype"
127 | ]
128 | },
129 | {
130 | "cell_type": "markdown",
131 | "metadata": {},
132 | "source": [
133 | "## Train Test Split"
134 | ]
135 | },
136 | {
137 | "cell_type": "code",
138 | "execution_count": 7,
139 | "metadata": {
140 | "collapsed": true
141 | },
142 | "outputs": [],
143 | "source": [
144 | "from sklearn.cross_validation import train_test_split"
145 | ]
146 | },
147 | {
148 | "cell_type": "code",
149 | "execution_count": 8,
150 | "metadata": {
151 | "collapsed": false
152 | },
153 | "outputs": [],
154 | "source": [
155 | "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)"
156 | ]
157 | },
158 | {
159 | "cell_type": "markdown",
160 | "metadata": {},
161 | "source": [
162 | "# Contrib.learn\n",
163 | "\n",
164 | "Let's show you how to use the simpler contrib.learn interface!"
165 | ]
166 | },
167 | {
168 | "cell_type": "code",
169 | "execution_count": 9,
170 | "metadata": {
171 | "collapsed": true
172 | },
173 | "outputs": [],
174 | "source": [
175 | "import tensorflow.contrib.learn.python.learn as learn"
176 | ]
177 | },
178 | {
179 | "cell_type": "markdown",
180 | "metadata": {},
181 | "source": [
182 | "There are several high level abstraction calls to models in learn, you can explore them with Tab, but we will use DNNClassifier, which stands for Deep Neural Network:"
183 | ]
184 | },
185 | {
186 | "cell_type": "code",
187 | "execution_count": 10,
188 | "metadata": {
189 | "collapsed": false
190 | },
191 | "outputs": [
192 | {
193 | "data": {
194 | "text/plain": [
195 | "DNNClassifier()"
196 | ]
197 | },
198 | "execution_count": 10,
199 | "metadata": {},
200 | "output_type": "execute_result"
201 | }
202 | ],
203 | "source": [
204 | "classifier = learn.DNNClassifier(hidden_units=[10, 20, 10], n_classes=3)#,feature_columns=feature_columns)\n",
205 | "classifier.fit(X_train, y_train, steps=200, batch_size=32)"
206 | ]
207 | },
208 | {
209 | "cell_type": "code",
210 | "execution_count": 11,
211 | "metadata": {
212 | "collapsed": true
213 | },
214 | "outputs": [],
215 | "source": [
216 | "iris_predictions = classifier.predict(X_test)"
217 | ]
218 | },
219 | {
220 | "cell_type": "code",
221 | "execution_count": 12,
222 | "metadata": {
223 | "collapsed": true
224 | },
225 | "outputs": [],
226 | "source": [
227 | "from sklearn.metrics import classification_report,confusion_matrix"
228 | ]
229 | },
230 | {
231 | "cell_type": "code",
232 | "execution_count": 14,
233 | "metadata": {
234 | "collapsed": false
235 | },
236 | "outputs": [
237 | {
238 | "name": "stdout",
239 | "output_type": "stream",
240 | "text": [
241 | " precision recall f1-score support\n",
242 | "\n",
243 | " 0 1.00 1.00 1.00 13\n",
244 | " 1 1.00 0.75 0.86 16\n",
245 | " 2 0.80 1.00 0.89 16\n",
246 | "\n",
247 | "avg / total 0.93 0.91 0.91 45\n",
248 | "\n"
249 | ]
250 | }
251 | ],
252 | "source": [
253 | "print(classification_report(y_test,iris_predictions))"
254 | ]
255 | },
256 | {
257 | "cell_type": "markdown",
258 | "metadata": {},
259 | "source": [
260 | "# Great Job!"
261 | ]
262 | }
263 | ],
264 | "metadata": {
265 | "kernelspec": {
266 | "display_name": "Python 3",
267 | "language": "python",
268 | "name": "python3"
269 | },
270 | "language_info": {
271 | "codemirror_mode": {
272 | "name": "ipython",
273 | "version": 3
274 | },
275 | "file_extension": ".py",
276 | "mimetype": "text/x-python",
277 | "name": "python",
278 | "nbconvert_exporter": "python",
279 | "pygments_lexer": "ipython3",
280 | "version": "3.5.1"
281 | }
282 | },
283 | "nbformat": 4,
284 | "nbformat_minor": 0
285 | }
286 |
--------------------------------------------------------------------------------
/Numpy/.ipynb_checkpoints/NumPy Notes-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 2
6 | }
7 |
--------------------------------------------------------------------------------
/Numpy/.ipynb_checkpoints/Numpy Exercise -checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "___\n",
8 | "\n",
9 | "
\n",
10 | "___"
11 | ]
12 | },
13 | {
14 | "cell_type": "markdown",
15 | "metadata": {},
16 | "source": [
17 | "# NumPy Exercises \n",
18 | "\n",
19 | "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."
20 | ]
21 | },
22 | {
23 | "cell_type": "markdown",
24 | "metadata": {},
25 | "source": [
26 | "#### Import NumPy as np"
27 | ]
28 | },
29 | {
30 | "cell_type": "code",
31 | "execution_count": 1,
32 | "metadata": {
33 | "collapsed": true
34 | },
35 | "outputs": [],
36 | "source": [
37 | "import numpy as np"
38 | ]
39 | },
40 | {
41 | "cell_type": "markdown",
42 | "metadata": {},
43 | "source": [
44 | "#### Create an array of 10 zeros "
45 | ]
46 | },
47 | {
48 | "cell_type": "code",
49 | "execution_count": 2,
50 | "metadata": {
51 | "collapsed": false
52 | },
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 | },
67 | {
68 | "cell_type": "markdown",
69 | "metadata": {},
70 | "source": [
71 | "#### Create an array of 10 ones"
72 | ]
73 | },
74 | {
75 | "cell_type": "code",
76 | "execution_count": 3,
77 | "metadata": {
78 | "collapsed": false
79 | },
80 | "outputs": [
81 | {
82 | "data": {
83 | "text/plain": [
84 | "array([ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])"
85 | ]
86 | },
87 | "execution_count": 3,
88 | "metadata": {},
89 | "output_type": "execute_result"
90 | }
91 | ],
92 | "source": []
93 | },
94 | {
95 | "cell_type": "markdown",
96 | "metadata": {},
97 | "source": [
98 | "#### Create an array of 10 fives"
99 | ]
100 | },
101 | {
102 | "cell_type": "code",
103 | "execution_count": 4,
104 | "metadata": {
105 | "collapsed": false
106 | },
107 | "outputs": [
108 | {
109 | "data": {
110 | "text/plain": [
111 | "array([ 5., 5., 5., 5., 5., 5., 5., 5., 5., 5.])"
112 | ]
113 | },
114 | "execution_count": 4,
115 | "metadata": {},
116 | "output_type": "execute_result"
117 | }
118 | ],
119 | "source": []
120 | },
121 | {
122 | "cell_type": "markdown",
123 | "metadata": {},
124 | "source": [
125 | "#### Create an array of the integers from 10 to 50"
126 | ]
127 | },
128 | {
129 | "cell_type": "code",
130 | "execution_count": 5,
131 | "metadata": {
132 | "collapsed": false
133 | },
134 | "outputs": [
135 | {
136 | "data": {
137 | "text/plain": [
138 | "array([10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,\n",
139 | " 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,\n",
140 | " 44, 45, 46, 47, 48, 49, 50])"
141 | ]
142 | },
143 | "execution_count": 5,
144 | "metadata": {},
145 | "output_type": "execute_result"
146 | }
147 | ],
148 | "source": []
149 | },
150 | {
151 | "cell_type": "markdown",
152 | "metadata": {},
153 | "source": [
154 | "#### Create an array of all the even integers from 10 to 50"
155 | ]
156 | },
157 | {
158 | "cell_type": "code",
159 | "execution_count": 6,
160 | "metadata": {
161 | "collapsed": false
162 | },
163 | "outputs": [
164 | {
165 | "data": {
166 | "text/plain": [
167 | "array([10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42,\n",
168 | " 44, 46, 48, 50])"
169 | ]
170 | },
171 | "execution_count": 6,
172 | "metadata": {},
173 | "output_type": "execute_result"
174 | }
175 | ],
176 | "source": []
177 | },
178 | {
179 | "cell_type": "markdown",
180 | "metadata": {},
181 | "source": [
182 | "#### Create a 3x3 matrix with values ranging from 0 to 8"
183 | ]
184 | },
185 | {
186 | "cell_type": "code",
187 | "execution_count": 7,
188 | "metadata": {
189 | "collapsed": false
190 | },
191 | "outputs": [
192 | {
193 | "data": {
194 | "text/plain": [
195 | "array([[0, 1, 2],\n",
196 | " [3, 4, 5],\n",
197 | " [6, 7, 8]])"
198 | ]
199 | },
200 | "execution_count": 7,
201 | "metadata": {},
202 | "output_type": "execute_result"
203 | }
204 | ],
205 | "source": []
206 | },
207 | {
208 | "cell_type": "markdown",
209 | "metadata": {},
210 | "source": [
211 | "#### Create a 3x3 identity matrix"
212 | ]
213 | },
214 | {
215 | "cell_type": "code",
216 | "execution_count": 8,
217 | "metadata": {
218 | "collapsed": false
219 | },
220 | "outputs": [
221 | {
222 | "data": {
223 | "text/plain": [
224 | "array([[ 1., 0., 0.],\n",
225 | " [ 0., 1., 0.],\n",
226 | " [ 0., 0., 1.]])"
227 | ]
228 | },
229 | "execution_count": 8,
230 | "metadata": {},
231 | "output_type": "execute_result"
232 | }
233 | ],
234 | "source": []
235 | },
236 | {
237 | "cell_type": "markdown",
238 | "metadata": {},
239 | "source": [
240 | "#### Use NumPy to generate a random number between 0 and 1"
241 | ]
242 | },
243 | {
244 | "cell_type": "code",
245 | "execution_count": 15,
246 | "metadata": {
247 | "collapsed": false
248 | },
249 | "outputs": [
250 | {
251 | "data": {
252 | "text/plain": [
253 | "array([ 0.42829726])"
254 | ]
255 | },
256 | "execution_count": 15,
257 | "metadata": {},
258 | "output_type": "execute_result"
259 | }
260 | ],
261 | "source": []
262 | },
263 | {
264 | "cell_type": "markdown",
265 | "metadata": {},
266 | "source": [
267 | "#### Use NumPy to generate an array of 25 random numbers sampled from a standard normal distribution"
268 | ]
269 | },
270 | {
271 | "cell_type": "code",
272 | "execution_count": 33,
273 | "metadata": {
274 | "collapsed": false
275 | },
276 | "outputs": [
277 | {
278 | "data": {
279 | "text/plain": [
280 | "array([ 1.32031013, 1.6798602 , -0.42985892, -1.53116655, 0.85753232,\n",
281 | " 0.87339938, 0.35668636, -1.47491157, 0.15349697, 0.99530727,\n",
282 | " -0.94865451, -1.69174783, 1.57525349, -0.70615234, 0.10991879,\n",
283 | " -0.49478947, 1.08279872, 0.76488333, -2.3039931 , 0.35401124,\n",
284 | " -0.45454399, -0.64754649, -0.29391671, 0.02339861, 0.38272124])"
285 | ]
286 | },
287 | "execution_count": 33,
288 | "metadata": {},
289 | "output_type": "execute_result"
290 | }
291 | ],
292 | "source": []
293 | },
294 | {
295 | "cell_type": "markdown",
296 | "metadata": {},
297 | "source": [
298 | "#### Create the following matrix:"
299 | ]
300 | },
301 | {
302 | "cell_type": "code",
303 | "execution_count": 35,
304 | "metadata": {
305 | "collapsed": false
306 | },
307 | "outputs": [
308 | {
309 | "data": {
310 | "text/plain": [
311 | "array([[ 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1 ],\n",
312 | " [ 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2 ],\n",
313 | " [ 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3 ],\n",
314 | " [ 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4 ],\n",
315 | " [ 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5 ],\n",
316 | " [ 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6 ],\n",
317 | " [ 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7 ],\n",
318 | " [ 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8 ],\n",
319 | " [ 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9 ],\n",
320 | " [ 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1. ]])"
321 | ]
322 | },
323 | "execution_count": 35,
324 | "metadata": {},
325 | "output_type": "execute_result"
326 | }
327 | ],
328 | "source": []
329 | },
330 | {
331 | "cell_type": "markdown",
332 | "metadata": {},
333 | "source": [
334 | "#### Create an array of 20 linearly spaced points between 0 and 1:"
335 | ]
336 | },
337 | {
338 | "cell_type": "code",
339 | "execution_count": 36,
340 | "metadata": {
341 | "collapsed": false
342 | },
343 | "outputs": [
344 | {
345 | "data": {
346 | "text/plain": [
347 | "array([ 0. , 0.05263158, 0.10526316, 0.15789474, 0.21052632,\n",
348 | " 0.26315789, 0.31578947, 0.36842105, 0.42105263, 0.47368421,\n",
349 | " 0.52631579, 0.57894737, 0.63157895, 0.68421053, 0.73684211,\n",
350 | " 0.78947368, 0.84210526, 0.89473684, 0.94736842, 1. ])"
351 | ]
352 | },
353 | "execution_count": 36,
354 | "metadata": {},
355 | "output_type": "execute_result"
356 | }
357 | ],
358 | "source": []
359 | },
360 | {
361 | "cell_type": "markdown",
362 | "metadata": {},
363 | "source": [
364 | "## Numpy Indexing and Selection\n",
365 | "\n",
366 | "Now you will be given a few matrices, and be asked to replicate the resulting matrix outputs:"
367 | ]
368 | },
369 | {
370 | "cell_type": "code",
371 | "execution_count": 38,
372 | "metadata": {
373 | "collapsed": false
374 | },
375 | "outputs": [
376 | {
377 | "data": {
378 | "text/plain": [
379 | "array([[ 1, 2, 3, 4, 5],\n",
380 | " [ 6, 7, 8, 9, 10],\n",
381 | " [11, 12, 13, 14, 15],\n",
382 | " [16, 17, 18, 19, 20],\n",
383 | " [21, 22, 23, 24, 25]])"
384 | ]
385 | },
386 | "execution_count": 38,
387 | "metadata": {},
388 | "output_type": "execute_result"
389 | }
390 | ],
391 | "source": [
392 | "mat = np.arange(1,26).reshape(5,5)\n",
393 | "mat"
394 | ]
395 | },
396 | {
397 | "cell_type": "code",
398 | "execution_count": 39,
399 | "metadata": {
400 | "collapsed": true
401 | },
402 | "outputs": [],
403 | "source": [
404 | "# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW\n",
405 | "# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
406 | "# BE ABLE TO SEE THE OUTPUT ANY MORE"
407 | ]
408 | },
409 | {
410 | "cell_type": "code",
411 | "execution_count": 40,
412 | "metadata": {
413 | "collapsed": false
414 | },
415 | "outputs": [
416 | {
417 | "data": {
418 | "text/plain": [
419 | "array([[12, 13, 14, 15],\n",
420 | " [17, 18, 19, 20],\n",
421 | " [22, 23, 24, 25]])"
422 | ]
423 | },
424 | "execution_count": 40,
425 | "metadata": {},
426 | "output_type": "execute_result"
427 | }
428 | ],
429 | "source": []
430 | },
431 | {
432 | "cell_type": "code",
433 | "execution_count": 29,
434 | "metadata": {
435 | "collapsed": true
436 | },
437 | "outputs": [],
438 | "source": [
439 | "# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW\n",
440 | "# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
441 | "# BE ABLE TO SEE THE OUTPUT ANY MORE"
442 | ]
443 | },
444 | {
445 | "cell_type": "code",
446 | "execution_count": 41,
447 | "metadata": {
448 | "collapsed": false
449 | },
450 | "outputs": [
451 | {
452 | "data": {
453 | "text/plain": [
454 | "20"
455 | ]
456 | },
457 | "execution_count": 41,
458 | "metadata": {},
459 | "output_type": "execute_result"
460 | }
461 | ],
462 | "source": []
463 | },
464 | {
465 | "cell_type": "code",
466 | "execution_count": 30,
467 | "metadata": {
468 | "collapsed": true
469 | },
470 | "outputs": [],
471 | "source": [
472 | "# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW\n",
473 | "# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
474 | "# BE ABLE TO SEE THE OUTPUT ANY MORE"
475 | ]
476 | },
477 | {
478 | "cell_type": "code",
479 | "execution_count": 42,
480 | "metadata": {
481 | "collapsed": false
482 | },
483 | "outputs": [
484 | {
485 | "data": {
486 | "text/plain": [
487 | "array([[ 2],\n",
488 | " [ 7],\n",
489 | " [12]])"
490 | ]
491 | },
492 | "execution_count": 42,
493 | "metadata": {},
494 | "output_type": "execute_result"
495 | }
496 | ],
497 | "source": []
498 | },
499 | {
500 | "cell_type": "code",
501 | "execution_count": 31,
502 | "metadata": {
503 | "collapsed": true
504 | },
505 | "outputs": [],
506 | "source": [
507 | "# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW\n",
508 | "# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
509 | "# BE ABLE TO SEE THE OUTPUT ANY MORE"
510 | ]
511 | },
512 | {
513 | "cell_type": "code",
514 | "execution_count": 46,
515 | "metadata": {
516 | "collapsed": false
517 | },
518 | "outputs": [
519 | {
520 | "data": {
521 | "text/plain": [
522 | "array([21, 22, 23, 24, 25])"
523 | ]
524 | },
525 | "execution_count": 46,
526 | "metadata": {},
527 | "output_type": "execute_result"
528 | }
529 | ],
530 | "source": []
531 | },
532 | {
533 | "cell_type": "code",
534 | "execution_count": 32,
535 | "metadata": {
536 | "collapsed": true
537 | },
538 | "outputs": [],
539 | "source": [
540 | "# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW\n",
541 | "# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
542 | "# BE ABLE TO SEE THE OUTPUT ANY MORE"
543 | ]
544 | },
545 | {
546 | "cell_type": "code",
547 | "execution_count": 49,
548 | "metadata": {
549 | "collapsed": false
550 | },
551 | "outputs": [
552 | {
553 | "data": {
554 | "text/plain": [
555 | "array([[16, 17, 18, 19, 20],\n",
556 | " [21, 22, 23, 24, 25]])"
557 | ]
558 | },
559 | "execution_count": 49,
560 | "metadata": {},
561 | "output_type": "execute_result"
562 | }
563 | ],
564 | "source": []
565 | },
566 | {
567 | "cell_type": "markdown",
568 | "metadata": {},
569 | "source": [
570 | "### Now do the following"
571 | ]
572 | },
573 | {
574 | "cell_type": "markdown",
575 | "metadata": {},
576 | "source": [
577 | "#### Get the sum of all the values in mat"
578 | ]
579 | },
580 | {
581 | "cell_type": "code",
582 | "execution_count": 50,
583 | "metadata": {
584 | "collapsed": false
585 | },
586 | "outputs": [
587 | {
588 | "data": {
589 | "text/plain": [
590 | "325"
591 | ]
592 | },
593 | "execution_count": 50,
594 | "metadata": {},
595 | "output_type": "execute_result"
596 | }
597 | ],
598 | "source": []
599 | },
600 | {
601 | "cell_type": "markdown",
602 | "metadata": {},
603 | "source": [
604 | "#### Get the standard deviation of the values in mat"
605 | ]
606 | },
607 | {
608 | "cell_type": "code",
609 | "execution_count": 51,
610 | "metadata": {
611 | "collapsed": false
612 | },
613 | "outputs": [
614 | {
615 | "data": {
616 | "text/plain": [
617 | "7.2111025509279782"
618 | ]
619 | },
620 | "execution_count": 51,
621 | "metadata": {},
622 | "output_type": "execute_result"
623 | }
624 | ],
625 | "source": []
626 | },
627 | {
628 | "cell_type": "markdown",
629 | "metadata": {},
630 | "source": [
631 | "#### Get the sum of all the columns in mat"
632 | ]
633 | },
634 | {
635 | "cell_type": "code",
636 | "execution_count": 53,
637 | "metadata": {
638 | "collapsed": false
639 | },
640 | "outputs": [
641 | {
642 | "data": {
643 | "text/plain": [
644 | "array([55, 60, 65, 70, 75])"
645 | ]
646 | },
647 | "execution_count": 53,
648 | "metadata": {},
649 | "output_type": "execute_result"
650 | }
651 | ],
652 | "source": []
653 | },
654 | {
655 | "cell_type": "markdown",
656 | "metadata": {
657 | "collapsed": true
658 | },
659 | "source": [
660 | "# Great Job!"
661 | ]
662 | }
663 | ],
664 | "metadata": {
665 | "kernelspec": {
666 | "display_name": "Python 3",
667 | "language": "python",
668 | "name": "python3"
669 | },
670 | "language_info": {
671 | "codemirror_mode": {
672 | "name": "ipython",
673 | "version": 3
674 | },
675 | "file_extension": ".py",
676 | "mimetype": "text/x-python",
677 | "name": "python",
678 | "nbconvert_exporter": "python",
679 | "pygments_lexer": "ipython3",
680 | "version": "3.6.0"
681 | }
682 | },
683 | "nbformat": 4,
684 | "nbformat_minor": 0
685 | }
686 |
--------------------------------------------------------------------------------
/Numpy/NumPy Notes.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": true
8 | },
9 | "outputs": [],
10 | "source": [
11 | "import numpy as np"
12 | ]
13 | },
14 | {
15 | "cell_type": "code",
16 | "execution_count": 2,
17 | "metadata": {
18 | "collapsed": true
19 | },
20 | "outputs": [],
21 | "source": [
22 | "my_list = [1,2,3]"
23 | ]
24 | },
25 | {
26 | "cell_type": "code",
27 | "execution_count": 3,
28 | "metadata": {
29 | "collapsed": false
30 | },
31 | "outputs": [
32 | {
33 | "data": {
34 | "text/plain": [
35 | "[1, 2, 3]"
36 | ]
37 | },
38 | "execution_count": 3,
39 | "metadata": {},
40 | "output_type": "execute_result"
41 | }
42 | ],
43 | "source": [
44 | "my_list"
45 | ]
46 | },
47 | {
48 | "cell_type": "markdown",
49 | "metadata": {},
50 | "source": [
51 | "arr = np.array(my_list)"
52 | ]
53 | },
54 | {
55 | "cell_type": "code",
56 | "execution_count": 10,
57 | "metadata": {
58 | "collapsed": true
59 | },
60 | "outputs": [],
61 | "source": [
62 | "my_matrix = [[1,2,3],[4,5,6],[7,8,9]]"
63 | ]
64 | },
65 | {
66 | "cell_type": "markdown",
67 | "metadata": {},
68 | "source": [
69 | "# Instantiating a basic Array"
70 | ]
71 | },
72 | {
73 | "cell_type": "code",
74 | "execution_count": 34,
75 | "metadata": {
76 | "collapsed": false
77 | },
78 | "outputs": [],
79 | "source": [
80 | "my_matrix = np.array(my_matrix)"
81 | ]
82 | },
83 | {
84 | "cell_type": "code",
85 | "execution_count": 13,
86 | "metadata": {
87 | "collapsed": false
88 | },
89 | "outputs": [
90 | {
91 | "data": {
92 | "text/plain": [
93 | "array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])"
94 | ]
95 | },
96 | "execution_count": 13,
97 | "metadata": {},
98 | "output_type": "execute_result"
99 | }
100 | ],
101 | "source": [
102 | "np.arange(0,10)"
103 | ]
104 | },
105 | {
106 | "cell_type": "markdown",
107 | "metadata": {},
108 | "source": [
109 | "# Instatiating a zero Array"
110 | ]
111 | },
112 | {
113 | "cell_type": "code",
114 | "execution_count": 16,
115 | "metadata": {
116 | "collapsed": false
117 | },
118 | "outputs": [
119 | {
120 | "data": {
121 | "text/plain": [
122 | "array([[ 0., 0., 0., 0., 0.],\n",
123 | " [ 0., 0., 0., 0., 0.],\n",
124 | " [ 0., 0., 0., 0., 0.],\n",
125 | " [ 0., 0., 0., 0., 0.],\n",
126 | " [ 0., 0., 0., 0., 0.]])"
127 | ]
128 | },
129 | "execution_count": 16,
130 | "metadata": {},
131 | "output_type": "execute_result"
132 | }
133 | ],
134 | "source": [
135 | "np.zeros((5,5))"
136 | ]
137 | },
138 | {
139 | "cell_type": "markdown",
140 | "metadata": {},
141 | "source": [
142 | "# This is to instating an EVEN spaced matrix, of 10 rows"
143 | ]
144 | },
145 | {
146 | "cell_type": "code",
147 | "execution_count": 15,
148 | "metadata": {
149 | "collapsed": false
150 | },
151 | "outputs": [
152 | {
153 | "data": {
154 | "text/plain": [
155 | "array([ 0. , 0.55555556, 1.11111111, 1.66666667, 2.22222222,\n",
156 | " 2.77777778, 3.33333333, 3.88888889, 4.44444444, 5. ])"
157 | ]
158 | },
159 | "execution_count": 15,
160 | "metadata": {},
161 | "output_type": "execute_result"
162 | }
163 | ],
164 | "source": [
165 | "np.linspace(0,5,10)"
166 | ]
167 | },
168 | {
169 | "cell_type": "code",
170 | "execution_count": 19,
171 | "metadata": {
172 | "collapsed": false
173 | },
174 | "outputs": [],
175 | "source": [
176 | "arr = np.arange(25)"
177 | ]
178 | },
179 | {
180 | "cell_type": "code",
181 | "execution_count": 22,
182 | "metadata": {
183 | "collapsed": true
184 | },
185 | "outputs": [],
186 | "source": [
187 | "ranarr = np.random.randint(0,50,10)"
188 | ]
189 | },
190 | {
191 | "cell_type": "markdown",
192 | "metadata": {},
193 | "source": [
194 | "# RESHAPING is useful, you are changing the dimensions of a n x m list or array into a new array"
195 | ]
196 | },
197 | {
198 | "cell_type": "code",
199 | "execution_count": 26,
200 | "metadata": {
201 | "collapsed": false
202 | },
203 | "outputs": [],
204 | "source": [
205 | "arr = arr.reshape(5,5)"
206 | ]
207 | },
208 | {
209 | "cell_type": "code",
210 | "execution_count": 30,
211 | "metadata": {
212 | "collapsed": false
213 | },
214 | "outputs": [
215 | {
216 | "data": {
217 | "text/plain": [
218 | "(5, 5)"
219 | ]
220 | },
221 | "execution_count": 30,
222 | "metadata": {},
223 | "output_type": "execute_result"
224 | }
225 | ],
226 | "source": [
227 | "arr.shape"
228 | ]
229 | },
230 | {
231 | "cell_type": "code",
232 | "execution_count": 31,
233 | "metadata": {
234 | "collapsed": true
235 | },
236 | "outputs": [],
237 | "source": [
238 | "# Note here, the index is the MATRIX ROW in some caseas"
239 | ]
240 | },
241 | {
242 | "cell_type": "code",
243 | "execution_count": 37,
244 | "metadata": {
245 | "collapsed": false
246 | },
247 | "outputs": [
248 | {
249 | "data": {
250 | "text/plain": [
251 | "array([[1, 2, 3],\n",
252 | " [4, 5, 6],\n",
253 | " [7, 8, 9]])"
254 | ]
255 | },
256 | "execution_count": 37,
257 | "metadata": {},
258 | "output_type": "execute_result"
259 | }
260 | ],
261 | "source": [
262 | "my_matrix[0:3]"
263 | ]
264 | },
265 | {
266 | "cell_type": "code",
267 | "execution_count": 39,
268 | "metadata": {
269 | "collapsed": false
270 | },
271 | "outputs": [
272 | {
273 | "data": {
274 | "text/plain": [
275 | "3"
276 | ]
277 | },
278 | "execution_count": 39,
279 | "metadata": {},
280 | "output_type": "execute_result"
281 | }
282 | ],
283 | "source": [
284 | "my_matrix[0][2]\n",
285 | "#is the same as\n",
286 | "my_matrix[0,2]"
287 | ]
288 | },
289 | {
290 | "cell_type": "markdown",
291 | "metadata": {},
292 | "source": [
293 | "# This is important - to get the specifics on a certain allocation"
294 | ]
295 | },
296 | {
297 | "cell_type": "code",
298 | "execution_count": 38,
299 | "metadata": {
300 | "collapsed": false
301 | },
302 | "outputs": [
303 | {
304 | "data": {
305 | "text/plain": [
306 | "array([[3],\n",
307 | " [6]])"
308 | ]
309 | },
310 | "execution_count": 38,
311 | "metadata": {},
312 | "output_type": "execute_result"
313 | }
314 | ],
315 | "source": [
316 | "my_matrix[:2,2:]"
317 | ]
318 | },
319 | {
320 | "cell_type": "markdown",
321 | "metadata": {},
322 | "source": [
323 | "# Conditional Selection is REALLY Important"
324 | ]
325 | },
326 | {
327 | "cell_type": "code",
328 | "execution_count": 41,
329 | "metadata": {
330 | "collapsed": true
331 | },
332 | "outputs": [],
333 | "source": [
334 | "c_array = np.arange(1,11)"
335 | ]
336 | },
337 | {
338 | "cell_type": "code",
339 | "execution_count": 42,
340 | "metadata": {
341 | "collapsed": false
342 | },
343 | "outputs": [
344 | {
345 | "data": {
346 | "text/plain": [
347 | "array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])"
348 | ]
349 | },
350 | "execution_count": 42,
351 | "metadata": {},
352 | "output_type": "execute_result"
353 | }
354 | ],
355 | "source": [
356 | "c_array"
357 | ]
358 | },
359 | {
360 | "cell_type": "code",
361 | "execution_count": 43,
362 | "metadata": {
363 | "collapsed": false
364 | },
365 | "outputs": [
366 | {
367 | "data": {
368 | "text/plain": [
369 | "array([False, False, False, False, False, True, True, True, True, True], dtype=bool)"
370 | ]
371 | },
372 | "execution_count": 43,
373 | "metadata": {},
374 | "output_type": "execute_result"
375 | }
376 | ],
377 | "source": [
378 | "c_array > 5"
379 | ]
380 | },
381 | {
382 | "cell_type": "code",
383 | "execution_count": 44,
384 | "metadata": {
385 | "collapsed": false
386 | },
387 | "outputs": [
388 | {
389 | "data": {
390 | "text/plain": [
391 | "array([ 6, 7, 8, 9, 10])"
392 | ]
393 | },
394 | "execution_count": 44,
395 | "metadata": {},
396 | "output_type": "execute_result"
397 | }
398 | ],
399 | "source": [
400 | "# This allows you to get positions where something is TRUE!\n",
401 | "c_array[c_array > 5]"
402 | ]
403 | },
404 | {
405 | "cell_type": "markdown",
406 | "metadata": {},
407 | "source": [
408 | "# Numpy OPERATIONS"
409 | ]
410 | },
411 | {
412 | "cell_type": "code",
413 | "execution_count": 46,
414 | "metadata": {
415 | "collapsed": false
416 | },
417 | "outputs": [
418 | {
419 | "data": {
420 | "text/plain": [
421 | "10"
422 | ]
423 | },
424 | "execution_count": 46,
425 | "metadata": {},
426 | "output_type": "execute_result"
427 | }
428 | ],
429 | "source": [
430 | "np.max(c_array)"
431 | ]
432 | },
433 | {
434 | "cell_type": "code",
435 | "execution_count": null,
436 | "metadata": {
437 | "collapsed": true
438 | },
439 | "outputs": [],
440 | "source": []
441 | }
442 | ],
443 | "metadata": {
444 | "kernelspec": {
445 | "display_name": "Python 3",
446 | "language": "python",
447 | "name": "python3"
448 | },
449 | "language_info": {
450 | "codemirror_mode": {
451 | "name": "ipython",
452 | "version": 3
453 | },
454 | "file_extension": ".py",
455 | "mimetype": "text/x-python",
456 | "name": "python",
457 | "nbconvert_exporter": "python",
458 | "pygments_lexer": "ipython3",
459 | "version": "3.6.0"
460 | }
461 | },
462 | "nbformat": 4,
463 | "nbformat_minor": 2
464 | }
465 |
--------------------------------------------------------------------------------
/Numpy/Numpy Exercise .ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "___\n",
8 | "\n",
9 | "
\n",
10 | "___"
11 | ]
12 | },
13 | {
14 | "cell_type": "markdown",
15 | "metadata": {},
16 | "source": [
17 | "# NumPy Exercises \n",
18 | "\n",
19 | "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."
20 | ]
21 | },
22 | {
23 | "cell_type": "markdown",
24 | "metadata": {},
25 | "source": [
26 | "#### Import NumPy as np"
27 | ]
28 | },
29 | {
30 | "cell_type": "code",
31 | "execution_count": 1,
32 | "metadata": {
33 | "collapsed": true
34 | },
35 | "outputs": [],
36 | "source": [
37 | "import numpy as np"
38 | ]
39 | },
40 | {
41 | "cell_type": "markdown",
42 | "metadata": {},
43 | "source": [
44 | "#### Create an array of 10 zeros "
45 | ]
46 | },
47 | {
48 | "cell_type": "code",
49 | "execution_count": 3,
50 | "metadata": {
51 | "collapsed": false
52 | },
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": 3,
61 | "metadata": {},
62 | "output_type": "execute_result"
63 | }
64 | ],
65 | "source": [
66 | "arr = np.zeros(10)\n",
67 | "arr"
68 | ]
69 | },
70 | {
71 | "cell_type": "markdown",
72 | "metadata": {},
73 | "source": [
74 | "#### Create an array of 10 ones"
75 | ]
76 | },
77 | {
78 | "cell_type": "code",
79 | "execution_count": 5,
80 | "metadata": {
81 | "collapsed": false
82 | },
83 | "outputs": [
84 | {
85 | "data": {
86 | "text/plain": [
87 | "array([ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])"
88 | ]
89 | },
90 | "execution_count": 5,
91 | "metadata": {},
92 | "output_type": "execute_result"
93 | }
94 | ],
95 | "source": [
96 | "arr = np.ones(10)\n",
97 | "arr"
98 | ]
99 | },
100 | {
101 | "cell_type": "markdown",
102 | "metadata": {},
103 | "source": [
104 | "#### Create an array of 10 fives"
105 | ]
106 | },
107 | {
108 | "cell_type": "code",
109 | "execution_count": 7,
110 | "metadata": {
111 | "collapsed": false
112 | },
113 | "outputs": [
114 | {
115 | "data": {
116 | "text/plain": [
117 | "array([ 5., 5., 5., 5., 5., 5., 5., 5., 5., 5.])"
118 | ]
119 | },
120 | "execution_count": 7,
121 | "metadata": {},
122 | "output_type": "execute_result"
123 | }
124 | ],
125 | "source": [
126 | "arr = np.ones(10)*5\n",
127 | "arr"
128 | ]
129 | },
130 | {
131 | "cell_type": "markdown",
132 | "metadata": {},
133 | "source": [
134 | "#### Create an array of the integers from 10 to 50"
135 | ]
136 | },
137 | {
138 | "cell_type": "code",
139 | "execution_count": 9,
140 | "metadata": {
141 | "collapsed": false
142 | },
143 | "outputs": [
144 | {
145 | "data": {
146 | "text/plain": [
147 | "array([10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,\n",
148 | " 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,\n",
149 | " 44, 45, 46, 47, 48, 49, 50])"
150 | ]
151 | },
152 | "execution_count": 9,
153 | "metadata": {},
154 | "output_type": "execute_result"
155 | }
156 | ],
157 | "source": [
158 | "arr = np.arange(10,51)\n",
159 | "arr"
160 | ]
161 | },
162 | {
163 | "cell_type": "markdown",
164 | "metadata": {},
165 | "source": [
166 | "#### Create an array of all the even integers from 10 to 50"
167 | ]
168 | },
169 | {
170 | "cell_type": "code",
171 | "execution_count": 11,
172 | "metadata": {
173 | "collapsed": false
174 | },
175 | "outputs": [
176 | {
177 | "data": {
178 | "text/plain": [
179 | "array([10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42,\n",
180 | " 44, 46, 48, 50])"
181 | ]
182 | },
183 | "execution_count": 11,
184 | "metadata": {},
185 | "output_type": "execute_result"
186 | }
187 | ],
188 | "source": [
189 | "arr = np.arange(10,51,2)\n",
190 | "arr"
191 | ]
192 | },
193 | {
194 | "cell_type": "markdown",
195 | "metadata": {},
196 | "source": [
197 | "#### Create a 3x3 matrix with values ranging from 0 to 8"
198 | ]
199 | },
200 | {
201 | "cell_type": "code",
202 | "execution_count": 14,
203 | "metadata": {
204 | "collapsed": false
205 | },
206 | "outputs": [
207 | {
208 | "data": {
209 | "text/plain": [
210 | "array([[0, 1, 2],\n",
211 | " [3, 4, 5],\n",
212 | " [6, 7, 8]])"
213 | ]
214 | },
215 | "execution_count": 14,
216 | "metadata": {},
217 | "output_type": "execute_result"
218 | }
219 | ],
220 | "source": [
221 | "arr = np.arange(0,9).reshape(3,3)\n",
222 | "arr"
223 | ]
224 | },
225 | {
226 | "cell_type": "markdown",
227 | "metadata": {},
228 | "source": [
229 | "#### Create a 3x3 identity matrix"
230 | ]
231 | },
232 | {
233 | "cell_type": "code",
234 | "execution_count": 16,
235 | "metadata": {
236 | "collapsed": false
237 | },
238 | "outputs": [
239 | {
240 | "data": {
241 | "text/plain": [
242 | "array([[ 1., 0., 0.],\n",
243 | " [ 0., 1., 0.],\n",
244 | " [ 0., 0., 1.]])"
245 | ]
246 | },
247 | "execution_count": 16,
248 | "metadata": {},
249 | "output_type": "execute_result"
250 | }
251 | ],
252 | "source": [
253 | "arr = np.identity(3)\n",
254 | "arr"
255 | ]
256 | },
257 | {
258 | "cell_type": "markdown",
259 | "metadata": {},
260 | "source": [
261 | "#### Use NumPy to generate a random number between 0 and 1"
262 | ]
263 | },
264 | {
265 | "cell_type": "code",
266 | "execution_count": 24,
267 | "metadata": {
268 | "collapsed": false
269 | },
270 | "outputs": [
271 | {
272 | "data": {
273 | "text/plain": [
274 | "array([], shape=(0, 1), dtype=float64)"
275 | ]
276 | },
277 | "execution_count": 24,
278 | "metadata": {},
279 | "output_type": "execute_result"
280 | }
281 | ],
282 | "source": [
283 | "num = np.random.rand(0,1)\n",
284 | "num"
285 | ]
286 | },
287 | {
288 | "cell_type": "markdown",
289 | "metadata": {},
290 | "source": [
291 | "#### Use NumPy to generate an array of 25 random numbers sampled from a standard normal distribution"
292 | ]
293 | },
294 | {
295 | "cell_type": "code",
296 | "execution_count": 29,
297 | "metadata": {
298 | "collapsed": false
299 | },
300 | "outputs": [
301 | {
302 | "data": {
303 | "text/plain": [
304 | "array([ 0.85929951, -0.73424028, -0.66743855, -1.12014024, 0.14921427,\n",
305 | " -1.39291747, 0.48998068, 0.06508304, -0.94324407, 0.56841866,\n",
306 | " 0.19042924, 1.49407052, -0.96509842, 0.39839176, -0.66135731,\n",
307 | " -0.4383768 , -0.1072717 , -0.47950802, -0.40180186, -0.63680173,\n",
308 | " 0.10564819, -0.05918523, -0.04572078, 0.58041 , -1.8703772 ])"
309 | ]
310 | },
311 | "execution_count": 29,
312 | "metadata": {},
313 | "output_type": "execute_result"
314 | }
315 | ],
316 | "source": [
317 | "arr = np.random.randn(25)\n",
318 | "arr"
319 | ]
320 | },
321 | {
322 | "cell_type": "markdown",
323 | "metadata": {},
324 | "source": [
325 | "#### Create the following matrix:"
326 | ]
327 | },
328 | {
329 | "cell_type": "code",
330 | "execution_count": 65,
331 | "metadata": {
332 | "collapsed": false
333 | },
334 | "outputs": [
335 | {
336 | "data": {
337 | "text/plain": [
338 | "array([ 0. , 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08,\n",
339 | " 0.09, 0.1 , 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17,\n",
340 | " 0.18, 0.19, 0.2 , 0.21, 0.22, 0.23, 0.24, 0.25, 0.26,\n",
341 | " 0.27, 0.28, 0.29, 0.3 , 0.31, 0.32, 0.33, 0.34, 0.35,\n",
342 | " 0.36, 0.37, 0.38, 0.39, 0.4 , 0.41, 0.42, 0.43, 0.44,\n",
343 | " 0.45, 0.46, 0.47, 0.48, 0.49, 0.5 , 0.51, 0.52, 0.53,\n",
344 | " 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6 , 0.61, 0.62,\n",
345 | " 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7 , 0.71,\n",
346 | " 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8 ,\n",
347 | " 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89,\n",
348 | " 0.9 , 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98,\n",
349 | " 0.99, 1. ])"
350 | ]
351 | },
352 | "execution_count": 65,
353 | "metadata": {},
354 | "output_type": "execute_result"
355 | }
356 | ],
357 | "source": [
358 | "arr = np.arange(0,1.01,0.01)\n",
359 | "arr"
360 | ]
361 | },
362 | {
363 | "cell_type": "markdown",
364 | "metadata": {},
365 | "source": [
366 | "#### Create an array of 20 linearly spaced points between 0 and 1:"
367 | ]
368 | },
369 | {
370 | "cell_type": "code",
371 | "execution_count": 31,
372 | "metadata": {
373 | "collapsed": false
374 | },
375 | "outputs": [
376 | {
377 | "data": {
378 | "text/plain": [
379 | "array([ 0. , 0.05263158, 0.10526316, 0.15789474, 0.21052632,\n",
380 | " 0.26315789, 0.31578947, 0.36842105, 0.42105263, 0.47368421,\n",
381 | " 0.52631579, 0.57894737, 0.63157895, 0.68421053, 0.73684211,\n",
382 | " 0.78947368, 0.84210526, 0.89473684, 0.94736842, 1. ])"
383 | ]
384 | },
385 | "execution_count": 31,
386 | "metadata": {},
387 | "output_type": "execute_result"
388 | }
389 | ],
390 | "source": [
391 | "arr = np.linspace(0,1,20)\n",
392 | "arr"
393 | ]
394 | },
395 | {
396 | "cell_type": "markdown",
397 | "metadata": {},
398 | "source": [
399 | "## Numpy Indexing and Selection\n",
400 | "\n",
401 | "Now you will be given a few matrices, and be asked to replicate the resulting matrix outputs:"
402 | ]
403 | },
404 | {
405 | "cell_type": "code",
406 | "execution_count": 44,
407 | "metadata": {
408 | "collapsed": false
409 | },
410 | "outputs": [
411 | {
412 | "data": {
413 | "text/plain": [
414 | "array([[ 1, 2, 3, 4, 5],\n",
415 | " [ 6, 7, 8, 9, 10],\n",
416 | " [11, 12, 13, 14, 15],\n",
417 | " [16, 17, 18, 19, 20],\n",
418 | " [21, 22, 23, 24, 25]])"
419 | ]
420 | },
421 | "execution_count": 44,
422 | "metadata": {},
423 | "output_type": "execute_result"
424 | }
425 | ],
426 | "source": [
427 | "mat = np.arange(1,26).reshape(5,5)\n",
428 | "mat"
429 | ]
430 | },
431 | {
432 | "cell_type": "code",
433 | "execution_count": 47,
434 | "metadata": {
435 | "collapsed": false
436 | },
437 | "outputs": [
438 | {
439 | "data": {
440 | "text/plain": [
441 | "array([[11, 12, 13, 14, 15],\n",
442 | " [16, 17, 18, 19, 20],\n",
443 | " [21, 22, 23, 24, 25]])"
444 | ]
445 | },
446 | "execution_count": 47,
447 | "metadata": {},
448 | "output_type": "execute_result"
449 | }
450 | ],
451 | "source": [
452 | "# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW\n",
453 | "# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
454 | "# BE ABLE TO SEE THE OUTPUT ANY MORE\n",
455 | "mat[2:,]\n"
456 | ]
457 | },
458 | {
459 | "cell_type": "code",
460 | "execution_count": 40,
461 | "metadata": {
462 | "collapsed": false
463 | },
464 | "outputs": [
465 | {
466 | "data": {
467 | "text/plain": [
468 | "array([[12, 13, 14, 15],\n",
469 | " [17, 18, 19, 20],\n",
470 | " [22, 23, 24, 25]])"
471 | ]
472 | },
473 | "execution_count": 40,
474 | "metadata": {},
475 | "output_type": "execute_result"
476 | }
477 | ],
478 | "source": []
479 | },
480 | {
481 | "cell_type": "code",
482 | "execution_count": 48,
483 | "metadata": {
484 | "collapsed": false
485 | },
486 | "outputs": [
487 | {
488 | "data": {
489 | "text/plain": [
490 | "20"
491 | ]
492 | },
493 | "execution_count": 48,
494 | "metadata": {},
495 | "output_type": "execute_result"
496 | }
497 | ],
498 | "source": [
499 | "# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW\n",
500 | "# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
501 | "# BE ABLE TO SEE THE OUTPUT ANY MORE\n",
502 | "mat[3][4]"
503 | ]
504 | },
505 | {
506 | "cell_type": "code",
507 | "execution_count": 41,
508 | "metadata": {
509 | "collapsed": false
510 | },
511 | "outputs": [
512 | {
513 | "data": {
514 | "text/plain": [
515 | "20"
516 | ]
517 | },
518 | "execution_count": 41,
519 | "metadata": {},
520 | "output_type": "execute_result"
521 | }
522 | ],
523 | "source": []
524 | },
525 | {
526 | "cell_type": "code",
527 | "execution_count": 54,
528 | "metadata": {
529 | "collapsed": false
530 | },
531 | "outputs": [
532 | {
533 | "data": {
534 | "text/plain": [
535 | "array([[ 2],\n",
536 | " [ 7],\n",
537 | " [12]])"
538 | ]
539 | },
540 | "execution_count": 54,
541 | "metadata": {},
542 | "output_type": "execute_result"
543 | }
544 | ],
545 | "source": [
546 | "# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW\n",
547 | "# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
548 | "# BE ABLE TO SEE THE OUTPUT ANY MORE\n",
549 | "mat[0:3,1].reshape(3,1)"
550 | ]
551 | },
552 | {
553 | "cell_type": "code",
554 | "execution_count": 42,
555 | "metadata": {
556 | "collapsed": false
557 | },
558 | "outputs": [
559 | {
560 | "data": {
561 | "text/plain": [
562 | "array([[ 2],\n",
563 | " [ 7],\n",
564 | " [12]])"
565 | ]
566 | },
567 | "execution_count": 42,
568 | "metadata": {},
569 | "output_type": "execute_result"
570 | }
571 | ],
572 | "source": []
573 | },
574 | {
575 | "cell_type": "code",
576 | "execution_count": 55,
577 | "metadata": {
578 | "collapsed": false
579 | },
580 | "outputs": [
581 | {
582 | "data": {
583 | "text/plain": [
584 | "array([21, 22, 23, 24, 25])"
585 | ]
586 | },
587 | "execution_count": 55,
588 | "metadata": {},
589 | "output_type": "execute_result"
590 | }
591 | ],
592 | "source": [
593 | "# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW\n",
594 | "# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
595 | "# BE ABLE TO SEE THE OUTPUT ANY MORE\n",
596 | "mat[4,]"
597 | ]
598 | },
599 | {
600 | "cell_type": "code",
601 | "execution_count": 46,
602 | "metadata": {
603 | "collapsed": false
604 | },
605 | "outputs": [
606 | {
607 | "data": {
608 | "text/plain": [
609 | "array([21, 22, 23, 24, 25])"
610 | ]
611 | },
612 | "execution_count": 46,
613 | "metadata": {},
614 | "output_type": "execute_result"
615 | }
616 | ],
617 | "source": []
618 | },
619 | {
620 | "cell_type": "code",
621 | "execution_count": 56,
622 | "metadata": {
623 | "collapsed": false
624 | },
625 | "outputs": [
626 | {
627 | "data": {
628 | "text/plain": [
629 | "array([[16, 17, 18, 19, 20],\n",
630 | " [21, 22, 23, 24, 25]])"
631 | ]
632 | },
633 | "execution_count": 56,
634 | "metadata": {},
635 | "output_type": "execute_result"
636 | }
637 | ],
638 | "source": [
639 | "# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW\n",
640 | "# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
641 | "# BE ABLE TO SEE THE OUTPUT ANY MORE\n",
642 | "mat[3:,]"
643 | ]
644 | },
645 | {
646 | "cell_type": "code",
647 | "execution_count": 49,
648 | "metadata": {
649 | "collapsed": false
650 | },
651 | "outputs": [
652 | {
653 | "data": {
654 | "text/plain": [
655 | "array([[16, 17, 18, 19, 20],\n",
656 | " [21, 22, 23, 24, 25]])"
657 | ]
658 | },
659 | "execution_count": 49,
660 | "metadata": {},
661 | "output_type": "execute_result"
662 | }
663 | ],
664 | "source": []
665 | },
666 | {
667 | "cell_type": "markdown",
668 | "metadata": {},
669 | "source": [
670 | "### Now do the following"
671 | ]
672 | },
673 | {
674 | "cell_type": "markdown",
675 | "metadata": {},
676 | "source": [
677 | "#### Get the sum of all the values in mat"
678 | ]
679 | },
680 | {
681 | "cell_type": "code",
682 | "execution_count": 57,
683 | "metadata": {
684 | "collapsed": false
685 | },
686 | "outputs": [
687 | {
688 | "data": {
689 | "text/plain": [
690 | "325"
691 | ]
692 | },
693 | "execution_count": 57,
694 | "metadata": {},
695 | "output_type": "execute_result"
696 | }
697 | ],
698 | "source": [
699 | "mat.sum()"
700 | ]
701 | },
702 | {
703 | "cell_type": "markdown",
704 | "metadata": {},
705 | "source": [
706 | "#### Get the standard deviation of the values in mat"
707 | ]
708 | },
709 | {
710 | "cell_type": "code",
711 | "execution_count": 58,
712 | "metadata": {
713 | "collapsed": false
714 | },
715 | "outputs": [
716 | {
717 | "data": {
718 | "text/plain": [
719 | "7.2111025509279782"
720 | ]
721 | },
722 | "execution_count": 58,
723 | "metadata": {},
724 | "output_type": "execute_result"
725 | }
726 | ],
727 | "source": [
728 | "mat.std()"
729 | ]
730 | },
731 | {
732 | "cell_type": "markdown",
733 | "metadata": {},
734 | "source": [
735 | "#### Get the sum of all the columns in mat"
736 | ]
737 | },
738 | {
739 | "cell_type": "code",
740 | "execution_count": 63,
741 | "metadata": {
742 | "collapsed": false
743 | },
744 | "outputs": [
745 | {
746 | "data": {
747 | "text/plain": [
748 | "array([ 15, 40, 65, 90, 115])"
749 | ]
750 | },
751 | "execution_count": 63,
752 | "metadata": {},
753 | "output_type": "execute_result"
754 | }
755 | ],
756 | "source": [
757 | "mat.sum(axis=1)"
758 | ]
759 | },
760 | {
761 | "cell_type": "markdown",
762 | "metadata": {
763 | "collapsed": true
764 | },
765 | "source": [
766 | "# Great Job!"
767 | ]
768 | }
769 | ],
770 | "metadata": {
771 | "kernelspec": {
772 | "display_name": "Python 3",
773 | "language": "python",
774 | "name": "python3"
775 | },
776 | "language_info": {
777 | "codemirror_mode": {
778 | "name": "ipython",
779 | "version": 3
780 | },
781 | "file_extension": ".py",
782 | "mimetype": "text/x-python",
783 | "name": "python",
784 | "nbconvert_exporter": "python",
785 | "pygments_lexer": "ipython3",
786 | "version": "3.6.0"
787 | }
788 | },
789 | "nbformat": 4,
790 | "nbformat_minor": 0
791 | }
792 |
--------------------------------------------------------------------------------
/Pandas/Excel_Sample.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pasteurtran/Udemy_Python_for_Data_Science/88988a2173bd8b68533109fc9543ca6b5332c67e/Pandas/Excel_Sample.xlsx
--------------------------------------------------------------------------------
/Pandas/Output_Excel_Sample:
--------------------------------------------------------------------------------
1 | a,b,c,d
2 | 0,1,2,3
3 | 4,5,6,7
4 | 8,9,10,11
5 | 12,13,14,15
6 |
--------------------------------------------------------------------------------
/Pandas/Pandas Built-in Data Viz/df2:
--------------------------------------------------------------------------------
1 | a,b,c,d
2 | 0.039761986133905136,0.2185172274750622,0.10342298051665423,0.9579042338107532
3 | 0.9372879037285884,0.04156728027953449,0.8991254222382951,0.9776795571253272
4 | 0.7805044779316328,0.008947537857148302,0.5578084027546968,0.7975104497549266
5 | 0.6727174963492204,0.24786984946279625,0.2640713103088026,0.44435791644122935
6 | 0.05382860859967886,0.5201244020579979,0.5522642392797277,0.19000759632053632
7 | 0.2860433671280178,0.5934650440000543,0.9073072637456548,0.6378977150631427
8 | 0.4304355863327313,0.16623013749421356,0.4693825447762464,0.4977008828313123
9 | 0.3122955538295512,0.5028232900921878,0.8066087010958843,0.8505190941429479
10 | 0.1877648514121828,0.9970746427719338,0.8959552961495315,0.530390137569463
11 | 0.9081621790575398,0.23272641071536715,0.4141382611943452,0.4320069001558664
12 |
--------------------------------------------------------------------------------
/Pandas/Pandas Exercises/.ipynb_checkpoints/SF Salaries Exercise-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "___\n",
8 | "\n",
9 | "
\n",
10 | "___"
11 | ]
12 | },
13 | {
14 | "cell_type": "markdown",
15 | "metadata": {},
16 | "source": [
17 | "# SF Salaries Exercise \n",
18 | "\n",
19 | "Welcome to a quick exercise for you to practice your pandas skills! We will be using the [SF Salaries Dataset](https://www.kaggle.com/kaggle/sf-salaries) from Kaggle! Just follow along and complete the tasks outlined in bold below. The tasks will get harder and harder as you go along."
20 | ]
21 | },
22 | {
23 | "cell_type": "markdown",
24 | "metadata": {},
25 | "source": [
26 | "** Import pandas as pd.**"
27 | ]
28 | },
29 | {
30 | "cell_type": "code",
31 | "execution_count": 1,
32 | "metadata": {
33 | "collapsed": true
34 | },
35 | "outputs": [],
36 | "source": [
37 | "import pandas as pd"
38 | ]
39 | },
40 | {
41 | "cell_type": "markdown",
42 | "metadata": {},
43 | "source": [
44 | "** Read Salaries.csv as a dataframe called sal.**"
45 | ]
46 | },
47 | {
48 | "cell_type": "code",
49 | "execution_count": 2,
50 | "metadata": {
51 | "collapsed": false
52 | },
53 | "outputs": [],
54 | "source": [
55 | "sal = pd.read_csv(\"Salaries.csv\")"
56 | ]
57 | },
58 | {
59 | "cell_type": "markdown",
60 | "metadata": {},
61 | "source": [
62 | "** Check the head of the DataFrame. **"
63 | ]
64 | },
65 | {
66 | "cell_type": "code",
67 | "execution_count": 6,
68 | "metadata": {
69 | "collapsed": false
70 | },
71 | "outputs": [
72 | {
73 | "data": {
74 | "text/html": [
75 | "\n",
76 | "
\n",
77 | " \n",
78 | " \n",
79 | " | \n",
80 | " Id | \n",
81 | " EmployeeName | \n",
82 | " JobTitle | \n",
83 | " BasePay | \n",
84 | " OvertimePay | \n",
85 | " OtherPay | \n",
86 | " Benefits | \n",
87 | " TotalPay | \n",
88 | " TotalPayBenefits | \n",
89 | " Year | \n",
90 | " Notes | \n",
91 | " Agency | \n",
92 | " Status | \n",
93 | "
\n",
94 | " \n",
95 | " \n",
96 | " \n",
97 | " 0 | \n",
98 | " 1 | \n",
99 | " NATHANIEL FORD | \n",
100 | " GENERAL MANAGER-METROPOLITAN TRANSIT AUTHORITY | \n",
101 | " 167411.18 | \n",
102 | " 0.00 | \n",
103 | " 400184.25 | \n",
104 | " NaN | \n",
105 | " 567595.43 | \n",
106 | " 567595.43 | \n",
107 | " 2011 | \n",
108 | " NaN | \n",
109 | " San Francisco | \n",
110 | " NaN | \n",
111 | "
\n",
112 | " \n",
113 | " 1 | \n",
114 | " 2 | \n",
115 | " GARY JIMENEZ | \n",
116 | " CAPTAIN III (POLICE DEPARTMENT) | \n",
117 | " 155966.02 | \n",
118 | " 245131.88 | \n",
119 | " 137811.38 | \n",
120 | " NaN | \n",
121 | " 538909.28 | \n",
122 | " 538909.28 | \n",
123 | " 2011 | \n",
124 | " NaN | \n",
125 | " San Francisco | \n",
126 | " NaN | \n",
127 | "
\n",
128 | " \n",
129 | " 2 | \n",
130 | " 3 | \n",
131 | " ALBERT PARDINI | \n",
132 | " CAPTAIN III (POLICE DEPARTMENT) | \n",
133 | " 212739.13 | \n",
134 | " 106088.18 | \n",
135 | " 16452.60 | \n",
136 | " NaN | \n",
137 | " 335279.91 | \n",
138 | " 335279.91 | \n",
139 | " 2011 | \n",
140 | " NaN | \n",
141 | " San Francisco | \n",
142 | " NaN | \n",
143 | "
\n",
144 | " \n",
145 | " 3 | \n",
146 | " 4 | \n",
147 | " CHRISTOPHER CHONG | \n",
148 | " WIRE ROPE CABLE MAINTENANCE MECHANIC | \n",
149 | " 77916.00 | \n",
150 | " 56120.71 | \n",
151 | " 198306.90 | \n",
152 | " NaN | \n",
153 | " 332343.61 | \n",
154 | " 332343.61 | \n",
155 | " 2011 | \n",
156 | " NaN | \n",
157 | " San Francisco | \n",
158 | " NaN | \n",
159 | "
\n",
160 | " \n",
161 | " 4 | \n",
162 | " 5 | \n",
163 | " PATRICK GARDNER | \n",
164 | " DEPUTY CHIEF OF DEPARTMENT,(FIRE DEPARTMENT) | \n",
165 | " 134401.60 | \n",
166 | " 9737.00 | \n",
167 | " 182234.59 | \n",
168 | " NaN | \n",
169 | " 326373.19 | \n",
170 | " 326373.19 | \n",
171 | " 2011 | \n",
172 | " NaN | \n",
173 | " San Francisco | \n",
174 | " NaN | \n",
175 | "
\n",
176 | " \n",
177 | "
\n",
178 | "
"
179 | ],
180 | "text/plain": [
181 | " Id EmployeeName JobTitle \\\n",
182 | "0 1 NATHANIEL FORD GENERAL MANAGER-METROPOLITAN TRANSIT AUTHORITY \n",
183 | "1 2 GARY JIMENEZ CAPTAIN III (POLICE DEPARTMENT) \n",
184 | "2 3 ALBERT PARDINI CAPTAIN III (POLICE DEPARTMENT) \n",
185 | "3 4 CHRISTOPHER CHONG WIRE ROPE CABLE MAINTENANCE MECHANIC \n",
186 | "4 5 PATRICK GARDNER DEPUTY CHIEF OF DEPARTMENT,(FIRE DEPARTMENT) \n",
187 | "\n",
188 | " BasePay OvertimePay OtherPay Benefits TotalPay TotalPayBenefits \\\n",
189 | "0 167411.18 0.00 400184.25 NaN 567595.43 567595.43 \n",
190 | "1 155966.02 245131.88 137811.38 NaN 538909.28 538909.28 \n",
191 | "2 212739.13 106088.18 16452.60 NaN 335279.91 335279.91 \n",
192 | "3 77916.00 56120.71 198306.90 NaN 332343.61 332343.61 \n",
193 | "4 134401.60 9737.00 182234.59 NaN 326373.19 326373.19 \n",
194 | "\n",
195 | " Year Notes Agency Status \n",
196 | "0 2011 NaN San Francisco NaN \n",
197 | "1 2011 NaN San Francisco NaN \n",
198 | "2 2011 NaN San Francisco NaN \n",
199 | "3 2011 NaN San Francisco NaN \n",
200 | "4 2011 NaN San Francisco NaN "
201 | ]
202 | },
203 | "execution_count": 6,
204 | "metadata": {},
205 | "output_type": "execute_result"
206 | }
207 | ],
208 | "source": [
209 | "sal.head()"
210 | ]
211 | },
212 | {
213 | "cell_type": "markdown",
214 | "metadata": {},
215 | "source": [
216 | "** Use the .info() method to find out how many entries there are.**"
217 | ]
218 | },
219 | {
220 | "cell_type": "code",
221 | "execution_count": 7,
222 | "metadata": {
223 | "collapsed": false
224 | },
225 | "outputs": [
226 | {
227 | "name": "stdout",
228 | "output_type": "stream",
229 | "text": [
230 | "\n",
231 | "RangeIndex: 148654 entries, 0 to 148653\n",
232 | "Data columns (total 13 columns):\n",
233 | "Id 148654 non-null int64\n",
234 | "EmployeeName 148654 non-null object\n",
235 | "JobTitle 148654 non-null object\n",
236 | "BasePay 148045 non-null float64\n",
237 | "OvertimePay 148650 non-null float64\n",
238 | "OtherPay 148650 non-null float64\n",
239 | "Benefits 112491 non-null float64\n",
240 | "TotalPay 148654 non-null float64\n",
241 | "TotalPayBenefits 148654 non-null float64\n",
242 | "Year 148654 non-null int64\n",
243 | "Notes 0 non-null float64\n",
244 | "Agency 148654 non-null object\n",
245 | "Status 0 non-null float64\n",
246 | "dtypes: float64(8), int64(2), object(3)\n",
247 | "memory usage: 14.7+ MB\n"
248 | ]
249 | }
250 | ],
251 | "source": [
252 | "sal.info()"
253 | ]
254 | },
255 | {
256 | "cell_type": "markdown",
257 | "metadata": {},
258 | "source": [
259 | "**What is the average BasePay ?**"
260 | ]
261 | },
262 | {
263 | "cell_type": "code",
264 | "execution_count": 8,
265 | "metadata": {
266 | "collapsed": false
267 | },
268 | "outputs": [
269 | {
270 | "data": {
271 | "text/plain": [
272 | "66325.44884050643"
273 | ]
274 | },
275 | "execution_count": 8,
276 | "metadata": {},
277 | "output_type": "execute_result"
278 | }
279 | ],
280 | "source": [
281 | "sal['BasePay'].mean()"
282 | ]
283 | },
284 | {
285 | "cell_type": "markdown",
286 | "metadata": {},
287 | "source": [
288 | "** What is the highest amount of OvertimePay in the dataset ? **"
289 | ]
290 | },
291 | {
292 | "cell_type": "code",
293 | "execution_count": 9,
294 | "metadata": {
295 | "collapsed": false
296 | },
297 | "outputs": [
298 | {
299 | "data": {
300 | "text/plain": [
301 | "245131.88"
302 | ]
303 | },
304 | "execution_count": 9,
305 | "metadata": {},
306 | "output_type": "execute_result"
307 | }
308 | ],
309 | "source": [
310 | "sal['OvertimePay'].max()"
311 | ]
312 | },
313 | {
314 | "cell_type": "markdown",
315 | "metadata": {},
316 | "source": [
317 | "** What is the job title of JOSEPH DRISCOLL ? Note: Use all caps, otherwise you may get an answer that doesn't match up (there is also a lowercase Joseph Driscoll). **"
318 | ]
319 | },
320 | {
321 | "cell_type": "code",
322 | "execution_count": 16,
323 | "metadata": {
324 | "collapsed": false
325 | },
326 | "outputs": [
327 | {
328 | "data": {
329 | "text/plain": [
330 | "24 CAPTAIN, FIRE SUPPRESSION\n",
331 | "Name: JobTitle, dtype: object"
332 | ]
333 | },
334 | "execution_count": 16,
335 | "metadata": {},
336 | "output_type": "execute_result"
337 | }
338 | ],
339 | "source": [
340 | "sal[sal['EmployeeName']=='JOSEPH DRISCOLL']['JobTitle']"
341 | ]
342 | },
343 | {
344 | "cell_type": "markdown",
345 | "metadata": {},
346 | "source": [
347 | "** How much does JOSEPH DRISCOLL make (including benefits)? **"
348 | ]
349 | },
350 | {
351 | "cell_type": "code",
352 | "execution_count": 23,
353 | "metadata": {
354 | "collapsed": false
355 | },
356 | "outputs": [
357 | {
358 | "data": {
359 | "text/plain": [
360 | "24 270324.91\n",
361 | "Name: TotalPayBenefits, dtype: float64"
362 | ]
363 | },
364 | "execution_count": 23,
365 | "metadata": {},
366 | "output_type": "execute_result"
367 | }
368 | ],
369 | "source": [
370 | "sal[sal['EmployeeName']=='JOSEPH DRISCOLL']['TotalPayBenefits']"
371 | ]
372 | },
373 | {
374 | "cell_type": "markdown",
375 | "metadata": {},
376 | "source": [
377 | "** What is the name of highest paid person (including benefits)?**"
378 | ]
379 | },
380 | {
381 | "cell_type": "code",
382 | "execution_count": 78,
383 | "metadata": {
384 | "collapsed": false
385 | },
386 | "outputs": [
387 | {
388 | "data": {
389 | "text/html": [
390 | "\n",
391 | "
\n",
392 | " \n",
393 | " \n",
394 | " | \n",
395 | " Id | \n",
396 | " EmployeeName | \n",
397 | " JobTitle | \n",
398 | " BasePay | \n",
399 | " OvertimePay | \n",
400 | " OtherPay | \n",
401 | " Benefits | \n",
402 | " TotalPay | \n",
403 | " TotalPayBenefits | \n",
404 | " Year | \n",
405 | " Notes | \n",
406 | " Agency | \n",
407 | " Status | \n",
408 | "
\n",
409 | " \n",
410 | " \n",
411 | " \n",
412 | " 0 | \n",
413 | " 1 | \n",
414 | " NATHANIEL FORD | \n",
415 | " GENERAL MANAGER-METROPOLITAN TRANSIT AUTHORITY | \n",
416 | " 167411.18 | \n",
417 | " 0.0 | \n",
418 | " 400184.25 | \n",
419 | " NaN | \n",
420 | " 567595.43 | \n",
421 | " 567595.43 | \n",
422 | " 2011 | \n",
423 | " NaN | \n",
424 | " San Francisco | \n",
425 | " NaN | \n",
426 | "
\n",
427 | " \n",
428 | "
\n",
429 | "
"
430 | ],
431 | "text/plain": [
432 | " Id EmployeeName JobTitle \\\n",
433 | "0 1 NATHANIEL FORD GENERAL MANAGER-METROPOLITAN TRANSIT AUTHORITY \n",
434 | "\n",
435 | " BasePay OvertimePay OtherPay Benefits TotalPay TotalPayBenefits \\\n",
436 | "0 167411.18 0.0 400184.25 NaN 567595.43 567595.43 \n",
437 | "\n",
438 | " Year Notes Agency Status \n",
439 | "0 2011 NaN San Francisco NaN "
440 | ]
441 | },
442 | "execution_count": 78,
443 | "metadata": {},
444 | "output_type": "execute_result"
445 | }
446 | ],
447 | "source": [
448 | "sal[sal['TotalPayBenefits'] == sal['TotalPayBenefits'].max()]\n",
449 | "## SURELY THIS CAN BE DONE BETTER\n",
450 | "# ANOTHERE WAY TO DO THIS: \n",
451 | "#sal.loc[sal['TotalPayBenefits'].idxmax()]"
452 | ]
453 | },
454 | {
455 | "cell_type": "markdown",
456 | "metadata": {},
457 | "source": [
458 | "** What is the name of lowest paid person (including benefits)? Do you notice something strange about how much he or she is paid?**"
459 | ]
460 | },
461 | {
462 | "cell_type": "code",
463 | "execution_count": 80,
464 | "metadata": {
465 | "collapsed": false
466 | },
467 | "outputs": [
468 | {
469 | "data": {
470 | "text/plain": [
471 | "Id 148654\n",
472 | "EmployeeName Joe Lopez\n",
473 | "JobTitle Counselor, Log Cabin Ranch\n",
474 | "BasePay 0\n",
475 | "OvertimePay 0\n",
476 | "OtherPay -618.13\n",
477 | "Benefits 0\n",
478 | "TotalPay -618.13\n",
479 | "TotalPayBenefits -618.13\n",
480 | "Year 2014\n",
481 | "Notes NaN\n",
482 | "Agency San Francisco\n",
483 | "Status NaN\n",
484 | "Name: 148653, dtype: object"
485 | ]
486 | },
487 | "execution_count": 80,
488 | "metadata": {},
489 | "output_type": "execute_result"
490 | }
491 | ],
492 | "source": [
493 | "sal[sal['TotalPayBenefits'] == sal['TotalPayBenefits'].min()]\n",
494 | "\n",
495 | "sal.iloc[sal['TotalPayBenefits'].argmin()]"
496 | ]
497 | },
498 | {
499 | "cell_type": "markdown",
500 | "metadata": {},
501 | "source": [
502 | "** What was the average (mean) BasePay of all employees per year? (2011-2014) ? **"
503 | ]
504 | },
505 | {
506 | "cell_type": "code",
507 | "execution_count": 36,
508 | "metadata": {
509 | "collapsed": false
510 | },
511 | "outputs": [
512 | {
513 | "data": {
514 | "text/plain": [
515 | "Year\n",
516 | "2011 63595.956517\n",
517 | "2012 65436.406857\n",
518 | "2013 69630.030216\n",
519 | "2014 66564.421924\n",
520 | "Name: BasePay, dtype: float64"
521 | ]
522 | },
523 | "execution_count": 36,
524 | "metadata": {},
525 | "output_type": "execute_result"
526 | }
527 | ],
528 | "source": [
529 | "sal.groupby('Year').mean()['BasePay']"
530 | ]
531 | },
532 | {
533 | "cell_type": "markdown",
534 | "metadata": {},
535 | "source": [
536 | "** How many unique job titles are there? **"
537 | ]
538 | },
539 | {
540 | "cell_type": "code",
541 | "execution_count": 47,
542 | "metadata": {
543 | "collapsed": false
544 | },
545 | "outputs": [
546 | {
547 | "data": {
548 | "text/plain": [
549 | "2159"
550 | ]
551 | },
552 | "execution_count": 47,
553 | "metadata": {},
554 | "output_type": "execute_result"
555 | }
556 | ],
557 | "source": [
558 | "sal['JobTitle'].nunique() #number of uniquye"
559 | ]
560 | },
561 | {
562 | "cell_type": "markdown",
563 | "metadata": {},
564 | "source": [
565 | "** What are the top 5 most common jobs? **"
566 | ]
567 | },
568 | {
569 | "cell_type": "code",
570 | "execution_count": 81,
571 | "metadata": {
572 | "collapsed": false
573 | },
574 | "outputs": [
575 | {
576 | "data": {
577 | "text/plain": [
578 | "Transit Operator 7036\n",
579 | "Special Nurse 4389\n",
580 | "Registered Nurse 3736\n",
581 | "Public Svc Aide-Public Works 2518\n",
582 | "Police Officer 3 2421\n",
583 | "Name: JobTitle, dtype: int64"
584 | ]
585 | },
586 | "execution_count": 81,
587 | "metadata": {},
588 | "output_type": "execute_result"
589 | }
590 | ],
591 | "source": [
592 | "sal['JobTitle'].value_counts()[0:5]\n",
593 | "# OR use.head(5)"
594 | ]
595 | },
596 | {
597 | "cell_type": "markdown",
598 | "metadata": {},
599 | "source": [
600 | "** How many Job Titles were represented by only one person in 2013? (e.g. Job Titles with only one occurence in 2013?) **"
601 | ]
602 | },
603 | {
604 | "cell_type": "code",
605 | "execution_count": 87,
606 | "metadata": {
607 | "collapsed": false
608 | },
609 | "outputs": [
610 | {
611 | "data": {
612 | "text/plain": [
613 | "202"
614 | ]
615 | },
616 | "execution_count": 87,
617 | "metadata": {},
618 | "output_type": "execute_result"
619 | }
620 | ],
621 | "source": [
622 | "## ATTEMPT:(sal['JobTitle'].value_counts() == 1) & (sal['Year'] == 2013)\n",
623 | "\n",
624 | "df = sal[sal['Year']==2013]['JobTitle'].value_counts() == 1\n",
625 | "# So what we have done here is:\n",
626 | "# We first get the condition and make a series of that condition, grabbing ONLY the columns of Job titles for that year\n",
627 | "\n",
628 | "sum(df)"
629 | ]
630 | },
631 | {
632 | "cell_type": "markdown",
633 | "metadata": {},
634 | "source": [
635 | "** How many people have the word Chief in their job title? (This is pretty tricky) **"
636 | ]
637 | },
638 | {
639 | "cell_type": "code",
640 | "execution_count": 90,
641 | "metadata": {
642 | "collapsed": false
643 | },
644 | "outputs": [
645 | {
646 | "data": {
647 | "text/plain": [
648 | "477"
649 | ]
650 | },
651 | "execution_count": 90,
652 | "metadata": {},
653 | "output_type": "execute_result"
654 | }
655 | ],
656 | "source": [
657 | "# sal['JobTitle']\n",
658 | "# make function\n",
659 | "def check_chief(title):\n",
660 | " # Grab a title and return True if there is a Chief word\n",
661 | " if('chief' in title.lower().split()):\n",
662 | " return True\n",
663 | " else:\n",
664 | " return False\n",
665 | " \n",
666 | "sum(sal['JobTitle'].apply(check_chief) == True)"
667 | ]
668 | },
669 | {
670 | "cell_type": "code",
671 | "execution_count": 21,
672 | "metadata": {
673 | "collapsed": false
674 | },
675 | "outputs": [
676 | {
677 | "data": {
678 | "text/plain": [
679 | "477"
680 | ]
681 | },
682 | "execution_count": 21,
683 | "metadata": {},
684 | "output_type": "execute_result"
685 | }
686 | ],
687 | "source": []
688 | },
689 | {
690 | "cell_type": "markdown",
691 | "metadata": {},
692 | "source": [
693 | "** Bonus: Is there a correlation between length of the Job Title string and Salary? **"
694 | ]
695 | },
696 | {
697 | "cell_type": "code",
698 | "execution_count": 91,
699 | "metadata": {
700 | "collapsed": false
701 | },
702 | "outputs": [],
703 | "source": [
704 | "sal['title_len'] = sal['JobTitle'].apply(len)"
705 | ]
706 | },
707 | {
708 | "cell_type": "code",
709 | "execution_count": 93,
710 | "metadata": {
711 | "collapsed": false
712 | },
713 | "outputs": [
714 | {
715 | "data": {
716 | "text/html": [
717 | "\n",
718 | "
\n",
719 | " \n",
720 | " \n",
721 | " | \n",
722 | " TotalPayBenefits | \n",
723 | " title_len | \n",
724 | "
\n",
725 | " \n",
726 | " \n",
727 | " \n",
728 | " TotalPayBenefits | \n",
729 | " 1.000000 | \n",
730 | " -0.036878 | \n",
731 | "
\n",
732 | " \n",
733 | " title_len | \n",
734 | " -0.036878 | \n",
735 | " 1.000000 | \n",
736 | "
\n",
737 | " \n",
738 | "
\n",
739 | "
"
740 | ],
741 | "text/plain": [
742 | " TotalPayBenefits title_len\n",
743 | "TotalPayBenefits 1.000000 -0.036878\n",
744 | "title_len -0.036878 1.000000"
745 | ]
746 | },
747 | "execution_count": 93,
748 | "metadata": {},
749 | "output_type": "execute_result"
750 | }
751 | ],
752 | "source": [
753 | "sal[['TotalPayBenefits', 'title_len']].corr()"
754 | ]
755 | },
756 | {
757 | "cell_type": "markdown",
758 | "metadata": {},
759 | "source": [
760 | "# Great Job!"
761 | ]
762 | }
763 | ],
764 | "metadata": {
765 | "kernelspec": {
766 | "display_name": "Python 3",
767 | "language": "python",
768 | "name": "python3"
769 | },
770 | "language_info": {
771 | "codemirror_mode": {
772 | "name": "ipython",
773 | "version": 3
774 | },
775 | "file_extension": ".py",
776 | "mimetype": "text/x-python",
777 | "name": "python",
778 | "nbconvert_exporter": "python",
779 | "pygments_lexer": "ipython3",
780 | "version": "3.6.0"
781 | }
782 | },
783 | "nbformat": 4,
784 | "nbformat_minor": 0
785 | }
786 |
--------------------------------------------------------------------------------
/Pandas/Pandas Exercises/SF Salaries Exercise.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "___\n",
8 | "\n",
9 | "
\n",
10 | "___"
11 | ]
12 | },
13 | {
14 | "cell_type": "markdown",
15 | "metadata": {},
16 | "source": [
17 | "# SF Salaries Exercise \n",
18 | "\n",
19 | "Welcome to a quick exercise for you to practice your pandas skills! We will be using the [SF Salaries Dataset](https://www.kaggle.com/kaggle/sf-salaries) from Kaggle! Just follow along and complete the tasks outlined in bold below. The tasks will get harder and harder as you go along."
20 | ]
21 | },
22 | {
23 | "cell_type": "markdown",
24 | "metadata": {},
25 | "source": [
26 | "** Import pandas as pd.**"
27 | ]
28 | },
29 | {
30 | "cell_type": "code",
31 | "execution_count": 1,
32 | "metadata": {
33 | "collapsed": true
34 | },
35 | "outputs": [],
36 | "source": [
37 | "import pandas as pd"
38 | ]
39 | },
40 | {
41 | "cell_type": "markdown",
42 | "metadata": {},
43 | "source": [
44 | "** Read Salaries.csv as a dataframe called sal.**"
45 | ]
46 | },
47 | {
48 | "cell_type": "code",
49 | "execution_count": 2,
50 | "metadata": {
51 | "collapsed": false
52 | },
53 | "outputs": [],
54 | "source": [
55 | "sal = pd.read_csv(\"Salaries.csv\")"
56 | ]
57 | },
58 | {
59 | "cell_type": "markdown",
60 | "metadata": {},
61 | "source": [
62 | "** Check the head of the DataFrame. **"
63 | ]
64 | },
65 | {
66 | "cell_type": "code",
67 | "execution_count": 6,
68 | "metadata": {
69 | "collapsed": false
70 | },
71 | "outputs": [
72 | {
73 | "data": {
74 | "text/html": [
75 | "\n",
76 | "
\n",
77 | " \n",
78 | " \n",
79 | " | \n",
80 | " Id | \n",
81 | " EmployeeName | \n",
82 | " JobTitle | \n",
83 | " BasePay | \n",
84 | " OvertimePay | \n",
85 | " OtherPay | \n",
86 | " Benefits | \n",
87 | " TotalPay | \n",
88 | " TotalPayBenefits | \n",
89 | " Year | \n",
90 | " Notes | \n",
91 | " Agency | \n",
92 | " Status | \n",
93 | "
\n",
94 | " \n",
95 | " \n",
96 | " \n",
97 | " 0 | \n",
98 | " 1 | \n",
99 | " NATHANIEL FORD | \n",
100 | " GENERAL MANAGER-METROPOLITAN TRANSIT AUTHORITY | \n",
101 | " 167411.18 | \n",
102 | " 0.00 | \n",
103 | " 400184.25 | \n",
104 | " NaN | \n",
105 | " 567595.43 | \n",
106 | " 567595.43 | \n",
107 | " 2011 | \n",
108 | " NaN | \n",
109 | " San Francisco | \n",
110 | " NaN | \n",
111 | "
\n",
112 | " \n",
113 | " 1 | \n",
114 | " 2 | \n",
115 | " GARY JIMENEZ | \n",
116 | " CAPTAIN III (POLICE DEPARTMENT) | \n",
117 | " 155966.02 | \n",
118 | " 245131.88 | \n",
119 | " 137811.38 | \n",
120 | " NaN | \n",
121 | " 538909.28 | \n",
122 | " 538909.28 | \n",
123 | " 2011 | \n",
124 | " NaN | \n",
125 | " San Francisco | \n",
126 | " NaN | \n",
127 | "
\n",
128 | " \n",
129 | " 2 | \n",
130 | " 3 | \n",
131 | " ALBERT PARDINI | \n",
132 | " CAPTAIN III (POLICE DEPARTMENT) | \n",
133 | " 212739.13 | \n",
134 | " 106088.18 | \n",
135 | " 16452.60 | \n",
136 | " NaN | \n",
137 | " 335279.91 | \n",
138 | " 335279.91 | \n",
139 | " 2011 | \n",
140 | " NaN | \n",
141 | " San Francisco | \n",
142 | " NaN | \n",
143 | "
\n",
144 | " \n",
145 | " 3 | \n",
146 | " 4 | \n",
147 | " CHRISTOPHER CHONG | \n",
148 | " WIRE ROPE CABLE MAINTENANCE MECHANIC | \n",
149 | " 77916.00 | \n",
150 | " 56120.71 | \n",
151 | " 198306.90 | \n",
152 | " NaN | \n",
153 | " 332343.61 | \n",
154 | " 332343.61 | \n",
155 | " 2011 | \n",
156 | " NaN | \n",
157 | " San Francisco | \n",
158 | " NaN | \n",
159 | "
\n",
160 | " \n",
161 | " 4 | \n",
162 | " 5 | \n",
163 | " PATRICK GARDNER | \n",
164 | " DEPUTY CHIEF OF DEPARTMENT,(FIRE DEPARTMENT) | \n",
165 | " 134401.60 | \n",
166 | " 9737.00 | \n",
167 | " 182234.59 | \n",
168 | " NaN | \n",
169 | " 326373.19 | \n",
170 | " 326373.19 | \n",
171 | " 2011 | \n",
172 | " NaN | \n",
173 | " San Francisco | \n",
174 | " NaN | \n",
175 | "
\n",
176 | " \n",
177 | "
\n",
178 | "
"
179 | ],
180 | "text/plain": [
181 | " Id EmployeeName JobTitle \\\n",
182 | "0 1 NATHANIEL FORD GENERAL MANAGER-METROPOLITAN TRANSIT AUTHORITY \n",
183 | "1 2 GARY JIMENEZ CAPTAIN III (POLICE DEPARTMENT) \n",
184 | "2 3 ALBERT PARDINI CAPTAIN III (POLICE DEPARTMENT) \n",
185 | "3 4 CHRISTOPHER CHONG WIRE ROPE CABLE MAINTENANCE MECHANIC \n",
186 | "4 5 PATRICK GARDNER DEPUTY CHIEF OF DEPARTMENT,(FIRE DEPARTMENT) \n",
187 | "\n",
188 | " BasePay OvertimePay OtherPay Benefits TotalPay TotalPayBenefits \\\n",
189 | "0 167411.18 0.00 400184.25 NaN 567595.43 567595.43 \n",
190 | "1 155966.02 245131.88 137811.38 NaN 538909.28 538909.28 \n",
191 | "2 212739.13 106088.18 16452.60 NaN 335279.91 335279.91 \n",
192 | "3 77916.00 56120.71 198306.90 NaN 332343.61 332343.61 \n",
193 | "4 134401.60 9737.00 182234.59 NaN 326373.19 326373.19 \n",
194 | "\n",
195 | " Year Notes Agency Status \n",
196 | "0 2011 NaN San Francisco NaN \n",
197 | "1 2011 NaN San Francisco NaN \n",
198 | "2 2011 NaN San Francisco NaN \n",
199 | "3 2011 NaN San Francisco NaN \n",
200 | "4 2011 NaN San Francisco NaN "
201 | ]
202 | },
203 | "execution_count": 6,
204 | "metadata": {},
205 | "output_type": "execute_result"
206 | }
207 | ],
208 | "source": [
209 | "sal.head()"
210 | ]
211 | },
212 | {
213 | "cell_type": "markdown",
214 | "metadata": {},
215 | "source": [
216 | "** Use the .info() method to find out how many entries there are.**"
217 | ]
218 | },
219 | {
220 | "cell_type": "code",
221 | "execution_count": 7,
222 | "metadata": {
223 | "collapsed": false
224 | },
225 | "outputs": [
226 | {
227 | "name": "stdout",
228 | "output_type": "stream",
229 | "text": [
230 | "\n",
231 | "RangeIndex: 148654 entries, 0 to 148653\n",
232 | "Data columns (total 13 columns):\n",
233 | "Id 148654 non-null int64\n",
234 | "EmployeeName 148654 non-null object\n",
235 | "JobTitle 148654 non-null object\n",
236 | "BasePay 148045 non-null float64\n",
237 | "OvertimePay 148650 non-null float64\n",
238 | "OtherPay 148650 non-null float64\n",
239 | "Benefits 112491 non-null float64\n",
240 | "TotalPay 148654 non-null float64\n",
241 | "TotalPayBenefits 148654 non-null float64\n",
242 | "Year 148654 non-null int64\n",
243 | "Notes 0 non-null float64\n",
244 | "Agency 148654 non-null object\n",
245 | "Status 0 non-null float64\n",
246 | "dtypes: float64(8), int64(2), object(3)\n",
247 | "memory usage: 14.7+ MB\n"
248 | ]
249 | }
250 | ],
251 | "source": [
252 | "sal.info()"
253 | ]
254 | },
255 | {
256 | "cell_type": "markdown",
257 | "metadata": {},
258 | "source": [
259 | "**What is the average BasePay ?**"
260 | ]
261 | },
262 | {
263 | "cell_type": "code",
264 | "execution_count": 8,
265 | "metadata": {
266 | "collapsed": false
267 | },
268 | "outputs": [
269 | {
270 | "data": {
271 | "text/plain": [
272 | "66325.44884050643"
273 | ]
274 | },
275 | "execution_count": 8,
276 | "metadata": {},
277 | "output_type": "execute_result"
278 | }
279 | ],
280 | "source": [
281 | "sal['BasePay'].mean()"
282 | ]
283 | },
284 | {
285 | "cell_type": "markdown",
286 | "metadata": {},
287 | "source": [
288 | "** What is the highest amount of OvertimePay in the dataset ? **"
289 | ]
290 | },
291 | {
292 | "cell_type": "code",
293 | "execution_count": 9,
294 | "metadata": {
295 | "collapsed": false
296 | },
297 | "outputs": [
298 | {
299 | "data": {
300 | "text/plain": [
301 | "245131.88"
302 | ]
303 | },
304 | "execution_count": 9,
305 | "metadata": {},
306 | "output_type": "execute_result"
307 | }
308 | ],
309 | "source": [
310 | "sal['OvertimePay'].max()"
311 | ]
312 | },
313 | {
314 | "cell_type": "markdown",
315 | "metadata": {},
316 | "source": [
317 | "** What is the job title of JOSEPH DRISCOLL ? Note: Use all caps, otherwise you may get an answer that doesn't match up (there is also a lowercase Joseph Driscoll). **"
318 | ]
319 | },
320 | {
321 | "cell_type": "code",
322 | "execution_count": 16,
323 | "metadata": {
324 | "collapsed": false
325 | },
326 | "outputs": [
327 | {
328 | "data": {
329 | "text/plain": [
330 | "24 CAPTAIN, FIRE SUPPRESSION\n",
331 | "Name: JobTitle, dtype: object"
332 | ]
333 | },
334 | "execution_count": 16,
335 | "metadata": {},
336 | "output_type": "execute_result"
337 | }
338 | ],
339 | "source": [
340 | "sal[sal['EmployeeName']=='JOSEPH DRISCOLL']['JobTitle']"
341 | ]
342 | },
343 | {
344 | "cell_type": "markdown",
345 | "metadata": {},
346 | "source": [
347 | "** How much does JOSEPH DRISCOLL make (including benefits)? **"
348 | ]
349 | },
350 | {
351 | "cell_type": "code",
352 | "execution_count": 23,
353 | "metadata": {
354 | "collapsed": false
355 | },
356 | "outputs": [
357 | {
358 | "data": {
359 | "text/plain": [
360 | "24 270324.91\n",
361 | "Name: TotalPayBenefits, dtype: float64"
362 | ]
363 | },
364 | "execution_count": 23,
365 | "metadata": {},
366 | "output_type": "execute_result"
367 | }
368 | ],
369 | "source": [
370 | "sal[sal['EmployeeName']=='JOSEPH DRISCOLL']['TotalPayBenefits']"
371 | ]
372 | },
373 | {
374 | "cell_type": "markdown",
375 | "metadata": {},
376 | "source": [
377 | "** What is the name of highest paid person (including benefits)?**"
378 | ]
379 | },
380 | {
381 | "cell_type": "code",
382 | "execution_count": 78,
383 | "metadata": {
384 | "collapsed": false
385 | },
386 | "outputs": [
387 | {
388 | "data": {
389 | "text/html": [
390 | "\n",
391 | "
\n",
392 | " \n",
393 | " \n",
394 | " | \n",
395 | " Id | \n",
396 | " EmployeeName | \n",
397 | " JobTitle | \n",
398 | " BasePay | \n",
399 | " OvertimePay | \n",
400 | " OtherPay | \n",
401 | " Benefits | \n",
402 | " TotalPay | \n",
403 | " TotalPayBenefits | \n",
404 | " Year | \n",
405 | " Notes | \n",
406 | " Agency | \n",
407 | " Status | \n",
408 | "
\n",
409 | " \n",
410 | " \n",
411 | " \n",
412 | " 0 | \n",
413 | " 1 | \n",
414 | " NATHANIEL FORD | \n",
415 | " GENERAL MANAGER-METROPOLITAN TRANSIT AUTHORITY | \n",
416 | " 167411.18 | \n",
417 | " 0.0 | \n",
418 | " 400184.25 | \n",
419 | " NaN | \n",
420 | " 567595.43 | \n",
421 | " 567595.43 | \n",
422 | " 2011 | \n",
423 | " NaN | \n",
424 | " San Francisco | \n",
425 | " NaN | \n",
426 | "
\n",
427 | " \n",
428 | "
\n",
429 | "
"
430 | ],
431 | "text/plain": [
432 | " Id EmployeeName JobTitle \\\n",
433 | "0 1 NATHANIEL FORD GENERAL MANAGER-METROPOLITAN TRANSIT AUTHORITY \n",
434 | "\n",
435 | " BasePay OvertimePay OtherPay Benefits TotalPay TotalPayBenefits \\\n",
436 | "0 167411.18 0.0 400184.25 NaN 567595.43 567595.43 \n",
437 | "\n",
438 | " Year Notes Agency Status \n",
439 | "0 2011 NaN San Francisco NaN "
440 | ]
441 | },
442 | "execution_count": 78,
443 | "metadata": {},
444 | "output_type": "execute_result"
445 | }
446 | ],
447 | "source": [
448 | "sal[sal['TotalPayBenefits'] == sal['TotalPayBenefits'].max()]\n",
449 | "## SURELY THIS CAN BE DONE BETTER\n",
450 | "# ANOTHERE WAY TO DO THIS: \n",
451 | "#sal.loc[sal['TotalPayBenefits'].idxmax()]"
452 | ]
453 | },
454 | {
455 | "cell_type": "markdown",
456 | "metadata": {},
457 | "source": [
458 | "** What is the name of lowest paid person (including benefits)? Do you notice something strange about how much he or she is paid?**"
459 | ]
460 | },
461 | {
462 | "cell_type": "code",
463 | "execution_count": 80,
464 | "metadata": {
465 | "collapsed": false
466 | },
467 | "outputs": [
468 | {
469 | "data": {
470 | "text/plain": [
471 | "Id 148654\n",
472 | "EmployeeName Joe Lopez\n",
473 | "JobTitle Counselor, Log Cabin Ranch\n",
474 | "BasePay 0\n",
475 | "OvertimePay 0\n",
476 | "OtherPay -618.13\n",
477 | "Benefits 0\n",
478 | "TotalPay -618.13\n",
479 | "TotalPayBenefits -618.13\n",
480 | "Year 2014\n",
481 | "Notes NaN\n",
482 | "Agency San Francisco\n",
483 | "Status NaN\n",
484 | "Name: 148653, dtype: object"
485 | ]
486 | },
487 | "execution_count": 80,
488 | "metadata": {},
489 | "output_type": "execute_result"
490 | }
491 | ],
492 | "source": [
493 | "sal[sal['TotalPayBenefits'] == sal['TotalPayBenefits'].min()]\n",
494 | "\n",
495 | "sal.iloc[sal['TotalPayBenefits'].argmin()]"
496 | ]
497 | },
498 | {
499 | "cell_type": "markdown",
500 | "metadata": {},
501 | "source": [
502 | "** What was the average (mean) BasePay of all employees per year? (2011-2014) ? **"
503 | ]
504 | },
505 | {
506 | "cell_type": "code",
507 | "execution_count": 36,
508 | "metadata": {
509 | "collapsed": false
510 | },
511 | "outputs": [
512 | {
513 | "data": {
514 | "text/plain": [
515 | "Year\n",
516 | "2011 63595.956517\n",
517 | "2012 65436.406857\n",
518 | "2013 69630.030216\n",
519 | "2014 66564.421924\n",
520 | "Name: BasePay, dtype: float64"
521 | ]
522 | },
523 | "execution_count": 36,
524 | "metadata": {},
525 | "output_type": "execute_result"
526 | }
527 | ],
528 | "source": [
529 | "sal.groupby('Year').mean()['BasePay']"
530 | ]
531 | },
532 | {
533 | "cell_type": "markdown",
534 | "metadata": {},
535 | "source": [
536 | "** How many unique job titles are there? **"
537 | ]
538 | },
539 | {
540 | "cell_type": "code",
541 | "execution_count": 47,
542 | "metadata": {
543 | "collapsed": false
544 | },
545 | "outputs": [
546 | {
547 | "data": {
548 | "text/plain": [
549 | "2159"
550 | ]
551 | },
552 | "execution_count": 47,
553 | "metadata": {},
554 | "output_type": "execute_result"
555 | }
556 | ],
557 | "source": [
558 | "sal['JobTitle'].nunique() #number of uniquye"
559 | ]
560 | },
561 | {
562 | "cell_type": "markdown",
563 | "metadata": {},
564 | "source": [
565 | "** What are the top 5 most common jobs? **"
566 | ]
567 | },
568 | {
569 | "cell_type": "code",
570 | "execution_count": 81,
571 | "metadata": {
572 | "collapsed": false
573 | },
574 | "outputs": [
575 | {
576 | "data": {
577 | "text/plain": [
578 | "Transit Operator 7036\n",
579 | "Special Nurse 4389\n",
580 | "Registered Nurse 3736\n",
581 | "Public Svc Aide-Public Works 2518\n",
582 | "Police Officer 3 2421\n",
583 | "Name: JobTitle, dtype: int64"
584 | ]
585 | },
586 | "execution_count": 81,
587 | "metadata": {},
588 | "output_type": "execute_result"
589 | }
590 | ],
591 | "source": [
592 | "sal['JobTitle'].value_counts()[0:5]\n",
593 | "# OR use.head(5)"
594 | ]
595 | },
596 | {
597 | "cell_type": "markdown",
598 | "metadata": {},
599 | "source": [
600 | "** How many Job Titles were represented by only one person in 2013? (e.g. Job Titles with only one occurence in 2013?) **"
601 | ]
602 | },
603 | {
604 | "cell_type": "code",
605 | "execution_count": 87,
606 | "metadata": {
607 | "collapsed": false
608 | },
609 | "outputs": [
610 | {
611 | "data": {
612 | "text/plain": [
613 | "202"
614 | ]
615 | },
616 | "execution_count": 87,
617 | "metadata": {},
618 | "output_type": "execute_result"
619 | }
620 | ],
621 | "source": [
622 | "## ATTEMPT:(sal['JobTitle'].value_counts() == 1) & (sal['Year'] == 2013)\n",
623 | "\n",
624 | "df = sal[sal['Year']==2013]['JobTitle'].value_counts() == 1\n",
625 | "# So what we have done here is:\n",
626 | "# We first get the condition and make a series of that condition, grabbing ONLY the columns of Job titles for that year\n",
627 | "\n",
628 | "sum(df)"
629 | ]
630 | },
631 | {
632 | "cell_type": "markdown",
633 | "metadata": {},
634 | "source": [
635 | "** How many people have the word Chief in their job title? (This is pretty tricky) **"
636 | ]
637 | },
638 | {
639 | "cell_type": "code",
640 | "execution_count": 90,
641 | "metadata": {
642 | "collapsed": false
643 | },
644 | "outputs": [
645 | {
646 | "data": {
647 | "text/plain": [
648 | "477"
649 | ]
650 | },
651 | "execution_count": 90,
652 | "metadata": {},
653 | "output_type": "execute_result"
654 | }
655 | ],
656 | "source": [
657 | "# sal['JobTitle']\n",
658 | "# make function\n",
659 | "def check_chief(title):\n",
660 | " # Grab a title and return True if there is a Chief word\n",
661 | " if('chief' in title.lower().split()):\n",
662 | " return True\n",
663 | " else:\n",
664 | " return False\n",
665 | " \n",
666 | "sum(sal['JobTitle'].apply(check_chief) == True)"
667 | ]
668 | },
669 | {
670 | "cell_type": "code",
671 | "execution_count": 21,
672 | "metadata": {
673 | "collapsed": false
674 | },
675 | "outputs": [
676 | {
677 | "data": {
678 | "text/plain": [
679 | "477"
680 | ]
681 | },
682 | "execution_count": 21,
683 | "metadata": {},
684 | "output_type": "execute_result"
685 | }
686 | ],
687 | "source": []
688 | },
689 | {
690 | "cell_type": "markdown",
691 | "metadata": {},
692 | "source": [
693 | "** Bonus: Is there a correlation between length of the Job Title string and Salary? **"
694 | ]
695 | },
696 | {
697 | "cell_type": "code",
698 | "execution_count": 91,
699 | "metadata": {
700 | "collapsed": false
701 | },
702 | "outputs": [],
703 | "source": [
704 | "sal['title_len'] = sal['JobTitle'].apply(len)"
705 | ]
706 | },
707 | {
708 | "cell_type": "code",
709 | "execution_count": 93,
710 | "metadata": {
711 | "collapsed": false
712 | },
713 | "outputs": [
714 | {
715 | "data": {
716 | "text/html": [
717 | "\n",
718 | "
\n",
719 | " \n",
720 | " \n",
721 | " | \n",
722 | " TotalPayBenefits | \n",
723 | " title_len | \n",
724 | "
\n",
725 | " \n",
726 | " \n",
727 | " \n",
728 | " TotalPayBenefits | \n",
729 | " 1.000000 | \n",
730 | " -0.036878 | \n",
731 | "
\n",
732 | " \n",
733 | " title_len | \n",
734 | " -0.036878 | \n",
735 | " 1.000000 | \n",
736 | "
\n",
737 | " \n",
738 | "
\n",
739 | "
"
740 | ],
741 | "text/plain": [
742 | " TotalPayBenefits title_len\n",
743 | "TotalPayBenefits 1.000000 -0.036878\n",
744 | "title_len -0.036878 1.000000"
745 | ]
746 | },
747 | "execution_count": 93,
748 | "metadata": {},
749 | "output_type": "execute_result"
750 | }
751 | ],
752 | "source": [
753 | "sal[['TotalPayBenefits', 'title_len']].corr()"
754 | ]
755 | },
756 | {
757 | "cell_type": "markdown",
758 | "metadata": {},
759 | "source": [
760 | "# Great Job!"
761 | ]
762 | }
763 | ],
764 | "metadata": {
765 | "kernelspec": {
766 | "display_name": "Python 3",
767 | "language": "python",
768 | "name": "python3"
769 | },
770 | "language_info": {
771 | "codemirror_mode": {
772 | "name": "ipython",
773 | "version": 3
774 | },
775 | "file_extension": ".py",
776 | "mimetype": "text/x-python",
777 | "name": "python",
778 | "nbconvert_exporter": "python",
779 | "pygments_lexer": "ipython3",
780 | "version": "3.6.0"
781 | }
782 | },
783 | "nbformat": 4,
784 | "nbformat_minor": 0
785 | }
786 |
--------------------------------------------------------------------------------