asdmay / leap_practice

0 stars 1 forks source link

距離を求めるアルゴリズムを別ファイル (./src/distance.js) に分離した #41

Closed otknoy closed 8 years ago

otknoy commented 8 years ago

別ファイルにすることで、実験がやりやすくなると思う。 条件変えるのが楽になるし。

一応、src/main.js の中身の処理と結果が同じになることを確認した。 念の為、自分でも確認して欲しい。

src/test/data.json のデータを用いて動作確認を行うスクリプト (./src/test_distance.js) を付けてある。

$ node src/test_distance.js

require することで、時間的類似度と空間的類似度を求める関数が使える。

var Distance = require('./distance.js');

// 時間的類似度
var tdist = Distance.temporalDistance(ts1, ts2);

// 空間的類似度
var sdist = Distance.spatialDistance(ts1, ts2);

console.log("temporal distance: " + tdist);
console.log("spatial distance: " + sdist.x * sdist.y);

詳しくは、src/test_distance.js を参照して下さい。

otknoy commented 8 years ago

src/main.js に組み込んで実際に動くか確かめよう。 余裕があれば、こっちでやってみる。

otknoy commented 8 years ago

修正後のコードによる結果

otknoy@debian:~/repos/leap_practice$ node src/test_distance.js                                                        
ts1_name,ts2_name,score,score_s,score_t
sin(slow),sin(slow),0,0,0
sin(slow),sin(normal),0.31258122521776394,0.10266379622000313,3.0447074502088234
sin(slow),sin(fast),1.7909762348779006,0.27701357657087267,6.46530129334541
sin(slow),sin(slow_fast),0.8597075329430575,0.04142093273117922,20.755388067249402
sin(slow),sin(fast_slow),1.1216776589187074,0.04511663600632399,24.86173079840177
sin(slow),sin(slow_fast_gradually),3.7312241674135103,0.29650627081065456,12.583963763101073
sin(slow),sin(fast_slow_gradually),11.199617546672524,0.41020905070825237,27.302219508164587
sin(slow),sin(slow_R),1.5729541337191772e-10,1210.4153183235485,1.2995160503237457e-13
sin(slow),sin(normal_R),3188.2389386997706,1047.1413069525315,3.044707450208817
sin(slow),sin(fast_R),6228.433355940993,963.363202013768,6.465301293345413
sin(slow),sin(fast_slow_R),21527.8689458634,937.552968071606,22.961762885933503
sin(slow),sin(slow_fast_R),28407.061633681966,1368.6596242691508,20.755388067249392
sin(slow),sin(slow_fast_gradually_R),12869.40471770568,1022.6829129500184,12.583963763101073
sin(slow),sin(fast_slow_gradually_R),27380.314440281014,1002.8603876726238,27.30221950816459
sin(slow),circle(fast),13458.267356019755,949.2440863133376,14.177878535213008
sin(slow),circle(normal),17856.217950844555,1117.738834101315,15.975304253610659
sin(slow),circle(slow),22267.18011623445,1067.4080270207246,20.8609824477197
sin(slow),circle(slow_fast),43845.91369691211,1121.0470811754622,39.11157205898787
sin(slow),circle(fast_slow),45658.48077448982,1063.1033498448369,42.94829922335755
sin(slow),circle(fast_slow_gradually),41583.890585119014,1090.7605416508136,38.123757687625734
sin(slow),circle(slow_fast_gradually),28657.28287364407,1093.9146798455702,26.19700000523777
sin(slow),circle(slow_R),19233.600713103704,931.9305397312783,20.638448782513024
sin(slow),circle(normal_R),15577.328649916313,975.2425873219504,15.972773187327876
sin(slow),circle(fast_R),17231.978489311263,1108.6391749042796,15.543360616675917
sin(slow),circle(slow_fast_R),38213.481177942944,977.0377196884235,39.111572058987846
sin(slow),circle(fast_slow_R),40009.25199743667,931.5677854753691,42.948299223357516
sin(slow),circle(slow_fast_gradually_R),25058.48607819607,956.5402936666763,26.19700000523778
sin(slow),circle(fast_slow_gradually_R),34452.094086204255,903.6909312165409,38.123757687625734
sin(slow),h_line(slow),1711.8386511626293,58.90357682818726,29.061709718508286
sin(slow),h_line(normal),1468.8866200996592,50.54370972414544,29.061709718508286
sin(slow),h_line(fast),1244.921404339886,42.83717015957404,29.061709718508286
sin(slow),h_line(fast_slow),2493.7717734084927,58.0645058943851,42.94829922335812
sin(slow),h_line(slow_fast),1974.9131834603472,50.4943442437385,39.11157205898845
sin(slow),h_line(fast_slow_gradually),2371.7524510256476,62.20736271605747,38.12655524156197
sin(slow),h_line(slow_fast_gradually),1399.1974513858072,53.41329984234195,26.19567515049185
sin(slow),h_line(slow_R),48833.65524279325,1680.3435075154223,29.061709718508286
sin(slow),h_line(normal_R),48525.62854592952,1669.7444512366528,29.061709718508286
sin(slow),h_line(fast_R),51430.215929887454,1769.6899607091432,29.061709718508286
sin(slow),h_line(slow_fast_R),65151.88129529764,1665.7955143565935,39.11157205898845
sin(slow),h_line(fast_slow_R),72356.57589534656,1684.7366997944887,42.94829922335812
sin(slow),h_line(slow_fast_gradually_R),43613.18211910572,1664.9000977662083,26.19567515049185
sin(slow),h_line(fast_slow_gradually_R),64225.830131655806,1684.5432199351405,38.12655524156197
sin(slow),v_line(slow),116170.9892839083,3997.3900506591135,29.061709718508286
sin(slow),v_line(normal),115732.57714173105,3982.304491467183,29.061709718508286
sin(slow),v_line(fast),122571.03739562494,4217.612748281088,29.061709718508286
sin(slow),v_line(slow_fast),155514.97885690504,3976.188393101557,39.11157205898845
sin(slow),v_line(fast_slow),172200.61880860655,4009.4863340933534,42.94829922335812
sin(slow),v_line(slow_fast_gradually),104034.25199523248,3971.4285429776037,26.19567515049185
sin(slow),v_line(fast_slow_gradually),152093.8612168734,3989.1844477749996,38.12655524156197
sin(slow),v_line(slow_R),98611.72621852049,3393.18392392167,29.061709718508286
sin(slow),v_line(normal_R),96132.37950023352,3307.8707492219737,29.061709718508286
sin(slow),v_line(fast_R),96762.05860411897,3329.5377161686715,29.061709718508286
sin(slow),v_line(slow_fast_R),129360.59343839166,3307.476192552137,39.11157205898845
sin(slow),v_line(fast_slow_R),145481.6542305989,3387.3670636875045,42.94829922335812
sin(slow),v_line(slow_fast_gradually_R),87802.54496412238,3351.7954570632164,26.19567515049185
sin(slow),v_line(fast_slow_gradually_R),130395.80115652503,3420.0782192454635,38.12655524156197
otknoy commented 8 years ago

https://github.com/otknoy/leap_practice/pull/1#issuecomment-180718535

修正前と修正後の計算結果が一致したため問題なし。

otknoy commented 8 years ago

@asdmay @ShunNaito 念の為、確認お願いします。

確認後、main.js に組み込んでしまいます。

asdmay commented 8 years ago

確認しました

otknoy commented 8 years ago

@asdmay main.js に組み込んだ。

master ブランチと feature/distance ブランチの結果が同じであれば問題ないので、確認してマージしてくださいー

asdmay commented 8 years ago

かくにんできました