Build the script kag

This is used for

  • Downloading datasets to an organised directory structure
  • Viewing CSV results in visidata by default
  • Keeping track of history
  • Caching results

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
export TTY

( hs "$(basename "$0")" "$@" "#" "<==" "$(ps -o comm= $PPID)" 0</dev/null ) &>/dev/null

is_tty() {
    # If stout is a tty
    [[ -t 1 ]]
}

slug="$(echo "$3" | slugify)"
dsname="$(echo "$3" | sed 's=.*/==')"

if test "$1 $2" = "datasets download"; then
    cd $DUMP$NOTES/ws/kaggle/datasets
    if test -d "$slug"; then
        zcd "$slug"
        exit 0
    fi
    mkdir -p "$slug"
    cd "$slug"
    kaggle "$@"
    unzip "$dsname".zip
    rm "$dsname".zip
    if is_tty; then
        zcd .
    fi
    exit 0
fi

if is_tty; then
    ci kaggle "$@" -v | tf csv | xa pvd
else
    ci kaggle "$@" -v
fi

Demonstration

GitHub project
https://github.com/trevorstephens/titanic/

Part 1: Booting Up R

asciinema recording

Part 2: The Gender-Class Model

asciinema recording

Dealing with the error

1
2
3
4
5
6
7
You can specify you libpath each time you
install with something like
install.packages("tidyverse", lib =
"/usr/lib/R/library") or you can set libpath
globally in your Rprofile.site file e.g.
.libPaths(c("/usr/local/lib/R/site-library",
"/usr/local/lib/R/library"))
1
l Rprofile.site
1
2
/etc/R/Rprofile.site
/usr/lib/R/etc/Rprofile.site
1
eww -c "https://whattheyforgot.org/r-startup.html"
1
2
1 .Renviron - which contains environment variables to be set in R sessions.
2 .Rprofile - which contains R code to be run in each session.
name location
Local config file $HOME/.Rprofile

Part 3: Decision Trees

Part 4: Feature Engineering

Part 5: Random Forests