Skip to content

Instantly share code, notes, and snippets.

View alfredplpl's full-sized avatar

Alfred Increment alfredplpl

View GitHub Profile
#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)
>>> 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}
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
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
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
> #各選択肢の出現回数を求めます
> choiceTable<-table(exam5)
> choiceTable
exam5
1 2 3 4 5
15 12 13 12 15
>
> #各選択肢に対して同じ回数出現しているかを統計的に調べます。
> #(カイ二乗検定による適合度検定)
> chisq.test(choiceTable)
#過去の解答を読み込む
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]
@alfredplpl
alfredplpl / resultOfHash.R
Created October 27, 2013 01:45
the result of hashLikeList.R
> 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
@alfredplpl
alfredplpl / hashLikeList.R
Created October 27, 2013 01:43
Its behavior is like hash (associative array).
#Its behavior is like hash (associative array).
hash.test=list("square"=function(x){x**2},
"pi"=3.1415926535)
hash.test[["square"]](2)
hash.test[["pi"]]
#probability that a random selected number is a prime number.
6/hash.test[["square"]](hash.test[["pi"]])
@alfredplpl
alfredplpl / resultBofTest.py
Created October 17, 2013 08:08
The result of bofTest.py
Ave. score(BagOfFeatures):70.492308[%]
Ave. score(BagOfFeaturesGMM):71.323077[%]