diff --git a/API/1-API/README.md b/API/1-API/README.md
new file mode 100644
index 000000000..cbb786a09
--- /dev/null
+++ b/API/1-API/README.md
@@ -0,0 +1,13 @@
+# Build an API
+
+## [Pre-lecture quiz](link-to-quiz-app)
+
+✅ Knowledge Check - use this moment to stretch students' knowledge with open questions
+
+🚀 Challenge: Add a challenge for students to work on collaboratively in class to enhance the project
+
+## [Post-lecture quiz](link-to-quiz-app)
+
+## Review & Self Study
+
+**Assignment**: [Assignment Name](assignment.md)
diff --git a/API/1-API/assignment.md b/API/1-API/assignment.md
new file mode 100644
index 000000000..346ffdaef
--- /dev/null
+++ b/API/1-API/assignment.md
@@ -0,0 +1 @@
+# Assignment
\ No newline at end of file
diff --git a/API/1-API/solution/lin-reg-model.pkl b/API/1-API/solution/lin-reg-model.pkl
new file mode 100644
index 000000000..2ffbbf826
Binary files /dev/null and b/API/1-API/solution/lin-reg-model.pkl differ
diff --git a/API/1-API/solution/notebook.ipynb b/API/1-API/solution/notebook.ipynb
new file mode 100644
index 000000000..078e1693b
--- /dev/null
+++ b/API/1-API/solution/notebook.ipynb
@@ -0,0 +1,275 @@
+{
+ "metadata": {
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.7.0"
+ },
+ "orig_nbformat": 2,
+ "kernelspec": {
+ "name": "python37364bit8d3b438fb5fc4430a93ac2cb74d693a7",
+ "display_name": "Python 3.7.0 64-bit ('3.7')"
+ },
+ "metadata": {
+ "interpreter": {
+ "hash": "70b38d7a306a849643e446cd70466270a13445e5987dfa1344ef2b127438fa4d"
+ }
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "cells": [
+ {
+ "source": [
+ "## Build an API with two different models\n",
+ "\n",
+ "Linear Regression\n",
+ "Classification"
+ ],
+ "cell_type": "markdown",
+ "metadata": {}
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ " City Name Type Package Variety Sub Variety Grade Date \\\n",
+ "0 BALTIMORE NaN 24 inch bins NaN NaN NaN 4/29/17 \n",
+ "1 BALTIMORE NaN 24 inch bins NaN NaN NaN 5/6/17 \n",
+ "2 BALTIMORE NaN 24 inch bins HOWDEN TYPE NaN NaN 9/24/16 \n",
+ "3 BALTIMORE NaN 24 inch bins HOWDEN TYPE NaN NaN 9/24/16 \n",
+ "4 BALTIMORE NaN 24 inch bins HOWDEN TYPE NaN NaN 11/5/16 \n",
+ "\n",
+ " Low Price High Price Mostly Low ... Unit of Sale Quality Condition \\\n",
+ "0 270.0 280.0 270.0 ... NaN NaN NaN \n",
+ "1 270.0 280.0 270.0 ... NaN NaN NaN \n",
+ "2 160.0 160.0 160.0 ... NaN NaN NaN \n",
+ "3 160.0 160.0 160.0 ... NaN NaN NaN \n",
+ "4 90.0 100.0 90.0 ... NaN NaN NaN \n",
+ "\n",
+ " Appearance Storage Crop Repack Trans Mode Unnamed: 24 Unnamed: 25 \n",
+ "0 NaN NaN NaN E NaN NaN NaN \n",
+ "1 NaN NaN NaN E NaN NaN NaN \n",
+ "2 NaN NaN NaN N NaN NaN NaN \n",
+ "3 NaN NaN NaN N NaN NaN NaN \n",
+ "4 NaN NaN NaN N NaN NaN NaN \n",
+ "\n",
+ "[5 rows x 26 columns]"
+ ],
+ "text/html": "
\n\n
\n \n \n \n City Name \n Type \n Package \n Variety \n Sub Variety \n Grade \n Date \n Low Price \n High Price \n Mostly Low \n ... \n Unit of Sale \n Quality \n Condition \n Appearance \n Storage \n Crop \n Repack \n Trans Mode \n Unnamed: 24 \n Unnamed: 25 \n \n \n \n \n 0 \n BALTIMORE \n NaN \n 24 inch bins \n NaN \n NaN \n NaN \n 4/29/17 \n 270.0 \n 280.0 \n 270.0 \n ... \n NaN \n NaN \n NaN \n NaN \n NaN \n NaN \n E \n NaN \n NaN \n NaN \n \n \n 1 \n BALTIMORE \n NaN \n 24 inch bins \n NaN \n NaN \n NaN \n 5/6/17 \n 270.0 \n 280.0 \n 270.0 \n ... \n NaN \n NaN \n NaN \n NaN \n NaN \n NaN \n E \n NaN \n NaN \n NaN \n \n \n 2 \n BALTIMORE \n NaN \n 24 inch bins \n HOWDEN TYPE \n NaN \n NaN \n 9/24/16 \n 160.0 \n 160.0 \n 160.0 \n ... \n NaN \n NaN \n NaN \n NaN \n NaN \n NaN \n N \n NaN \n NaN \n NaN \n \n \n 3 \n BALTIMORE \n NaN \n 24 inch bins \n HOWDEN TYPE \n NaN \n NaN \n 9/24/16 \n 160.0 \n 160.0 \n 160.0 \n ... \n NaN \n NaN \n NaN \n NaN \n NaN \n NaN \n N \n NaN \n NaN \n NaN \n \n \n 4 \n BALTIMORE \n NaN \n 24 inch bins \n HOWDEN TYPE \n NaN \n NaN \n 11/5/16 \n 90.0 \n 100.0 \n 90.0 \n ... \n NaN \n NaN \n NaN \n NaN \n NaN \n NaN \n N \n NaN \n NaN \n NaN \n \n \n
\n
5 rows × 26 columns
\n
"
+ },
+ "metadata": {},
+ "execution_count": 22
+ }
+ ],
+ "source": [
+ "import pandas as pd\n",
+ "import matplotlib.pyplot as plt\n",
+ "import numpy as np\n",
+ "\n",
+ "# Use the pumpkin data from Lesso\n",
+ "\n",
+ "pumpkins = pd.read_csv('../../../Regression/data/US-pumpkins.csv')\n",
+ "\n",
+ "pumpkins.head()\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ " Package Low Price High Price Price\n",
+ "70 0 5 3 13.636364\n",
+ "71 0 10 7 16.363636\n",
+ "72 0 10 7 16.363636\n",
+ "73 0 9 6 15.454545\n",
+ "74 0 5 3 13.636364"
+ ],
+ "text/html": "\n\n
\n \n \n \n Package \n Low Price \n High Price \n Price \n \n \n \n \n 70 \n 0 \n 5 \n 3 \n 13.636364 \n \n \n 71 \n 0 \n 10 \n 7 \n 16.363636 \n \n \n 72 \n 0 \n 10 \n 7 \n 16.363636 \n \n \n 73 \n 0 \n 9 \n 6 \n 15.454545 \n \n \n 74 \n 0 \n 5 \n 3 \n 13.636364 \n \n \n
\n
"
+ },
+ "metadata": {},
+ "execution_count": 23
+ }
+ ],
+ "source": [
+ "from sklearn.preprocessing import LabelEncoder\n",
+ "\n",
+ "pumpkins = pumpkins[pumpkins['Package'].str.contains('bushel', case=True, regex=True)]\n",
+ "\n",
+ "new_columns = ['Package', 'Low Price', 'High Price']\n",
+ "\n",
+ "pumpkins = pumpkins.drop([c for c in pumpkins.columns if c not in new_columns], axis=1)\n",
+ "\n",
+ "## price is the average of low and high prices\n",
+ "\n",
+ "price = (pumpkins['Low Price'] + pumpkins['High Price']) / 2\n",
+ "\n",
+ "new_pumpkins = pd.DataFrame({ 'Package': pumpkins['Package'], 'Low Price': pumpkins['Low Price'],'High Price': pumpkins['High Price'], 'Price': price})\n",
+ "\n",
+ "new_pumpkins.loc[new_pumpkins['Package'].str.contains('1 1/9'), 'Price'] = price/1.1\n",
+ "\n",
+ "new_pumpkins.loc[new_pumpkins['Package'].str.contains('1/2'), 'Price'] = price*2\n",
+ "\n",
+ "new_pumpkins.iloc[:, 0:-1] = new_pumpkins.iloc[:, 0:-1].apply(LabelEncoder().fit_transform)\n",
+ "\n",
+ "new_pumpkins.head()\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "\nInt64Index: 415 entries, 70 to 1742\nData columns (total 4 columns):\n # Column Non-Null Count Dtype \n--- ------ -------------- ----- \n 0 Package 415 non-null int64 \n 1 Low Price 415 non-null int64 \n 2 High Price 415 non-null int64 \n 3 Price 415 non-null float64\ndtypes: float64(1), int64(3)\nmemory usage: 16.2 KB\n"
+ ]
+ }
+ ],
+ "source": [
+ "\n",
+ "new_pumpkins.dropna(inplace=True)\n",
+ "new_pumpkins.info()\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ " Package Price\n",
+ "70 0 13.636364\n",
+ "71 0 16.363636\n",
+ "72 0 16.363636\n",
+ "73 0 15.454545\n",
+ "74 0 13.636364\n",
+ "... ... ...\n",
+ "1738 2 30.000000\n",
+ "1739 2 28.750000\n",
+ "1740 2 25.750000\n",
+ "1741 2 24.000000\n",
+ "1742 2 24.000000\n",
+ "\n",
+ "[415 rows x 2 columns]"
+ ],
+ "text/html": "\n\n
\n \n \n \n Package \n Price \n \n \n \n \n 70 \n 0 \n 13.636364 \n \n \n 71 \n 0 \n 16.363636 \n \n \n 72 \n 0 \n 16.363636 \n \n \n 73 \n 0 \n 15.454545 \n \n \n 74 \n 0 \n 13.636364 \n \n \n ... \n ... \n ... \n \n \n 1738 \n 2 \n 30.000000 \n \n \n 1739 \n 2 \n 28.750000 \n \n \n 1740 \n 2 \n 25.750000 \n \n \n 1741 \n 2 \n 24.000000 \n \n \n 1742 \n 2 \n 24.000000 \n \n \n
\n
415 rows × 2 columns
\n
"
+ },
+ "metadata": {},
+ "execution_count": 25
+ }
+ ],
+ "source": [
+ "new_columns = ['Package', 'Price']\n",
+ "lin_pumpkins = new_pumpkins.drop([c for c in new_pumpkins.columns if c not in new_columns], axis='columns')\n",
+ "\n",
+ "lin_pumpkins\n"
+ ]
+ },
+ {
+ "source": [
+ "Set X and y arrays to correspond to Package and Price"
+ ],
+ "cell_type": "markdown",
+ "metadata": {}
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "X = lin_pumpkins.values[:, :1]\n",
+ "y = lin_pumpkins.values[:, 1:2]\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Model Accuracy: 0.3315342327998989\n"
+ ]
+ }
+ ],
+ "source": [
+ "from sklearn.linear_model import LinearRegression\n",
+ "from sklearn.metrics import r2_score, mean_squared_error, mean_absolute_error\n",
+ "from sklearn.model_selection import train_test_split\n",
+ "\n",
+ "\n",
+ "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)\n",
+ "lin_reg = LinearRegression()\n",
+ "lin_reg.fit(X_train,y_train)\n",
+ "\n",
+ "pred = lin_reg.predict(X_test)\n",
+ "\n",
+ "accuracy_score = lin_reg.score(X_train,y_train)\n",
+ "print('Model Accuracy: ', accuracy_score)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 41,
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "[[33.627655]]\n"
+ ]
+ }
+ ],
+ "source": [
+ "import pickle\n",
+ "s = pickle.dumps(lin_reg)\n",
+ "model_filename = 'lin-reg-model.pkl'\n",
+ "# Open the file to save as pkl file\n",
+ "pickle.dump(lin_reg, open(model_filename,'wb'))\n",
+ "\n",
+ "model = pickle.load(open('lin-reg-model.pkl','rb'))\n",
+ "print(model.predict([[2.85]]))\n",
+ "\n",
+ "# Close the pickle instances\n",
+ "# clf2 = pickle.loads(s)\n",
+ "# clf2.predict([[2.75]])\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ]
+}
\ No newline at end of file
diff --git a/API/1-API/translations/README.es.md b/API/1-API/translations/README.es.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/API/README.md b/API/README.md
new file mode 100644
index 000000000..c153afb7c
--- /dev/null
+++ b/API/README.md
@@ -0,0 +1,11 @@
+# Getting Started with
+
+In this section of the curriculum, you will be introduced to ...
+
+## Topics
+
+1. [Build an API for your model](1-API/README.md)
+
+## Credits
+
+"Build an API" was written with ♥️ by [Jen Looper](https://twitter.com/jenlooper)
\ No newline at end of file
diff --git a/API/translations/README.es.md b/API/translations/README.es.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/Regression/3-Linear/solution/notebook.ipynb b/Regression/3-Linear/solution/notebook.ipynb
index 8d9809c3b..438f3ef2c 100644
--- a/Regression/3-Linear/solution/notebook.ipynb
+++ b/Regression/3-Linear/solution/notebook.ipynb
@@ -10,13 +10,17 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.8.3-final"
+ "version": "3.7.0"
},
"orig_nbformat": 2,
"kernelspec": {
- "name": "python3",
- "display_name": "Python 3",
- "language": "python"
+ "name": "python37364bit8d3b438fb5fc4430a93ac2cb74d693a7",
+ "display_name": "Python 3.7.0 64-bit ('3.7')"
+ },
+ "metadata": {
+ "interpreter": {
+ "hash": "70b38d7a306a849643e446cd70466270a13445e5987dfa1344ef2b127438fa4d"
+ }
}
},
"nbformat": 4,
@@ -38,7 +42,7 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 2,
"metadata": {},
"outputs": [
{
@@ -71,7 +75,7 @@
"text/html": "\n\n
\n \n \n \n City Name \n Type \n Package \n Variety \n Sub Variety \n Grade \n Date \n Low Price \n High Price \n Mostly Low \n ... \n Unit of Sale \n Quality \n Condition \n Appearance \n Storage \n Crop \n Repack \n Trans Mode \n Unnamed: 24 \n Unnamed: 25 \n \n \n \n \n 0 \n BALTIMORE \n NaN \n 24 inch bins \n NaN \n NaN \n NaN \n 4/29/17 \n 270.0 \n 280.0 \n 270.0 \n ... \n NaN \n NaN \n NaN \n NaN \n NaN \n NaN \n E \n NaN \n NaN \n NaN \n \n \n 1 \n BALTIMORE \n NaN \n 24 inch bins \n NaN \n NaN \n NaN \n 5/6/17 \n 270.0 \n 280.0 \n 270.0 \n ... \n NaN \n NaN \n NaN \n NaN \n NaN \n NaN \n E \n NaN \n NaN \n NaN \n \n \n 2 \n BALTIMORE \n NaN \n 24 inch bins \n HOWDEN TYPE \n NaN \n NaN \n 9/24/16 \n 160.0 \n 160.0 \n 160.0 \n ... \n NaN \n NaN \n NaN \n NaN \n NaN \n NaN \n N \n NaN \n NaN \n NaN \n \n \n 3 \n BALTIMORE \n NaN \n 24 inch bins \n HOWDEN TYPE \n NaN \n NaN \n 9/24/16 \n 160.0 \n 160.0 \n 160.0 \n ... \n NaN \n NaN \n NaN \n NaN \n NaN \n NaN \n N \n NaN \n NaN \n NaN \n \n \n 4 \n BALTIMORE \n NaN \n 24 inch bins \n HOWDEN TYPE \n NaN \n NaN \n 11/5/16 \n 90.0 \n 100.0 \n 90.0 \n ... \n NaN \n NaN \n NaN \n NaN \n NaN \n NaN \n N \n NaN \n NaN \n NaN \n \n \n
\n
5 rows × 26 columns
\n
"
},
"metadata": {},
- "execution_count": 1
+ "execution_count": 2
}
],
"source": [
@@ -86,7 +90,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 3,
"metadata": {},
"outputs": [
{
@@ -103,7 +107,7 @@
"text/html": "\n\n
\n \n \n \n Month \n Variety \n City \n Package \n Low Price \n High Price \n Price \n \n \n \n \n 70 \n 1 \n 3 \n 1 \n 0 \n 5 \n 3 \n 13.636364 \n \n \n 71 \n 1 \n 3 \n 1 \n 0 \n 10 \n 7 \n 16.363636 \n \n \n 72 \n 2 \n 3 \n 1 \n 0 \n 10 \n 7 \n 16.363636 \n \n \n 73 \n 2 \n 3 \n 1 \n 0 \n 9 \n 6 \n 15.454545 \n \n \n 74 \n 2 \n 3 \n 1 \n 0 \n 5 \n 3 \n 13.636364 \n \n \n
\n
"
},
"metadata": {},
- "execution_count": 2
+ "execution_count": 3
}
],
"source": [
@@ -139,25 +143,25 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 4,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
- ""
+ ""
]
},
"metadata": {},
- "execution_count": 3
+ "execution_count": 4
},
{
"output_type": "display_data",
"data": {
"text/plain": "",
- "image/svg+xml": "\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n