Skip to content

Instantly share code, notes, and snippets.

@puyokw
Last active March 11, 2016 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save puyokw/43591caed3785c5b1549 to your computer and use it in GitHub Desktop.
Save puyokw/43591caed3785c5b1549 to your computer and use it in GitHub Desktop.
td_intern otto
-- トレーニング
INSERT OVERWRITE TABLE model_cv
SELECT train_randomforest_classifier(features, label, '-trees 500')
FROM train_cv;
-- 予測
INSERT OVERWRITE TABLE pred_cv
SELECT
t2.rowid as rowid,
t2.predicted.label as label,
t2.predicted.probability as probability,
t2.predicted.probabilities as probabilities
FROM(
SELECT
rowid as rowid,
rf_ensemble(predicted) as predicted
FROM (
SELECT
t.rowid as rowid, t.label as actual,
-- hivemall v0.4.1-alpha.2 and before
-- tree_predict(p.model, t.features, ${classification}) as predicted
-- hivemall v0.4.1 and later
tree_predict(p.model_id, p.model_type, p.pred_model, t.features, true) as predicted
FROM model p
LEFT OUTER JOIN test_cv t
) t1
group by
rowid
) t2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment