Assignments


Final: (due Friday May 12, 2023)

This is a take-home Final Exam. You may ask questions of the Professor or search Google. This is exam is to be completed independently. Submit your .html or .pdf file and your .qmd file for each Part.

Part 1: Make an Quarto notebook with the file name lastname_firstname_Stat654_final_part1.qmd and do the following:

Read the excellent blog post from the Data Science Heroes website, How to create a sequential model in Keras for R.

  1. Run all of the code in this blog post in your Quarto Notebook and explain each step presented. Clearly describe what kind of neural network is being fitted.
  2. Change the neural network to use units = 4 for the first hidden layer and units = 2 for the second layer. Change the number of epochs = 40 in the fit(). How well does this neural network perform compared to the original neural network run?
  3. Note the use of one-hot encoding in the code. What is one-hot encoding and why is it used in this code? Why is activation = “softmax” used in the output layer? How does this code differ from using activation = “sigmoid” in the output layer?

Part 2: Make an Quarto notebook with the file name lastname_firstname_Stat654_final_part2.qmd and do the following:

Go to Alex Krizhevsky website and look over the The CIFAR-10 dataset. This is an interesting dataset with 10 different labeled classes of images.

Run all of the code from the Posit Keras website Example cfar10 and explain each step presented. Clearly describe what kind of neural network is being fitted.

First change the number of epochs to a value <= 50 (current value is 50, at the top), so it does not run forever. This program will take a long time to run. Does it appear that it has run long enough?

Suggestions: If you are having a hard time Rendering your Notebook into an .html or .pdf this code may be beyond the capability of your computer hardware. Try to reduce the epoch variable to 50 or less, maybe 20, to see if that helps. If that does not solve the problem, run the code outside of a Notebook and copy the relevant code into a .docx file and add your comments to that file.

Part 3: Finally found a way to identify objects in a picture. The neural network to do this is called Yolo. Here is a blog post about how to use Yolo in R. Object detection in just 3 lines of R code using Tiny YOLO and the ggnot2 YouTube video Image Classification and Object Detection in R using just TWO lines of code!

To install the R package image.darknet you may need to download the install from the website:

https://github.com/bnosac/drat

Suggestions: The main output to submit is the predictions.png file which is not visible when Rendering the Notebook. I would suggest submitting the .png file directly or copying the original image and the predictions.png file into a .docx file and add your comments.


Homework06: (not collected)

Using a Quarto Notebook produce your output from running the code from the book in Chapter . Render the .qmd files to either Lastname_Firstname_Stat652_hw3.docx or .pdf. Use your own last name and first name in the filename. At the top of your first page you should include Name, Class, Section, and homework assignment.

The header of your R Notebooks should include

title: "Stat. 654 Homework 6"

author: "Your name"

Problems:


Homework05: (complete by Monday April 22, 2024)

The header of your R Notebooks should include

---
title: "Stat. 654 Homework 5"
author: "Your name"
date: "April 22, 2024"
format:
  html:
    self-contained: true
---

Submit: Submit your Quarto Notebooks or shared CoLab Notebooks. You can share the CoLab Notebooks with me by providing the links in Canvas. If you use Quarto Notebooks, you can submit both your .qmd and .html files.


Project: (due Monday April 29, 2024)

Make a stylized picture. Using AI/Neural Network.

The goal of the Project is to run the style transfer code from Chapter 12 Section 3 on a picture of interest to you using a style of painting you like.

Next get the code from Chapter 12 Section 3, Neural Style Transfer, to run.

Submit: Submit your Quarto Notebooks or shared CoLab Notebooks. You can share the CoLab Notebooks with me by providing the links in Canvas. If you use Quarto Notebooks, you can submit both your .qmd and .html files.


Midterm: (due Monday April 22, 2024)

Instructions: This is a take-home midterm. Your work is to be completed individually. You may use your book, Google, and questions can be asked of the instructor. You are not to share code with others in the class.

