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
> hash.test[["square"]](2) | |
[1] 4 | |
> hash.test[["pi"]] | |
[1] 3.141593 | |
> | |
> #probability that a random selected number is a prime number. | |
> 6/hash.test[["square"]](hash.test[["pi"]]) | |
[1] 0.6079271 |
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
#過去の解答を読み込む | |
examH25<-read.csv("C:/center_kokugo - H25.csv",header=T) | |
examH24<-read.csv("C:/center_kokugo - H24.csv",header=T) | |
#過去問をくっつけます | |
exam<-rbind(examH25,examH24) | |
#選択肢が5個のものだけの解答を抽出します | |
exam5<-exam$Correct[exam$Choices==5] |
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
> #各選択肢の出現回数を求めます | |
> choiceTable<-table(exam5) | |
> choiceTable | |
exam5 | |
1 2 3 4 5 | |
15 12 13 12 15 | |
> | |
> #各選択肢に対して同じ回数出現しているかを統計的に調べます。 | |
> #(カイ二乗検定による適合度検定) | |
> chisq.test(choiceTable) |
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
No | Part | Correct | Choices | |
---|---|---|---|---|
1 | 1 | 1 | 5 | |
1 | 2 | 3 | 5 | |
1 | 3 | 1 | 5 | |
1 | 4 | 1 | 5 | |
1 | 5 | 5 | 5 | |
2 | 6 | 1 | 5 | |
3 | 7 | 5 | 5 | |
4 | 8 | 2 | 5 | |
5 | 9 | 5 | 5 |
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
No | Part | Correct | Choices | |
---|---|---|---|---|
1 | 1 | 3 | 5 | |
1 | 2 | 2 | 5 | |
1 | 3 | 5 | 5 | |
1 | 4 | 3 | 5 | |
1 | 5 | 5 | 5 | |
2 | 6 | 4 | 5 | |
3 | 7 | 5 | 5 | |
4 | 8 | 1 | 5 | |
5 | 9 | 3 | 5 |
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 json | |
#make a test data. | |
testHash={"A":10,"B":20.0,"C":[30.0,40]} | |
#dump the variable as a file | |
with open("E:/test.json","w") as f: | |
json.dump(testHash,f) | |
#load from a json file |
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 json | |
>>> testHash={"A":10,"B":20,"C":30.0} | |
with open("E:/test.json","w") as f: | |
json.dump(testHash,f) | |
>>> testHash | |
{'A': 10, 'C': 30.0, 'B': 20} |
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
#delete the next # if rjson package is not installed in the system | |
#install.packages("rjson") | |
library("rjson") | |
#load from a json file | |
data=fromJSON(file="E:/test.json") | |
#check the data | |
print(data) |
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 -*- | |
# This code is distributed under the 3-Clause BSD license (New BSD license). | |
# 基本的に作者の名前を書いていただければ、商用利用も可能です。なお、保証はしません。 | |
# 参考URL: http://osdn.jp/projects/opensource/wiki/licenses%2Fnew_BSD_license | |
from sklearn import linear_model | |
import Image | |
import numpy as np | |
from sklearn.cross_validation import ShuffleSplit | |
class MinibatchSGDRegressor(linear_model.SGDRegressor): |
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 -*- | |
# This code is distributed under the 3-Clause BSD license (New BSD license). | |
# 基本的に作者の名前を書いていただければ、商用利用も可能です。なお、保証はしません。 | |
# 参考URL: http://osdn.jp/projects/opensource/wiki/licenses%2Fnew_BSD_license | |
from sklearn import linear_model | |
import Image | |
import numpy as np | |
from sklearn.cross_validation import ShuffleSplit | |
from sklearn.metrics import r2_score |