image of bot

UMBC CMSC 471 02 Spring 2021
Introduction to Artificial Intelligence

 

Homework EX2: TensorFlow MLP for the Zoo Dataset

out Tue 5/7, due Wed 5/21

Assignment repository invitation

Overview

This is a simple extra credit homework that asks you to develop a jupyter notebook that implements simple multi-level preceptron in TensorFlow to work with the zoo_big dataset from HW5. It will give you some experience in preparing data for a neural network and using colab and TensorFlow.

There are many issues involved:

  • Adapting the data to make it appropriate for a neural network. You'll need to remove features that are not part of the machine learning task, make all of values numeric, and encode the final target class to be a set of integers starting with 0 and going up to the last class.
  • Loading your data into a colab notebook. Use the simple method of loading a csv files from your repository and creating numpy arrays from them
  • Putting the data into the form expected by TensorFlow, e.g., X and y
  • Developing a simple model in Kearas which will involves deciding on how many hidden layers to include and what hyperparameter settings work best.
  • Training the model
  • Experimenting with the model and its parameters to try to get a high accuracy while avoiding overfitting.
  • Saving the notebook to your local EX2 repository so that you can commit and push it to GitHub

There are also a few simple questions to answer in the repository file questions.md.

Colab or your own computer?

You can do this assignment using your own computer or colab. You can also try both!

To do this on your own computer, you will need a fairly recent version of Python (3.6 or better). You will have to use pip to install jupyter and all of the packages that you will find in the two notebooks, ex2.ipynb and ex2_wine_example.ipynb. Running these will not require much computation so you don't need to turn to colab for access to its GPUs. Once you have this all set go to your ex2 repository directory and invoke jupyter notebook. You can then use it to load ex2_wine_example.ipynb and you are off and running. Be sure to save the file if you are making changes that you want to keep.

To run this on colab, we suggest the following steps. But you will not need to pip install anything.

  • create a folder on Google drive for your ex2 notebooks
  • open this folder in google drive by clicking on it
  • do NEW > File Upload to upload the two ipynb files
  • click on the file ex2_wine_example.ipynb to start working with it
  • periodically click FILE > SAVE if you've made any changes you want to save
  • to download a copy to your computer click FILE > DOWNLOAD. You will probably have to then move it on your computer to your ex2 directory
  • Note that if you need to upload your data (e.g., one of the csv text files) to colab, you will be asked to navigate to your local computer's ex2 repo directory and click on the file

A worked example to try

Start by opening the notebook ex2_wine_example.ipynb. This example uses data from the UCI machine learning repository. The data has 11 attributes and a quality score for many white wine samples. You should walk through the notebook, reading the markup cells and running the code cells to try to understand it. feel free to experiment by changing cells, adding new ones, etc. To completely restart the notebook, you can restart the kernel and clear the output. If you've edited the notebook, you can always just close its window and reload the original.

The ex2.ipnb stub

When you are comfortable using the ex2_wine_example notebook and feel that you understand how it uses TensorFlow, you can move on to filling out the stub notebook ex2.ipnb. This has the cell you will need, but some are only partially filled in.

The data in zoo_big.csv needs to be reformatted to use in a neural network and save in a file named myzoo.csv. The stub ex2.ipynb will load this file. One issue is that all of the cell values need to be numeric. Another is that you should delete the first column, since it is of no use as training data. You might do some of these changes in a text editor. Others are easier to do in a spreadsheet system, like excel or good sheets. Save the modified data file as myzoo.csv.

you will have to fill in the partially completed code blocks in the notebook. You can use the somewhat more complicated wine example as a guide.

Final steps

When you have completed ex2.ipynb, be sure to save a copy in your repo. You can then answer the questions in questions.md. commit and push the results and you are done.