Using a Quarto Notebook produce your solutions to questions 1, 3, and 4. Turn in your modified Quarto Notebook for the IMDB code from Section 3.4 and an updated ver02 of the code provided for question 5, submit your .qmd and .html files. So you should submit three .qmd files and the corresponding .docx or .pdf files.

  1. Explain what a tensor is in words. In words describe examples of 2D, 3D, 4D, and 5D tensors.
    1. Write you own explanation.
    2. Prompt Microsoft CoPilot or groq.com to generate an explanation.
  2. In Section 4.1 of the Deep Learning with R book, the IMDB example is presented. Explain what the data being fitted is and what the input layer does in the neural network used in that section. Run the code from that example, try adding dropout layer(s) to see if the fit can be improved.
  3. When using the Gradient Descent Algorithm and Backpropogation, in which direction do updates move?
    1. Write you own explanation.
    2. Prompt Microsoft CoPilot or groq.com to generate an explanation.
  4. Explain what a Convolutional Neural Network is in words. How does a convnet compare to the traditional feedforward neural network?
    1. Write you own explanation.
    2. Prompt Microsoft CoPilot or groq.com to generate an explanation.
  5. Run the code from the book, A Computational Approach to Statistical Learning, from Chapter 8 casl Chapter 8. This example is related to the EMNIST dataset. Read the sample chapter Chapter 8. Use Meld to merge the changes from ver01 into ver02 of the R Notebook. Your assignment is to run the code in ver02 and write clear explanations above each R code chunk. Be sure to explain what a Feed-forward Neural Network is and what the Convolutional layers are.

Question 5:


Quiz: (due Monday April 15, 2024)

Build a Feed-Forward Neural Network, with one hidden layer, for the Palmer Penguins data using keras/tensorflow. Using the numeric columns in the penguins dataset, bill_length_mm, bill_depth_mm, flipper_length_mm, body_mass_g, build a classification model for the species variable. Add a dropout layer using a rate of .5 and compare the results without dropout.

Note that the NA values need to be dropped or imputed before scaling the data to be used as input in the Neural Network model. Neural Networks do not run with missing values. (Alternatively, try replacing the missing values with the value 0. Is this a legitimate way to handle missing values?)

See the iris code from Week 1 as a template. Change the iris data to the penguins data. And finally refit the model using a .5 dropout rate.

Submit: Submit your Quarto Notebooks or shared CoLab Notebooks. You can share the CoLab Notebooks with me by providing the links in Canvas. If you use Quarto Notebooks, you can submit both your .qmd and .html files.


Homework04: (complete by Monday April 15, 2024)

Using a Quarto Notebook produce your output from running the code from the book in Chapter 8. Render the .qmd files to either Lastname_Firstname_Stat652_hw4.docx or .pdf. Use your own last name and first name in the filename. At the top of your first page you should include Name, Class, Section, and homework assignment.

The header of your R Notebooks should include

---
title: "Stat. 654 Homework 4"
author: "Your name"
date: "April 15, 2024"
format:
  html:
    self-contained: true
---

Submit: Submit your Quarto Notebooks or shared CoLab Notebooks. You can share the CoLab Notebooks with me by providing the links in Canvas. If you use Quarto Notebooks, you can submit both your .qmd and .html files.


Homework03: (complete by Monday April 8, 2024)

Using three Quarto or shared Colab Notebooks produce your output from running the code from the book in Chapter 3 and 4.

At the top of your first page of each Notebook you should include Name, Class, Section, and homework assignment.

The header of your Quarto Notebooks should include

---
title: "Stat. 654 Homework 3"
author: "Your name"
date: "April 8, 2024"
format:
  html:
    self-contained: true
---

Submit: Submit your Quarto Notebooks or shared CoLab Notebooks. You can share the CoLab Notebooks with me by providing the links in Canvas. If you use Quarto Notebooks, you can submit both your .qmd and .html files.


Homework02: (complete by Monday March 25, 2023)

Using three Quarto or shared Colab Notebooks produce your output from running the code from the book in Chapter 4.

At the top of your first page of each Notebook you should include Name, Class, Section, and homework assignment.

The header of your Quarto Notebooks should include

---
title: "Stat. 654 Homework 2"
author: "Your name"
date: "March 25, 2024"
format:
  html:
    self-contained: true
---

Submit: Submit your Quarto Notebooks or shared CoLab Notebooks. You can share the CoLab Notebooks with me by providing the links in Canvas. If you use Quarto Notebooks, you can submit both your .qmd and .html files.


Homework01: (complete by Monday March 18, 2024)

Using four separate Quarto or shared CoLab Notebooks produce your output from running the code from the examples and from the book Chapter 2.

At the top of your first page of each Notebook you should include Name, Class, Section, and homework assignment.

The header of your Quarto Notebooks should include

---
title: "Stat. 654 Homework 1"
author: "Your name"
date: "March 18, 2024"
format:
  html:
    self-contained: true
---

Submit: Submit four Quarto Notebooks or shared CoLab Notebooks. You can share the CoLab Notebooks with me by providing the links in Canvas. If you use Quarto Notebooks, you can submit both your .qmd and .html files.