Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Update import statement #191

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
288 changes: 170 additions & 118 deletions module3-Intro-to-Keras/LS_DS_423_Keras_Assignment.ipynb
Original file line number Diff line number Diff line change
@@ -1,120 +1,172 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "pBQsZEJmubLs"
},
"source": [
"<img align=\"left\" src=\"https://lever-client-logos.s3.amazonaws.com/864372b1-534c-480e-acd5-9711f850815c-1524247202159.png\" width=200>\n",
"<br></br>\n",
"\n",
"# Neural Network Framework (Keras)\n",
"\n",
"## *Data Science Unit 4 Sprint 2 Assignment 3*\n",
"\n",
"## Use the Keras Library to build a Multi-Layer Perceptron Model on the Boston Housing dataset\n",
"\n",
"- The Boston Housing dataset comes with the Keras library so use Keras to import it into your notebook. \n",
"- Normalize the data (all features should have roughly the same scale)\n",
"- Import the type of model and layers that you will need from Keras.\n",
"- Instantiate a model object and use `model.add()` to add layers to your model\n",
"- Since this is a regression model you will have a single output node in the final layer.\n",
"- Use activation functions that are appropriate for this task\n",
"- Compile your model\n",
"- Fit your model and report its accuracy in terms of Mean Squared Error\n",
"- Use the history object that is returned from model.fit to make graphs of the model's loss or train/validation accuracies by epoch. \n",
"- Run this same data through a linear regression model. Which achieves higher accuracy?\n",
"- Do a little bit of feature engineering and see how that affects your neural network model. (you will need to change your model to accept more inputs)\n",
"- After feature engineering, which model sees a greater accuracy boost due to the new features?"
]
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "LS_DS_433_Keras_Assignment.ipynb",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "8NLTAR87uYJ-"
},
"outputs": [],
"source": [
"##### Your Code Here #####\n",
"\n",
"from tensorflow.keras.datasets import Boston"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "SfcFnOONyuNm"
},
"source": [
"## Use the Keras Library to build an image recognition network using the Fashion-MNIST dataset (also comes with keras)\n",
"\n",
"- Load and preprocess the image data similar to how we preprocessed the MNIST data in class.\n",
"- Make sure to one-hot encode your category labels\n",
"- The number of nodes in your output layer should equal the number of classes you want to predict for Fashion-MNIST.\n",
"- Try different hyperparameters. What is the highest accuracy that you are able to achieve.\n",
"- Use the history object that is returned from model.fit to make graphs of the model's loss or train/validation accuracies by epoch. \n",
"- Remember that neural networks fall prey to randomness so you may need to run your model multiple times (or use Cross Validation) in order to tell if a change to a hyperparameter is truly producing better results."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "szi6-IpuzaH1"
},
"outputs": [],
"source": [
"##### Your Code Here #####"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "zv_3xNMjzdLI"
},
"source": [
"## Stretch Goals:\n",
"\n",
"- Use Hyperparameter Tuning to make the accuracy of your models as high as possible. (error as low as possible)\n",
"- Use Cross Validation techniques to get more consistent results with your model.\n",
"- Use GridSearchCV to try different combinations of hyperparameters. \n",
"- Start looking into other types of Keras layers for CNNs and RNNs maybe try and build a CNN model for fashion-MNIST to see how the results compare."
]
}
],
"metadata": {
"colab": {
"name": "LS_DS_433_Keras_Assignment.ipynb",
"provenance": [],
"version": "0.3.2"
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "pBQsZEJmubLs"
},
"source": [
"<img align=\"left\" src=\"https://lever-client-logos.s3.amazonaws.com/864372b1-534c-480e-acd5-9711f850815c-1524247202159.png\" width=200>\n",
"<br></br>\n",
"\n",
"# Neural Network Framework (Keras)\n",
"\n",
"## *Data Science Unit 4 Sprint 2 Assignment 3*\n",
"\n",
"## Use the Keras Library to build a Multi-Layer Perceptron Model on the Boston Housing dataset\n",
"\n",
"- The Boston Housing dataset comes with the Keras library so use Keras to import it into your notebook. \n",
"- Normalize the data (all features should have roughly the same scale)\n",
"- Import the type of model and layers that you will need from Keras.\n",
"- Instantiate a model object and use `model.add()` to add layers to your model\n",
"- Since this is a regression model you will have a single output node in the final layer.\n",
"- Use activation functions that are appropriate for this task\n",
"- Compile your model\n",
"- Fit your model and report its accuracy in terms of Mean Squared Error\n",
"- Use the history object that is returned from model.fit to make graphs of the model's loss or train/validation accuracies by epoch. \n",
"- Run this same data through a linear regression model. Which achieves higher accuracy?\n",
"- Do a little bit of feature engineering and see how that affects your neural network model. (you will need to change your model to accept more inputs, a data dictionary is included at the bottom of the assignment)\n",
"- After feature engineering, which model sees a greater accuracy boost due to the new features?"
]
},
{
"cell_type": "code",
"metadata": {
"colab_type": "code",
"id": "8NLTAR87uYJ-",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 204
},
"outputId": "0c5c3f19-cb63-435f-ce29-e2380de67463"
},
"source": [
"from tensorflow.keras.datasets import boston_housing\n",
"\n",
"\n",
"dir(boston_housing)"
],
"execution_count": 5,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"['__builtins__',\n",
" '__cached__',\n",
" '__doc__',\n",
" '__file__',\n",
" '__loader__',\n",
" '__name__',\n",
" '__package__',\n",
" '__path__',\n",
" '__spec__',\n",
" '_sys',\n",
" 'load_data']"
]
},
"metadata": {
"tags": []
},
"execution_count": 5
}
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "SfcFnOONyuNm"
},
"source": [
"## Use the Keras Library to build an image recognition network using the Fashion-MNIST dataset (also comes with keras)\n",
"\n",
"- Load and preprocess the image data similar to how we preprocessed the MNIST data in class.\n",
"- Make sure to one-hot encode your category labels\n",
"- The number of nodes in your output layer should equal the number of classes you want to predict for Fashion-MNIST.\n",
"- Try different hyperparameters. What is the highest accuracy that you are able to achieve.\n",
"- Use the history object that is returned from model.fit to make graphs of the model's loss or train/validation accuracies by epoch. \n",
"- Remember that neural networks fall prey to randomness so you may need to run your model multiple times (or use Cross Validation) in order to tell if a change to a hyperparameter is truly producing better results."
]
},
{
"cell_type": "code",
"metadata": {
"colab_type": "code",
"id": "szi6-IpuzaH1",
"colab": {}
},
"source": [
"##### Your Code Here #####"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "zv_3xNMjzdLI"
},
"source": [
"## Stretch Goals:\n",
"\n",
"- Use Hyperparameter Tuning to make the accuracy of your models as high as possible. (error as low as possible)\n",
"- Use Cross Validation techniques to get more consistent results with your model.\n",
"- Use GridSearchCV to try different combinations of hyperparameters. \n",
"- Start looking into other types of Keras layers for CNNs and RNNs maybe try and build a CNN model for fashion-MNIST to see how the results compare."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "PM7f7KXi2FPg",
"colab_type": "text"
},
"source": [
"```Python\n",
" CRIM per capita crime rate by town\n",
" ZN proportion of residential land zoned for lots over 25,000 sq.ft.\n",
" INDUS proportion of non-retail business acres per town\n",
" CHAS Charles River dummy variable (= 1 if tract bounds river; 0 otherwise)\n",
" NOX nitric oxides concentration (parts per 10 million)\n",
" RM average number of rooms per dwelling\n",
" AGE proportion of owner-occupied units built prior to 1940\n",
" DIS weighted distances to five Boston employment centres\n",
" RAD index of accessibility to radial highways\n",
" TAX full-value property-tax rate per $10,000\n",
" PTRATIO pupil-teacher ratio by town\n",
" B 1000(Bk - 0.63)^2 where Bk is the proportion of blacks by town\n",
" LSTAT % lower status of the population\n",
" MEDV Median value of owner-occupied homes in $1000's\n",
" ```"
]
}
]
}