Training (multiclass classification)

create table model_scw1 as
select 
 label, 
 feature,
 argmin_kld(weight, covar) as weight
from 
 (select 
     train_multiclass_scw(features, label) as (label, feature, weight, covar)
  from 
     training_x10
 ) t 
group by label, feature;

Predict

create or replace view predict_scw1
as
select 
  rowid, 
  m.col0 as score, 
  m.col1 as label
from (
select
   rowid, 
   maxrow(score, label) as m
from (
  select
    t.rowid,
    m.label,
    sum(m.weight * t.value) as score
  from 
    test20p_exploded t LEFT OUTER JOIN
    model_scw1 m ON (t.feature = m.feature)
  group by
    t.rowid, m.label
) t1
group by rowid
) t2;

Evaluation

create or replace view eval_scw1 as
select 
  t.label as actual, 
  p.label as predicted
from 
  test20p t JOIN predict_scw1 p 
    on (t.rowid = p.rowid);

select count(1)/30 from eval_scw1 
where actual = predicted;

0.9666666666666667

results matching ""

    No results matching ""