This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
cs501r_f2016:lab1 [2016/08/29 16:27] admin created |
cs501r_f2016:lab1 [2021/06/30 23:42] (current) |
||
|---|---|---|---|
| Line 16: | Line 16: | ||
| {{:cs401r_w2016:lab1.png?nolink|}} | {{:cs401r_w2016:lab1.png?nolink|}} | ||
| - | **Part 2:** Your notebook should use the pandas library to read in the Rossman store sales data (a CSV dataset) and plot the sales of store #1. Your plot should look something like this: | + | **Part 2:** You must play with the Tensorflow playground neural network, and figure out how to create a classifier that successfully classifies the "spiral" dataset. |
| - | {{:cs401r_w2016:lab1_storesales.png?direct&700|}} | + | [[http://playground.tensorflow.org/|Tensorflow playground]] |
| - | + | ||
| - | Done correctly, this should only take a few lines of code. | + | |
| ---- | ---- | ||
| Line 28: | Line 26: | ||
| * 20% Successfully turned in a notebook with working code | * 20% Successfully turned in a notebook with working code | ||
| - | * 20% Random image with 50 random elements | + | * 35% Random image with 50 random elements |
| - | * 20% Correctly used pandas to load store sales data | + | * 35% Image indicating tensorflow success |
| - | * 30% Some sort of plot of sales data (only for store #1!) | + | |
| * 10% Tidy and legible figures, including labeled axes where appropriate | * 10% Tidy and legible figures, including labeled axes where appropriate | ||
| Line 37: | Line 34: | ||
| Throughout this class, we will be using a combination of ipython | Throughout this class, we will be using a combination of ipython | ||
| - | notebooks and the anaconda python distribution. For this lab, you | + | notebooks, Tensorflow and the anaconda python distribution. For this lab, you |
| must install anaconda, and write a simple python program (using | must install anaconda, and write a simple python program (using | ||
| - | ipython notebooks). As described above, the notebook should do two things: | + | ipython notebooks). |
| - | 1) generate simple random images, and 2) plot some data using pandas. | + | |
| + | As described above, the notebook should do two things: | ||
| + | 1) generate simple random images, and 2) display an image that you generate using the Tensorflow playground. | ||
| For part 1, you can generate any sort of random image that you want -- consider | For part 1, you can generate any sort of random image that you want -- consider | ||
| Line 50: | Line 49: | ||
| random images with moderate complexity. | random images with moderate complexity. | ||
| - | In preparation for future labs, we strongly encourage you to use the | + | For part 2, you should visit the Tensorflow playground (see link above), and play with different settings. Most of it will be unfamiliar, but don't worry -- you can't break it! |
| - | [[http://cairographics.org/|cairo]] package as part of your image generator. | + | |
| - | + | ||
| - | For part 2, the data you should use is downloadable here: | + | |
| - | [[http://hatch.cs.byu.edu/courses/stat_ml/store_train.csv|Rossman store sales data]] | + | Once you have a working classifier, take a screenshot. Then use your ipython notebook to display that image in-line. |
| ---- | ---- | ||
| Line 62: | Line 58: | ||
| http://docs.continuum.io/anaconda/install | http://docs.continuum.io/anaconda/install | ||
| - | To generate images, check out PIL and cairo: | + | To generate images, check out PIL. |
| - | + | ||
| - | ''conda install cairo'' | + | |
| To generate random numbers, check out the [[http://docs.scipy.org/doc/numpy-1.10.0/reference/routines.random.html|numpy.random]] module. | To generate random numbers, check out the [[http://docs.scipy.org/doc/numpy-1.10.0/reference/routines.random.html|numpy.random]] module. | ||
| Line 116: | Line 110: | ||
| nbimage( data ) | nbimage( data ) | ||
| </code> | </code> | ||
| - | |||
| - | ---- | ||
| - | ====Using Pandas:==== | ||
| - | |||
| - | For the second part of this lab, you will need to understand the ''pandas'' python package, just a little bit. For this lab, you only need to know how to select some data from a CSV file. | ||
| - | |||
| - | You should read through this tutorial and play with it. | ||
| - | |||
| - | [[http://synesthesiam.com/posts/an-introduction-to-pandas.html|Tutorial on using Pandas]] | ||
| - | |||
| - | For this lab, you need select the data for store #1 and plot it. | ||
| - | |||
| - | An important part of generating visualizations is conveying information cleanly and accurately. You should therefore label all axes, and in particular, the x-axis should be labeled using dates (See the example image). This involves a bit of python trickery, but check out some helpful functions in the hints below. | ||
| ---- | ---- | ||
| Line 138: | Line 119: | ||
| import matplotlib.pyplot as plt | import matplotlib.pyplot as plt | ||
| - | plt.plot_date | ||
| - | |||
| - | pandas.to_datetime | ||
| plt.legend | plt.legend | ||
| Line 148: | Line 126: | ||
| plt.tight_layout | plt.tight_layout | ||
| + | </code> | ||
| + | |||
| + | Also note that to get plots to show up inline, you may have to add the magic incantation **in the first cell**: | ||
| + | |||
| + | <code python> | ||
| + | |||
| + | %matplotlib inline | ||
| + | |||
| + | import matplotlib | ||
| + | import numpy as np | ||
| + | import matplotlib.pyplot as plt | ||
| + | |||
| + | </code> | ||
| + | |||
| + | Here is a full setup for cairo in linux. | ||
| + | <code> | ||
| + | sudo apt-get install libcairo2-dev | ||
| + | git clone https://github.com/pygobject/pycairo.git | ||
| + | cd pycairo/ | ||
| + | python setup.py build | ||
| + | python setup.py install | ||
| + | </code> | ||
| + | |||
| + | Here is a setup for cairo in mac. | ||
| + | <code> | ||
| + | brew install cairo --use-clang | ||
| + | brew install py2cairo | ||
| </code> | </code> | ||