This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Material colors from https://material.io/design/color/ | |
(defconst levels | |
(list "L50" "L100" "L200" "L300" "L400" | |
"L500" "L600" "L700" "L800" "L900" | |
"A100" "A200" "A400" "A700")) | |
(defconst red | |
(list "#FFEBEE" "#FFCDD2" "#EF9A9A" "#E57373" "#EF5350" | |
"#F44336" "#E53935" "#D32F2F" "#C62828" "#B71C1C" | |
"#FF8A80" "#FF5252" "#FF1744" "#D50000")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
hash brew &> /dev/null | |
if [ $? -eq 1 ]; then | |
echo 'Installing Homebrew ...' | |
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" | |
fi | |
# Ensure Homebrew formulae are updated | |
brew update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(MASS) | |
library(lme4) | |
generate_data = function( | |
n # number of units | |
, k # number of trials within each condition within each unit | |
, noise # measurement noise variance | |
, I # population intercept | |
, vI # across-units variance of intercepts | |
, A # population A effect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(plyr) | |
library(MASS) | |
library(lme4a) | |
generate_data = function( | |
n # number of units | |
, k # number of trials within each condition within each unit | |
, noise # measurement noise variance | |
, I # population intercept | |
, vI # across-units variance of intercepts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; http://carlo-hamalainen.net/blog/2011/08/04/ggplot2-from-clojure | |
; To dump the plot to a file: | |
(use '(com.evocomputing rincanter)) ; https://github.com/jolby/rincanter | |
(r-eval "library(ggplot2)") | |
(r-eval-raw "qplot(rating, data=movies, geom=\"histogram\")") ; see http://had.co.nz/ggplot2/geom_histogram.html | |
(r-eval "ggsave('histogram-example.png')") | |
; To display on your screen (Unix example; see rincanter docs for alternatives to x11() call) | |
(use '(com.evocomputing rincanter)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How much text versus metadata is in a tweet? | |
Brendan O'Connor (brenocon.com), 2011-06-13 | |
http://twitter.com/brendan642/status/80473880111742976 | |
What's it mean to compare the amount of text versus metadata? | |
Let's start with raw size of the data that comes over the wire from Twitter. | |
## Get tweets out of a sample stream archive. | |
## (e.g. curl http://stream.twitter.com/1/statuses/sample.json) | |
% cat tweets.2011-05-19 | grep -P '"text":' | head -100000 > 100k_tweets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Demo of techniques to visualize the predictions made by a categorization model. | |
library(ROCR) | |
library(ggplot2) | |
load(url('http://dl.dropbox.com/u/7644953/classifier-visualization.Rdata')) | |
pred.df$actual.bin <- ifelse(pred.df$actual == 'yes', 1, 0) | |
pred.df <- pred.df[order(pred.df$predicted, decreasing=TRUE), ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define two useful helper functions | |
colMean = function(x){ | |
dimx = dim(x) | |
.Internal(colMeans(x,dimx[1],dimx[2],na.rm=TRUE)) | |
} | |
colVar = function(x){ | |
dimx = dim(x) | |
x.mean = .Internal(colMeans(x,dimx[1],dimx[2],na.rm=TRUE)) | |
err = t(t(x)-x.mean) | |
err.sq = err*err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(RCurl) | |
require(XML) | |
google.counts<-function(s){ | |
search.url<-paste("http://www.google.com/search?q=",gsub(" ","+",s),sep="") | |
search.html<-getURL(search.url) | |
parse.search<-htmlTreeParse(search.html,useInternalNodes = TRUE) | |
search.nodes<-getNodeSet(parse.search,"//div[@id='resultStats']") | |
search.value<-strsplit(xmlValue(search.nodes[[1]])," ",fixed=TRUE)[[1]][2] | |
return(as.numeric(gsub(",","",search.value,fixed=TRUE))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mathieu Blondel, October 2010 | |
# License: BSD 3 clause | |
import numpy as np | |
from numpy import linalg | |
def linear_kernel(x1, x2): | |
return np.dot(x1, x2) | |
def polynomial_kernel(x, y, p=3): |
NewerOlder