Skip to content

Instantly share code, notes, and snippets.

View pmbaumgartner's full-sized avatar

Peter Baumgartner pmbaumgartner

View GitHub Profile
/*the pvalue10.7 below is where you change the number of decimal places you want.*/
/*the default value here will give you 10 digits to the 7th decimal place.*/
ods path sasuser.templat(update) sashelp.tmplmst(read);
proc template;
edit Common.PValue;
notes "Default p-value column";
just = r;
format = pvalue10.7;
end;
@pmbaumgartner
pmbaumgartner / proc export to csv
Last active December 22, 2015 08:19
PROC EXPORT to Comma Separated Values (.csv) file
libname data "your-data-location";
proc export data=data.dataset
outfile="your-data-location\filename.csv"
dbms=csv;
run;
@pmbaumgartner
pmbaumgartner / Logistic Regression
Last active March 13, 2019 15:40
Tutorial on Logistic Regression
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##Logistic Regression - Python Demonstration\n",
"**This script will run a logistic regression on our demo dataset. The goal is to predict whether a customer will buy a subscription to a magazine based on a number of factors.**\n",
"\n",
"###Steps:\n",
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##K-Nearest Neighbors - Python Demonstration\n",
"**This script will run a k-Nearest Neighbors algorithm on our demo dataset. The goal is to classify a `Favorable` or `Unfavorable` response based on a customer's `Age` and `Sales` variables.**\n",
"\n",
"###Steps:\n",
@pmbaumgartner
pmbaumgartner / slack_slash-hello_world.py
Last active December 15, 2015 01:49
creating a simple hello world app for a Slack slash command.
from flask import Flask
import os
app = Flask(__name__)
@app.route("/hello", methods=['POST'])
def hello():
return "Hello World!"
if __name__ == '__main__':
@pmbaumgartner
pmbaumgartner / slack_slash-hello_world_json.py
Last active December 15, 2015 17:51
Creating a JSON Response to a Slack Slash Request
from flask import Flask, request, make_response
import json
import os
app = Flask(__name__)
@app.route("/hello", methods=['POST'])
def hello():
# grab the post request
@pmbaumgartner
pmbaumgartner / sklearn_custom_scorer_labels.py
Last active August 14, 2018 17:12
Making a custom scorer in sklearn that only looks at certain labels when calculating model metrics. For example: This creates a f1_macro scorer object that only looks at the '-1' and '1' labels of a target variable.
from sklearn.metrics import f1_score, make_scorer
scorer = make_scorer(f1_score, labels=[-1, 1], average='macro')
# use like:
cv = cross_val_score(model, X, Y, scoring=scorer)
@pmbaumgartner
pmbaumgartner / vncboot
Created June 4, 2016 13:17
start vnc server on boot
#! /bin/sh
# /etc/init.d/vncboot
### BEGIN INIT INFO
# Provides: vncboot
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start VNC Server at boot time
@pmbaumgartner
pmbaumgartner / vncsetup
Last active June 4, 2016 19:05
acquiring tightvnc server
sudo aptitude update
sudo aptitude upgrade
sudo apt-get install tightvncserver
sudo su
wget https://gist.githubusercontent.com/pmbaumgartner/b897116f50cc9f73430f636523021d48/raw/52113a87979e7b012c4d79e9e1afda068de455b5/vncboot -O /etc/init.d/vncboot
chmod 755 /etc/init.d/vncboot
@pmbaumgartner
pmbaumgartner / opencv
Last active June 4, 2016 15:16
opencv setup
JOBS=`lscpu | awk ' /CPU\(s\):/ {print $2}' | head -n1` # Sets the amount of jobs when compiling to the detected amount of cores
echo "Now downloading OpenCV from github..."
git clone https://github.com/Itseez/opencv.git
git clone https://github.com/Itseez/opencv_contrib.git
cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_TBB=ON -D BUILD_TBB=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..