Skip to content

Instantly share code, notes, and snippets.

View Btibert3's full-sized avatar

Brock Tibert Btibert3

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Btibert3
Btibert3 / shooter-embeddings-r-python.RMD
Created February 29, 2020 20:21
Use RMarkdown and knitr to estimate shooter embeddings in R and python via Tensorflow at the same time.
---
title: Tensorflow, Tip-Ins, and Tableau, Oh My
author: Brock Tibert
date: '2020-02-18'
slug: tensorflow-tip-ins-and-tableau-oh-my
categories:
- R
tags:
- NHL
- Tensorflow
# timestamp tz conversion
DATE = "2020-01-23 13:23:45"
lubridate::ymd_hms(DATE)
ts = lubridate::ymd_hms(DATE, tz = "America/Los_Angeles")
ts
lubridate::with_tz(ts, tzone = "America/New_York")
ts_eastern = lubridate::with_tz(ts, tzone = "America/New_York")
lubridate::with_tz(ts, tzone = "UTC")
utc = lubridate::with_tz(ts, tzone = "UTC")
as.character(utc)
@Btibert3
Btibert3 / hclust-eval.R
Created October 16, 2019 14:05
A simple function to explore hclust in R to look at distance/cluster tradeoff
## function to take an dendrogram, and heights for each iteration
## pull out the # of clusters and height
hclust_eval = function(c) {
# extract the height, and the dendrogram
h = c$height
d = as.dendrogram(c)
# the container for the stats
s = list()
# for each entry in h, get the # of clusters
# TODO: improve this code
@Btibert3
Btibert3 / environment.yml
Created October 14, 2019 23:33
R 3.6 test for Azure Notebooks
name: r_env
channels:
- conda-forge
- defaults
dependencies:
- _r-mutex=1.0.1=anacondar_1
- appnope=0.1.0=py37_1000
- attrs=19.2.0=py_0
- backcall=0.1.0=py_0
- bleach=3.1.0=py_0
options(stringsAsFactors = FALSE)
#################### setup
## define the vectors
poker_vector <- c(140, -50, 20, -120, 240)
roulette_vector <- c(-24, -50, 100, -350, 10)
## we are covering named vectors in the module 3 Friday
@Btibert3
Btibert3 / README.md
Last active December 23, 2018 21:45
Command Line Option Parsing for R
@Btibert3
Btibert3 / install.md
Created October 11, 2018 22:18
Install spark for datascience on python and r

Python

Create your environment using Anaconda miniconda for python environments

conda create -n spark python=3

Activate the environment

@Btibert3
Btibert3 / README.md
Last active August 5, 2018 22:15
This R function builds a rasa NLU training data file

About

This R script provides a helper function to take a dataframe, and build a proper rasa NLU training file in JSON format. This would be helpful for when you want to:

  • export records from a database
  • import the training data file into the webapp found here: https://rasahq.github.io/rasa-nlu-trainer/
  • tag your data with the tool and export
  • re-import the JSON into R and associate with the database ID
@Btibert3
Btibert3 / calc_age.r
Created July 17, 2018 02:40 — forked from mmparker/calc_age.r
Calculate years of age at a given date
# Calculate age at a given reference date
# Create an interval between the date of birth and the enrollment date;
# intervals are specific to the two dates. Periods give the actual length
# of time between those dates, so convert to period and extract the year.
calc_age <- function(birthDate, refDate = Sys.Date()) {
require(lubridate)