Skip to content

Instantly share code, notes, and snippets.

@standarderror
standarderror / smear.sql
Created August 29, 2017 23:55
Smearing start-end date data
Imagine you have some start-end data:
create table PRD_CAA_CRE_DDWSP_PI6_DPOL.TBL_DATA_1 as (
select ACCT_ID
, START_DATE
, END_DATE
, CURR_CRDT_LIM_AMT
from PRD_ADS_IL_VR.VR_S_ACCT_CRDT_CRD_RAW
sample 1000)
with data;
@standarderror
standarderror / SQL to R.txt
Created April 8, 2017 10:26
SQL equivalents in R
SELECT ... FROM a JOIN b WHERE ... GROUP BY ... HAVING ... ORDER BY ...
is equivalent to a chain of R commands involving
a %>%
select(...) %>%
filter(...) %>%
inner_join(b, ...) %>%
group_by(...) %>%
summarise(...) %>%
@standarderror
standarderror / 20161112_Neural_Style_TensorFlow.py
Created November 12, 2016 04:26
20161112_Neural_Style_TensorFlow
import os
import numpy as np
import scipy.misc
import scipy.io
import math
import tensorflow as tf
from sys import stderr
from functools import reduce
import time
"""
Based on the tflearn CIFAR-10 example at:
https://github.com/tflearn/tflearn/blob/master/examples/images/convnet_cifar10.py
"""
from __future__ import division, print_function, absolute_import
from skimage import color, io
from scipy.misc import imresize
import numpy as np
# choose images & plot the first one
im = allX[102:103]
plt.axis('off')
plt.imshow(im[0].astype('uint8'))
plt.gcf().set_size_inches(2, 2)
# run images through 1st conv layer
m2 = tflearn.DNN(conv_1, session=model.session)
yhat = m2.predict(im)
@standarderror
standarderror / 20160215_Decision_boundaries.py
Last active February 16, 2016 01:12
20160215 Decision Boundaries
### Prepeare python
%pylab inline
import numpy as np
import pandas as pd
import statsmodels.api as sm
import scipy.stats as stats
import neurolab as nl
from sklearn.datasets import make_classification
from sklearn import neighbors, tree, svm
@standarderror
standarderror / Autoencoder.py
Last active September 26, 2016 03:36
20150715 Autoencoder
### Autoencoder
###################################
## [1] Parameters & hyperparameters
###################################
# shape of data
N = shape(X)[1] # num observation
D = shape(X)[0] # num features (dimensionality)
@standarderror
standarderror / index.html
Created January 12, 2015 03:41
20150115 Regression Animation in Viewbox
<!DOCTYPE html>
<meta charset="utf-8">
<style>
#chart {
/* margin-left:50%; */
}
.circle {
stroke: '#fff';
@standarderror
standarderror / index.html
Last active February 17, 2016 10:04
20150111 Regression Scatterplot Animation
<!DOCTYPE html>
<meta charset="utf-8">
<style>
#chart {
}
.circle {
stroke: '#fff';
@standarderror
standarderror / d3.min.js
Last active August 29, 2015 14:12
20150107 Movies by genre history
!function(){function n(n,t){return t>n?-1:n>t?1:n>=t?0:0/0}function t(n){return null===n?0/0:+n}function e(n){return!isNaN(n)}function r(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)<0?r=i+1:u=i}return r},right:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)>0?u=i:r=i+1}return r}}}function u(n){return n.length}function i(n){for(var t=1;n*t%1;)t*=10;return t}function o(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function a(){this._=Object.create(null)}function c(n){return(n+="")===da||n[0]===ma?ma+n:n}function l(n){return(n+="")[0]===ma?n.slice(1):n}function s(n){return c(n)in this._}function f(n){return(n=c(n))in this._&&delete this._[n]}function h(){var n=[];for(var t in this._)n.push(l(t));return n}function g(){var n=0;for(var t in this._)++n;return n}function p(){for(var n in this._)return!1;return!0}function v(){this._=Object