Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
# http://docs.python.jp/2/library/unittest.html
# https://pypi.python.org/pypi/pyrg
import random
import unittest
class TestSequenceFunctions(unittest.TestCase):
@yuu-ito
yuu-ito / ラベルの回転など.R
Last active August 29, 2015 14:07
R/ggplot2/theme/element_text/angle
# http://docs.ggplot2.org/current/theme.html
# http://docs.ggplot2.org/current/scale_date.html
a <- AirPassengers
ap.df <- data.frame(
year=seq(from=as.Date("1949-01-01"),to=as.Date("1960-12-01"),by="1 month"),
passengers=as.numeric(a)
)
p <- qplot(data=ap.df,x=year,y=passengers)+geom_line()+scale_x_date(labels = date_format("%Y/%m/%d"))
print(p)
mysql -uroot -e 'select now(),date(now())' | cat > /tmp/out.txt
more /tmp/out.txt
  • 結果
now()   date(now())
2014-10-06 19:13:44     2014-10-06

PureDataに投げるSQLを書く上で気にしていること #vgadvent2014

※これはVOYAGE GROUP エンジニアブログ:Advent Calendar 2014の3日目の記事です。

もうこんな季節なんですね。 去年のエントリから1年経ってると思うとホントにあっという間にでした!

弊社では、運用しているメディアサービスのデータ解析環境としてDWH(データウェアハウス)製品のひとつであるPureData(IBM PureData for Analytics)を使っていたりします。 Amazon RedshiftGoogle BigQuery などのクラウドサービスもあったりするので高性能なシステムでの分析ができる機会は増えてくるのかなと思います。

@yuu-ito
yuu-ito / midori_study_6.4_p120.R
Created March 24, 2015 03:03
久保みどり本 p.120 ~ 121 図6.4 ロジスティック関数のパラメタを変化させたときの曲線の動き
# p.120
logistic <- function(z){
1 / (1+exp(-z))
}
# z <- seq(-6,6,0.1)
# plot(z,logistic(z),type="l")
x <- seq(-3,3,0.1)
z <- function(x,b_1,b_2){
# z = b_1 + b_2*x
@yuu-ito
yuu-ito / midori_study_7.r
Last active August 29, 2015 14:18
久保みどり本 7章 途中まで。
library("magrittr")
library("dplyr")
library("ggplot2")
# midori_study 7
# http://hosho.ees.hokudai.ac.jp/~kubo/ce/IwanamiBook.html
rsc.dir <- "~/workspace/kubo_midori_7/"
d <- paste0(rsc.dir,"data.csv") %>% read.csv
head(d)
@yuu-ito
yuu-ito / midori_study_8.r
Last active August 29, 2015 14:19
久保みどり本 8章 今回は手を動かすというよりも読み物メイン。
library("ggplot2")
library("magrittr")
library("dplyr")
# midori 8
# http://hosho.ees.hokudai.ac.jp/~kubo/ce/IwanamiBook.html
data <- c(4,3,4,5,5,2,3,1,4,0,1,5,5,6,5,4,4,5,3,4)
hist(data)
loglik <- function(q){
# rcpp sandbox
gibbs_r <- function(n,thin){
# R実装のギブスサンプラー
mat <- matrix(0,nrow=n,ncol=2)
x <- 0
y <- 0
for(i in 1:n){
for(j in 1:thin){
x <- rgamma(1, 3, 1/(y*y+4) )
@yuu-ito
yuu-ito / titanicデータでの条件付き確率と事前確率の算出.R
Created June 10, 2015 01:41
ベイズ分類のための変量の特徴を見る。
library("magrittr")
library("dplyr")
data(Titanic)
t <- Titanic %>% as.data.frame %>% arrange(Survived,Class,Sex,Age)
t %>%
group_by(Survived) %>%
summarize(ClassCount=sum(Freq)) %>%
group_by %>%