---
title: "ACCT 420: Group presentations"
author: 
  - name: Dr. Richard M. Crowley
    email: rcrowley@smu.edu.sg
    affiliation: https://rmc.link/
title-slide-attributes:
  data-background-video: "../Backgrounds/title.mp4"
  data-background-video-loop: "true"
  data-background-size: stretch
format:
  revealjs:
    theme: default
    css: quarto_white.css
    navigation-mode: vertical
    controls: true
    transition: slide
    background-transition: fade
    transition-speed: default
    width: 1536
    height: 864
    logo: ../Logos/logo2.png
    code-link: true
    code-line-numbers: false
    chalkboard:
      theme: whiteboard
    auto-stretch: false
revealjs-plugins:
  - attribution
execute:
  echo: true
  warning: false
  message: false
editor: source
---

# Front Matter {data-background-video="../Backgrounds/section.mp4" data-background-video-loop="true"}

<!--# Note that the downlit and xml2 pacakges are required to compile -->
<!--# Installed extensions include `attribution`, `qrcode`, and `material-icons` -->

```{r helpers, echo=FALSE, warning=FALSE, message=F}
library(knitr)
library(kableExtra)

#' Pretty formatted HTML tables
#' 
#' @param df The dataframe to format as a table
#' @param names Names to use for columns if not using the df column names. Vector
#' @param highlight_cols Columns to highlight. Default is c(1) for highlighting the first row. Use c() to remove.
#' @param highlight_rows Rows to highlight. Default is c() to not highlight any rows.
#' @param color_rows Rows to highlight in color. Default is c() to not highlight any rows.
#' @param highlight_end_rows Rows to highlight. Uses a reverse indexing where 1 is the last row, 2 is second to last, etc.
#' @param full Use to span the full width of a slide. FALSE by default.
#' @param fixed_header Whether the first row should be treated as a header row. TRUE by default.
html_df <- function(df, names=NULL, highlight_cols=c(1), highlight_rows=c(), color_rows=c(), highlight_end_rows=c(), full=F, fixed_header=T) {
  if(!length(names)) {
    names=colnames(df)
  }
  kbl(df,"html", col.names = names, align = c("l",rep('c',length(cols)-1))) %>%
    kable_paper(c("striped","hover"), full_width=full, fixed_thead=F, html_font = "\"Source Sans Pro\", Helvetica, sans-serif") %>%
    {if(length(highlight_cols)) column_spec(., highlight_cols,bold=T, background = "#ffffff99") else .} %>%
    {if(length(highlight_rows)) row_spec(., highlight_rows,bold=T, background = "#ffffff99") else .} %>%
    {if(length(color_rows)) row_spec(., color_rows,bold=T, background = "#aaaaff99") else .} %>%
    {if(length(highlight_end_rows)) row_spec(., nrow(df) + 1 - highlight_end_rows,bold=T, background = "#ffffff99") else .}
}

library(tidyverse)
```

<!--# List packages here that are not being correctly highlighted -->
<!--# The usual cause is calling the library from a echo=FALSE cell -->

```{r}
#| include: false
options(downlit.attached = c("knitr", "kableExtra", "tidyverse"))
```

## Learning objectives {data-background="../Backgrounds/default.jpg"}

:::: columns

::: {.column width="50%"}

![](../Course_Diagrams/Map.png){fig-alt="Roadmap for the course"}

:::

::: {.column width="50%"}
- Show off what you came up with
- Learn from classmates' approaches to:
    - Fraud detection
    - Accounting error prediction
    - Twitter follower prediction
:::

::::

## Ground Rules {data-background="../Backgrounds/default.jpg"}

- 12-15 minutes per group
    - You'll get a 3 minute warning at 12 minutes
- When not presenting
    - Give your full attention
    - Feel free to ask questions after presentations

# Group projects {data-background-video="../Backgrounds/section.mp4" data-background-video-loop="true"}

## Presentation order  {data-background="../Backgrounds/presentation.jpg"}

1. Group 2 (Predicting follower counts)
2. Group 3 (Predicting follower counts)
3. Group 5 (Detecting Intentional Accounting Errors)
4. Break
5. Group 1 (Stock returns & Twitter)
6. Group 6 (Detecting Intentional Accounting Errors)
7. Group 4 (Predicting follower counts)
8. Break
9. Presentation by H2O.ai

# End matter {data-background-video="../Backgrounds/section.mp4" data-background-video-loop="true"}

## Course Recap {data-background="../Backgrounds/ending.jpg"}

