対応のあるt検定
10点テスト学習した結果、 サンプル数が一緒。対応があるt検定を行う
import scipy as sp b= [9,8,10,7,5,9,10,10,8,10,10,6,8,9,10,9,10,9] a =[9,9,10,7,6,10,10,9,8,10,7,8,10,10,10,10,10,10] print(len(a),len(b)) print(sp.stats.ttest_rel( b,a))
Ttest_relResult(statistic=-1.243163121016122, pvalue=0.23068052813068232)
差がないという事象が23%の確率で起こる。5%の有意水準では棄却できず。
差がないが採択される。
学習しても差(効果)がないかなしい。
対応の無いt検定
対応の無いt検定
import scipy as sp b = [7,8,10,5,8,7,9,5,6,9,10,6,7,8,7,9,10,10] a = [9,9,6,10,9,8,10,7,9,10,6,8,9,9,10,7,8,8,10,9] t_value = (sp.mean(a)-sp.mean(b))/sp.sqrt((sp.var(b,ddof=1)/len(b) + sp.var(a,ddof=1)/len(a))) t_value
1.463060101595841
一行で書くなら
t_value,p_value =sp.stats.ttest_ind(a,b,equal_var=False)
t_value
1.463060101595841
sp.stats.ttest_ind(a,b,equal_var=False)
だとp値も表示してくれる。
Ttest_indResult(statistic=1.463060101595841, pvalue=0.15335375977552246)
対応の無いt検定は、サンプル数が異なっても大丈夫
json.dump()
import json from io import StringIO io = StringIO() json.dump(['streaming API'], io)#dump()は書き出す io.getvalue()
'["streaming API"]'
rjust(),ljust(),zfill()たち
In [49]: s = 'Hello, world' ...: print (str(s)) ...: print (repr(s))#インタープリタが読めるよう表現を生成する。 ...: print(s.rjust(30))#30文字の中で右寄せる。 ...: print(s.ljust(30))#30文字の中で左寄せる。 ...: print(s.zfill(30))#30文字の中で0でパディング。 ...: ...: Hello, world 'Hello, world' Hello, world Hello, world 000000000000000000Hello, world
np.whereって
import numpy as np i = np.min(np.where(y > 0.5))
とはどういう意味か。 whereって
In [1]: import numpy as np In [2]: a = np.arange(8).reshape((2, 4)) In [3]: np.where(a > 2) Out[3]: (array([0, 1, 1, 1, 1], dtype=int64), array([3, 0, 1, 2, 3], dtype=int64))
最初意味がわからなかったけどこれ、indexを表示している。 2つのarray[0]の組み合わせ、(0,3)(1,0)という感じ
In [5]: a >2 Out[5]: array([[False, False, False, True], [ True, True, True, True]])
2より大きいものは、5個あって、(0,3)と(1,0),(1,1),(1,2),(1,3)が該当する。