More Related Content
Similar to ParamTuner 東京Node学園#8
Similar to ParamTuner 東京Node学園#8 (19)
ParamTuner 東京Node学園#8
- 7. Param Tuner bin
{
"params":
{
"alpha":
{
"range":
[0,
1]
}
},
"command":
"echo
$RANDOM",
"report":
{
"type":
"json",
"filename":
"./report.json"
}
}
plan.json
13年4月25日木曜日
- 9. Param Tuner
{
"time":
{
"begin":
"2013-‐04-‐24T19:15:58.559Z",
"end":
"2013-‐04-‐24T19:15:58.628Z"
},
"results":
{
"best":
{
"cost":
3164,
"params":
{
"alpha":
0.5529168925713748
}
},
"iteration":
[
{
"params":
{
"alpha":
0.20574524416588247
},
"cost":
19094
},
{
"params":
{
"alpha":
0.5529168925713748
report.json
13年4月25日木曜日
- 10. Param Tuner bin
{
"params":
{
"alpha":
{
"range":
[0,
1]
}
},
"command":
"echo
$RANDOM",
"report":
{
"type":
"json",
"filename":
"./report.json"
}
}
plan.json
パラメタ空間の定義
13年4月25日木曜日
- 11. Param Tuner bin
{
"params":
{
"alpha":
3.5,
//
const
"beta":
{
"range":
[0,
10]
//
range
[begin,
end]
},
"gamma":
{
"enum":
[1,
3,
6,
9]
//
enumerate
[items]
}
}
}
params
13年4月25日木曜日
- 12. Param Tuner bin
{
"params":
{
"alpha":
{
"range":
[0,
1]
}
},
"command":
"./command.js",
"report":
{
"type":
"json",
"filename":
"./report.json"
}
}
plan.json 外部jsを利用することもできます
通常のmoduleと同様 exports してください
13年4月25日木曜日
- 14. Param Tuner module
Tuner
=
require
'paramtuner'
tuner
=
new
Tuner
#
施行ごとに繰り返される処理を記述
command:
(env,
params,
next)-‐>
#
なんか処理してcostが求まる
costなので小さいほうが良い
next(null,
cost)
#
探索するパラメタ空間を定義
params:
alpha:
range:
[0,
10]
beta:
range:
[0,
10]
#
探索前に処理しておく内容を記述
command内のenv.$topicで取り出すことが可能
prepare:
(done)-‐>
done
null,
{data:
[0,
1,
2,
3,
4]}
#
実際にはdbから取得など
Usage
13年4月25日木曜日
- 15. Param Tuner module
Tuner
=
require
'paramtuner'
tuner
=
new
Tuner
#
~中略~
#
施行ごとに異なる環境を提供する場合
以下の場合、5000から1つずつ上げていく
#
envで返される関数が毎回実行される
commandの第1引数から取得可能
env:
()-‐>
port
=
5000
()-‐>
{
port:
port++
}
#
探索後の処理
例えば、最適なパラメタでWebサーバ起動など
done:
(err,
results,
time)-‐>
best
=
results.best
#
best.params
を使って処理
console.log
"best
cost
is
#{best.cost}"
tuner.start()
Usage
13年4月25日木曜日
- 16. Param Tuner module
✓Todo
✓ Strategyの追加
❖ 特に一般線形モデル作ったら気持ちよさそう
✓ grunt-contrib-tuning (現在はやっつけ)
❖ このmoduleを利用した形に変更する
❖ さっきやりました
13年4月25日木曜日
- 17. grunt-contrib-tuning
✓gruntで使えます!
✓multitask
tuning:
#
required:
tuning
case
name
test:
#
required:
tuning
parameter
list
params:
alpha:
range:
[0,
1]
beta:
range:
[5,
10]
gamma:
range:
[10,
100]
prepare:
(next)-‐>
next
null,
{hoge:
'fuga'}
#
optional:
if
define
this
method,
it
passed
to
`command`
env:
()-‐>
port
=
10000
13年4月25日木曜日
- 22. Series.js
Series
=
require
'series.js'
expect(Series.sum([0..10])).to.be.equal(55)
series
=
new
Series({bufsize:
10,
discount:
0.8}).x((d)-‐>
d.time).y((d)-‐>
d.val)
series.push({time:
new
Date(2013,0,1),
val:
1})
series.push({time:
new
Date(2013,0,2),
val:
2})
series.push({time:
new
Date(2013,0,3),
val:
3})
series.push({time:
new
Date(2013,0,4),
val:
4})
expect(series.mean()).to.be.equal(1.6384)
#
正確には
2.5
#
discountを変更することで、最新値と過去の重みを変更
13年4月25日木曜日