WITH train_input as (
select
array_concat(
array('bias'),
categorical_features(
'hour', 'week',
hour, week
)
) as features,
if(y_axis > 2500, 1.0 0.0) as label -- 0 or 1
from
data
)
INSERT OVERWRITE TABLE lr_model as
select
logress(features, label) as (feature, weight)
from (
select
amplify(5, features, label) as features, label -- 5x input
train_input
train_input
CLUSTER BY rand() -- random shuffle
) train_input_shuffled
Prestoでも動作するように修正
WITN test_exploded as (
select
rowid,
'bias', as bias
'hour#' || hour as hour,
'week#' || week as week
from
data
)
select
-- sigmoid(sum(m.weight)) as prob -- 0.0~1.0
1.0 / (1.0 + EXP(- sum(m.weight) ))
from
test_exploded t
LEFT OUTER JOIN lr_model m ON (t.feature = m.feature)
sigmoid(x) = 1.0 / (1.0 + EXP(-x)); http://hivemall.incubator.apache.org/userguide/tips/rt_prediction.html#onlinerealtime-prediction-on-mysql select