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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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(nnet) | |
even.n = 2*(1:75) | |
iris.train = iris[even.n,] | |
iris.test = iris[-even.n,] | |
iris.nnet = nnet(Species~.,size=3, decay=0.1, data = iris.train) | |
iris.nnetp = predict(iris.nnet, iris.test[,-5], type="class") | |
table(iris.test[,5], iris.nnetp) |
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
# -*- coding: utf-8 -*- | |
def chap1_0(): | |
targ = "stressed" | |
print targ[::-1] | |
def chap1_1(): | |
targ = u"パタトクカシーー" | |
print targ[0::2] |
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
# coding:utf8 | |
import MeCab | |
mt = MeCab.Tagger("-Ochasen") | |
print mt.parse("隣の客はよく柿食う客だ") | |
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
# coding:utf-8 | |
import CaboCha | |
mt = CaboCha.Parser() | |
targ = "太郎はこの本を次郎を見た女性に渡した" | |
print mt.parseToString(targ) | |
tree = mt.parse(targ) |
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
import pulp as lp | |
from pulp import lpSum | |
from pulp import LpVariable | |
def mixture(): | |
prob = lp.LpProblem("example mixture", lp.LpMinimize) | |
# Parameters | |
elements = ["Lead", "Zinc", "Tin"] |
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(ggplot2) | |
g = ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, colour=Species)) | |
g + geom_point() + geom_smooth(method=glm) |
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(ggplot2) | |
library(reshape2) | |
airq.df = data.frame(airquality) | |
airq.df = cbind(1:nrow(airq.df), airq.df) | |
colnames(airq.df)[1] = "id" | |
airq.melt = melt(airq.df, id = "id", measure = c("Ozone", "Solar.R", "Wind", "Temp")) | |
airq_g = ggplot(airq.melt, aes(x=id, y=value, group=variable, colour=variable)) |
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(forecast) | |
# データ読み込み | |
d = read.csv("temp.csv") | |
# unixtimeをPOSIXctに変換 | |
tsPOSIX = as.POSIXct(d[,1], origin="1970-01-01") | |
d = cbind(tsPOSIX, d) | |
colnames(d)[1] = "ts" | |
head(d) |
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
"+" = function(e1, e2){ | |
if(is.character(c(e1, e2))){ | |
paste(e1, e2, sep="") | |
}else{ | |
base::"+"(e1, e2) | |
} | |
} |