Skip to content

Instantly share code, notes, and snippets.

@standarderror
standarderror / smear.sql
Created Aug 29, 2017
Smearing start-end date data
View smear.sql
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 Apr 8, 2017
SQL equivalents in R
View SQL to R.txt
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(...) %>%
View 20161112_Neural_Style_TensorFlow.py
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
View CNN: train CNN for cat dog data.py
"""
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
View CNN: visualise conv layer outputs.py
# 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 Feb 16, 2016
20160215 Decision Boundaries
View 20160215_Decision_boundaries.py
### 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 Sep 26, 2016
20150715 Autoencoder
View Autoencoder.py
### 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 Jan 12, 2015
20150115 Regression Animation in Viewbox
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<style>
#chart {
/* margin-left:50%; */
}
.circle {
stroke: '#fff';
@standarderror
standarderror / index.html
Last active Feb 17, 2016
20150111 Regression Scatterplot Animation
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<style>
#chart {
}
.circle {
stroke: '#fff';
@standarderror
standarderror / d3.min.js
Last active Aug 29, 2015
20150107 Movies by genre history
View d3.min.js
!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
You can’t perform that action at this time.