Skip to content

Instantly share code, notes, and snippets.

View stephlocke's full-sized avatar

Steph Locke stephlocke

View GitHub Profile
@stephlocke
stephlocke / mora.R
Last active April 6, 2024 01:37
Additive or multiplicative time series?
if(!require("ggseas")) install.packages("ggseas")
if(!require("forecast")) install.packages("forecast")
if(!require("data.table")) install.packages("data.table")
if(!require("knitr")) install.packages("knitr")
library(ggseas)
library(forecast)
library(data.table)
# Get data
@stephlocke
stephlocke / app.R
Last active April 2, 2024 09:21
Demo shiny app for multiple file uploads and a single read step
library(shiny)
library(data.table)
ui <- fluidPage(
titlePanel("Multiple file uploads"),
sidebarLayout(
sidebarPanel(
fileInput("csvs",
label="Upload CSVs here",
multiple = TRUE)
This post provides an overview of performing diagnostic and performance evaluation on logistic regression models in R. After training a statistical model, it’s important to understand how well that model did in regards to it’s accuracy and predictive power. The following content will provide the background and theory to ensure that the right technique are being utilized for evaluating logistic regression models in R.
Logistic Regression Example
We will use the GermanCredit dataset in the caret package for this example. It contains 62 characteristics and 1000 observations, with a target variable (Class) that is allready defined. The response variable is coded 0 for bad consumer and 1 for good. It’s always recommended that one looks at the coding of the response variable to ensure that it’s a factor variable that’s coded accurately with a 0/1 scheme or two factor levels in the right order. The first step is to partition the data into training and testing sets.
```
library(caret)
data(GermanCredit)
Train <- cr
@stephlocke
stephlocke / sqlbitsRcode.R
Last active July 18, 2023 01:43
Initial R code for looking at sqlbits tracks
# get html from url
library(RCurl)
library(XML)
library(data.table)
library(ggplot2)
url <- "http://sqlbits.com/information/PublicSessions.aspx"
src<-getURL(url)
# transform html
@stephlocke
stephlocke / AggLookup
Last active November 15, 2022 05:20
Custom aggregate function for use with Lookup joined datasets in SSRS
'Allows aggregation of a multilookup cell and can be configured by the user
'To use add this expression to a cell's expression window:
'=code.AggLookup([aggregate choice as string], LookupSet([Local Column], [Match Column], [Return Column], [Dataset as string]))
'
'Available aggregate choices are count, sum, min, max and avg
Function AggLookup(ByVal choice as String, ByVal items as Object)
'Ensure the LookupSet array provided is not empty
If items is Nothing then
Return Nothing
@stephlocke
stephlocke / git.md
Created August 8, 2022 14:22
A brief intro to Git!

Source control

Source control concepts

Source control is a system for tracking changes to files over time.

What's the point?

  • No version hell
@stephlocke
stephlocke / twittermgmt.R
Last active February 16, 2022 14:28
A gist demonstrating how to retrieve the people you follow, assign them to lists, and unfollow in batches
library(rtweet) #' uses v0.7.0.9012 or higher
library(tidyverse)
## authenticate via web browser
auth_setup_default()
## people i follow
follow <- get_friends("theStephLocke")
## their user data
follow_deets <- lookup_users(follow$to_id)
@stephlocke
stephlocke / example.yaml
Created December 1, 2020 11:46
gh actione xample
name: Generate Word docs
on: push
jobs:
convert_via_pandoc:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: convert md to docx
uses: docker://pandoc/latex:2.9
@stephlocke
stephlocke / ethicaldatascience.md
Created September 20, 2018 16:08
Some links and resources around ethical data science

Ethical data science

Intro

Who I am

Purpose / Agenda

Problems caused

Facial recognition

Justice system

Access to finance

Ethical obligation

@stephlocke
stephlocke / extract.pq
Created November 9, 2020 09:09
Get and transform NomCom table in Power Query
let
Source = Web.Page(Web.Contents("https://www.pass.org/Governance/Elections")),
Data5 = Source{5}[Data],
#"Changed Type" = Table.TransformColumnTypes(Data5,{{"", type text}, {"Joey D'Antoni", type number}, {"Lori Edwards", type number}, {"Roberto Fonseca", type number}, {"Matt Gordon", type number}, {"Stephanie Locke", type number}, {"Jose L. Rivera", type number}, {"Hamish Watson", type number}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"", "Area"}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Renamed Columns", {"Area"}, "Attribute", "Value"),
#"Renamed Columns1" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Candidate"}})
in
#"Renamed Columns1"