- What did you learn in this course?
    1. Coding in R (for analytics)
    2. Linear models for predicting financials
    3. Logistic models binary prediction
        - Shipping delays
        - Bankruptcy
        - Fraud
    4. How to work with relevant unstructured data
    5. Many other useful models for understanding text, images, etc.
 
## What's left? {data-background="../Backgrounds/ending.jpg"}

- Assignment 4
    - I'll post some short review slides for this after the deadline
- Office hours
    - Book online using the link on eLearn
- Final Exam
    - November 24 at 2:30pm
- Surveys:

:::: {.columns}

::: {.column width="50%"}

**On the course overall**

{{< qrcode https://rmc.link/420final qrfinal width=200 height=200 >}}

:::

::: {.column width="50%"}

**Final class + group projects**

{{< qrcode https://rmc.link/420survey11 qrsurvey width=200 height=200 >}}

:::

::::

## For the future {data-background="../Backgrounds/ending.jpg"}

- If you have anything analytics related you would like to discuss, feel free to contact me some time down the line
- If you would like to stay up to date on analytics events, happenings, and techniques I post such things on my Twitter account from time to time
    - <a href="https://twitter.com/prof_rmc">@prof_rmc</a>

## {data-background="../Backgrounds/neural-net.jpg"}

![](../Figures/wordcloud_end3.png){width="1000px" fig-align="center"}

```{r, message=F, warning=F, echo=F, include=F, eval=F}
library(tidyverse)
# Note: Slide text scrubbed is a cleaned variant of Slide_text.txt, generated from Slide_text_pull.py (in the Data folder)
text <- read_file("../../Data/Slide_text_scrubbed.txt")
library(tidytext)
df_doc <- data.frame(text=c(text),
                     stringsAsFactors = F) %>%
  unnest_tokens(word, text)
library(stopwords)
df_doc <- df_doc %>%
  anti_join(data.frame(word=stopwords(source="smart"), stringsAsFactors = F))
terms <- df_doc %>%
  count(word, sort=TRUE) %>%
  ungroup() %>%
  rename(freq=n)

write_file(text,"../text_scrubbed.txt")
library(wordcloud2) # Install from Github required
#png("../Figures/wordcloud_end.png", width = 3200, height = 2400, res=400)
# as.data.frame(terms)
wordcloud2(demoFreq, figPath="../Figures/END_mask.png")
#dev.off()
#library("magick")
#wc <- image_read("Figures/wordcloud.png")
#wc <- image_crop(wc,"2200x2200+500+100")
#image_write(wc, path = "Backgrounds/wordcloud.png", format = "png")
#file.remove("Figures/wordcloud.png")
```







# End Matter {data-background-video="../Backgrounds/section.mp4"}

## Wrap up {data-background="../Backgrounds/ending.jpg"}



- Survey on the class session at this QR code:

{{< qrcode https://docs.google.com/forms/d/e/1FAIpQLSc9rHKLMH-ZfZwI-LzhmV-2sVnW5Md6muW2h1BFLxCwixpvDQ/viewform?usp=sf_link qrsurvey width=200 height=200 >}}

## Packages used for these slides {data-background="../Backgrounds/code.jpg" visibility="uncounted"}


- `{DT}`
- `{downlit}`
- `{kableExtra}`
- `{knitr}`
- `{plotly}`
- `{quarto}`
- `{revealjs}`
- `{stopwords}`
- `{tidytext}`
- `{tidyverse}`
- `{wordcloud2}`

## Custom code: Wordcloud {data-background="../Backgrounds/code.jpg" class="small" visibility="uncounted"}

```{r, eval=F}
library(tidyverse)
# Note: Slide text scrubbed is a cleaned variant of Slide_text.txt
#       generated from Slide_text_pull.py (in the Data folder)
text <- read_file("../../Data/Slide_text_scrubbed.txt")
library(tidytext)
df_doc <- data.frame(text=c(text),
                     stringsAsFactors = F) %>%
  unnest_tokens(word, text)
library(stopwords)
df_doc <- df_doc %>%
  anti_join(data.frame(word=stopwords(source="smart"), stringsAsFactors = F))
terms <- df_doc %>%
  count(word, sort=TRUE) %>%
  ungroup() %>%
  rename(freq=n)

write_file(text,"../text_scrubbed.txt")
library(wordcloud2) # Install from Github required
wordcloud2(demoFreq, figPath="../Figures/END_mask.png")
```

- [Link to mask file](../Figures/END_mask.png)

## NOTES {class="never"}


