StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
15 KiB
1 lines
15 KiB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-dataflow"),require("vega-scenegraph"),require("vega-util")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-scenegraph","vega-util"],t):t(((e=e||self).vega=e.vega||{},e.vega.transforms={}),e.vega,e.vega,e.vega)}(this,(function(e,t,n,r){"use strict";const a="top",o="left",i="right",s="bottom",u="top-left",c="top-right",d="bottom-left",l="bottom-right",f="start",h="middle",m="end",y="x",b="y",x="group",g="axis",p="title",w="frame",v="scope",k="legend",M="row-header",E="row-footer",T="row-title",_="column-header",A="column-footer",z="column-title",B="padding",D="symbol",O="fit",j="fit-x",q="fit-y",S="pad",L="none",I="all",P="each",C="flush",F="column",G="row";function H(e){t.Transform.call(this,null,e)}function R(e,t,n){return t(e.bounds.clear(),e,n)}r.inherits(H,t.Transform).transform=function(e,t){var r,a=t.dataflow,o=e.mark,i=o.marktype,s=n.Marks[i],u=s.bound,c=o.bounds;if(s.nested)o.items.length&&a.dirty(o.items[0]),c=R(o,u),o.items.forEach((function(e){e.bounds.clear().union(c)}));else if(i===x||e.modified())switch(t.visit(t.MOD,(function(e){a.dirty(e)})),c.clear(),o.items.forEach((function(e){c.union(R(e,u))})),o.role){case g:case k:case p:t.reflow()}else r=t.changed(t.REM),t.visit(t.ADD,(function(e){c.union(R(e,u))})),t.visit(t.MOD,(function(e){r=r||c.alignsWith(e.bounds),a.dirty(e),c.union(R(e,u))})),r&&(c.clear(),o.items.forEach((function(e){c.union(e.bounds)})));return n.boundClip(o),t.modifies("bounds")};var U=":vega_identifier:";function V(e){t.Transform.call(this,0,e)}function W(e){t.Transform.call(this,null,e)}function J(e){t.Transform.call(this,null,e)}V.Definition={type:"Identifier",metadata:{modifies:!0},params:[{name:"as",type:"string",required:!0}]},r.inherits(V,t.Transform).transform=function(e,t){var n=function(e){var t=e._signals[U];t||(e._signals[U]=t=e.add(0));return t}(t.dataflow),r=n.value,a=e.as;return t.visit(t.ADD,(function(e){e[a]||(e[a]=++r)})),n.set(this.value=r),t},r.inherits(W,t.Transform).transform=function(e,t){var r=this.value;r||((r=t.dataflow.scenegraph().mark(e.markdef,function(e){var t=e.groups,n=e.parent;return t&&1===t.size?t.get(Object.keys(t.object)[0]):t&&n?t.lookup(n):null}(e),e.index)).group.context=e.context,e.context.group||(e.context.group=r.group),r.source=this.source,r.clip=e.clip,r.interactive=e.interactive,this.value=r);var a=r.marktype===x?n.GroupItem:n.Item;return t.visit(t.ADD,(function(e){a.call(e,r)})),(e.modified("clip")||e.modified("interactive"))&&(r.clip=e.clip,r.interactive=!!e.interactive,r.zdirty=!0,t.reflow()),r.items=t.source,t};var K=r.inherits(J,t.Transform),N={parity:function(e){return e.filter((e,t)=>t%2?e.opacity=0:1)},greedy:function(e,t){var n;return e.filter((e,r)=>r&&Q(n.bounds,e.bounds,t)?e.opacity=0:(n=e,1))}};function Q(e,t,n){return n>Math.max(t.x1-e.x2,e.x1-t.x2,t.y1-e.y2,e.y1-t.y2)}function X(e,t){for(var n,r=1,a=e.length,o=e[0].bounds;r<a;o=n,++r)if(Q(o,n=e[r].bounds,t))return!0}function Y(e){var t=e.bounds;return t.width()>1&&t.height()>1}function Z(e){return e.forEach(e=>e.opacity=1),e}function $(e,t){return e.reflow(t.modified()).modifies("opacity")}function ee(e){t.Transform.call(this,null,e)}K.transform=function(e,t){var o,i,u,c=N[e.method]||N.parity,d=t.materialize(t.SOURCE).source,l=e.separation||0;if(d&&d.length){if(!e.method)return e.modified("method")&&(Z(d),t=$(t,e)),t;if(e.sort&&(d=d.slice().sort(e.sort)),o=Z(d=d.filter(Y)),t=$(t,e),o.length>=3&&X(o,l)){do{o=c(o,l)}while(o.length>=3&&X(o,l));o.length<3&&!r.peek(d).opacity&&(o.length>1&&(r.peek(o).opacity=0),r.peek(d).opacity=1)}var f,h,m,y,b;return e.boundScale&&e.boundTolerance>=0&&(f=e.boundScale,h=e.boundOrient,m=+e.boundTolerance,y=f.range(),b=new n.Bounds,h===a||h===s?b.set(y[0],-1/0,y[1],1/0):b.set(-1/0,y[0],1/0,y[1]),b.expand(m||1),i=e=>b.encloses(e.bounds),d.forEach(e=>{i(e)||(e.opacity=0)})),u=o[0].mark.bounds.clear(),d.forEach(e=>{e.opacity&&u.union(e.bounds)}),t}},r.inherits(ee,t.Transform).transform=function(e,t){var n=t.dataflow;if(t.visit(t.ALL,(function(e){n.dirty(e)})),t.fields&&t.fields.zindex){var r=t.source&&t.source[0];r&&(r.mark.zdirty=!0)}};const te=new n.Bounds;function ne(e,t,n){return e[t]===n?0:(e[t]=n,1)}function re(e){var t=e.items[0].datum.orient;return t===o||t===i}function ae(e,t,r,u){var c,d,l=t.items[0],f=l.datum,h=f.orient,m=null!=f.translate?f.translate:.5,y=function(e){var t=+e.grid;return[e.ticks?t++:-1,e.labels?t++:-1,t+ +e.domain]}(f),b=l.range,x=l.offset,g=l.position,p=l.minExtent,w=l.maxExtent,v=f.title&&l.items[y[2]].items[0],k=l.titlePadding,M=l.bounds,E=v&&n.multiLineOffset(v),T=0,_=0;switch(te.clear().union(M),M.clear(),(c=y[0])>-1&&M.union(l.items[c].bounds),(c=y[1])>-1&&M.union(l.items[c].bounds),h){case a:T=g||0,_=-x,d=Math.max(p,Math.min(w,-M.y1)),v&&(d=oe(e,v,d,k,E,0,-1,M)),M.add(0,-d).add(b,0);break;case o:T=-x,_=g||0,d=Math.max(p,Math.min(w,-M.x1)),v&&(d=oe(e,v,d,k,E,1,-1,M)),M.add(-d,0).add(0,b);break;case i:T=r+x,_=g||0,d=Math.max(p,Math.min(w,M.x2)),v&&(d=oe(e,v,d,k,E,1,1,M)),M.add(0,0).add(d,b);break;case s:T=g||0,_=u+x,d=Math.max(p,Math.min(w,M.y2)),v&&(d=oe(e,v,d,k,0,0,1,M)),M.add(0,0).add(b,d);break;default:T=l.x,_=l.y}return n.boundStroke(M.translate(T,_),l),ne(l,"x",T+m)|ne(l,"y",_+m)&&(l.bounds=te,e.dirty(l),l.bounds=M,e.dirty(l)),l.mark.bounds.clear().union(M)}function oe(e,t,n,r,a,o,i,s){var u=t.bounds,c=0,d=0;return t.auto?(e.dirty(t),n+=r,o?c=(t.x||0)-(t.x=i*(n+a)):d=(t.y||0)-(t.y=i*(n+a)),t.mark.bounds.clear().union(u.translate(-c,-d)),e.dirty(t),o?(s.add(0,u.y1).add(0,u.y2),n+=u.width()):(s.add(u.x1,0).add(u.x2,0),n+=u.height())):s.union(u),n}function ie(e){return(new n.Bounds).set(0,0,e.width||0,e.height||0)}function se(e){var t=e.bounds.clone();return t.empty()?t.set(0,0,0,0):t.translate(-(e.x||0),-(e.y||0))}function ue(e,t,n){var a=r.isObject(e)?e[t]:e;return null!=a?a:void 0!==n?n:0}function ce(e){return e<0?Math.ceil(-e):0}function de(e,t,n){var r,a,o,i,s,u,c,d,l,f,x,g=!n.nodirty,p=n.bounds===C?ie:se,w=te.set(0,0,0,0),v=ue(n.align,F),k=ue(n.align,G),M=ue(n.padding,F),E=ue(n.padding,G),T=n.columns||t.length,_=T<0?1:Math.ceil(t.length/T),A=t.length,z=Array(A),B=Array(T),D=0,O=Array(A),j=Array(_),q=0,S=Array(A),L=Array(A),H=Array(A);for(a=0;a<T;++a)B[a]=0;for(a=0;a<_;++a)j[a]=0;for(a=0;a<A;++a)u=t[a],s=H[a]=p(u),u.x=u.x||0,S[a]=0,u.y=u.y||0,L[a]=0,o=a%T,i=~~(a/T),D=Math.max(D,c=Math.ceil(s.x2)),q=Math.max(q,d=Math.ceil(s.y2)),B[o]=Math.max(B[o],c),j[i]=Math.max(j[i],d),z[a]=M+ce(s.x1),O[a]=E+ce(s.y1),g&&e.dirty(t[a]);for(a=0;a<A;++a)a%T==0&&(z[a]=0),a<T&&(O[a]=0);if(v===P)for(o=1;o<T;++o){for(x=0,a=o;a<A;a+=T)x<z[a]&&(x=z[a]);for(a=o;a<A;a+=T)z[a]=x+B[o-1]}else if(v===I){for(x=0,a=0;a<A;++a)a%T&&x<z[a]&&(x=z[a]);for(a=0;a<A;++a)a%T&&(z[a]=x+D)}else for(v=!1,o=1;o<T;++o)for(a=o;a<A;a+=T)z[a]+=B[o-1];if(k===P)for(i=1;i<_;++i){for(x=0,r=(a=i*T)+T;a<r;++a)x<O[a]&&(x=O[a]);for(a=i*T;a<r;++a)O[a]=x+j[i-1]}else if(k===I){for(x=0,a=T;a<A;++a)x<O[a]&&(x=O[a]);for(a=T;a<A;++a)O[a]=x+q}else for(k=!1,i=1;i<_;++i)for(r=(a=i*T)+T;a<r;++a)O[a]+=j[i-1];for(l=0,a=0;a<A;++a)l=z[a]+(a%T?l:0),S[a]+=l-t[a].x;for(o=0;o<T;++o)for(f=0,a=o;a<A;a+=T)f+=O[a],L[a]+=f-t[a].y;if(v&&ue(n.center,F)&&_>1)for(a=0;a<A;++a)(l=(s=v===I?D:B[a%T])-H[a].x2-t[a].x-S[a])>0&&(S[a]+=l/2);if(k&&ue(n.center,G)&&1!==T)for(a=0;a<A;++a)(f=(s=k===I?q:j[~~(a/T)])-H[a].y2-t[a].y-L[a])>0&&(L[a]+=f/2);for(a=0;a<A;++a)w.union(H[a].translate(S[a],L[a]));switch(l=ue(n.anchor,y),f=ue(n.anchor,b),ue(n.anchor,F)){case m:l-=w.width();break;case h:l-=w.width()/2}switch(ue(n.anchor,G)){case m:f-=w.height();break;case h:f-=w.height()/2}for(l=Math.round(l),f=Math.round(f),w.clear(),a=0;a<A;++a)t[a].mark.bounds.clear();for(a=0;a<A;++a)(u=t[a]).x+=S[a]+=l,u.y+=L[a]+=f,w.union(u.mark.bounds.union(u.bounds.translate(S[a],L[a]))),g&&e.dirty(u);return w}function le(e,t,n){var r,a,o,i,s,u,c,d=function(e){for(var t,n,r=e.items,a=r.length,o=0,i={marks:[],rowheaders:[],rowfooters:[],colheaders:[],colfooters:[],rowtitle:null,coltitle:null};o<a;++o)if(n=(t=r[o]).items,t.marktype===x)switch(t.role){case g:case k:case p:break;case M:i.rowheaders.push(...n);break;case E:i.rowfooters.push(...n);break;case _:i.colheaders.push(...n);break;case A:i.colfooters.push(...n);break;case T:i.rowtitle=n[0];break;case z:i.coltitle=n[0];break;default:i.marks.push(...n)}return i}(t),l=d.marks,f=n.bounds===C?fe:he,h=n.offset,y=n.columns||l.length,b=y<0?1:Math.ceil(l.length/y),w=b*y;const v=de(e,l,n);d.rowheaders&&(u=ue(n.headerBand,G,null),r=be(e,d.rowheaders,l,y,b,-ue(h,"rowHeader"),me,0,f,"x1",0,y,1,u)),d.colheaders&&(u=ue(n.headerBand,F,null),a=be(e,d.colheaders,l,y,y,-ue(h,"columnHeader"),me,1,f,"y1",0,1,y,u)),d.rowfooters&&(u=ue(n.footerBand,G,null),o=be(e,d.rowfooters,l,y,b,ue(h,"rowFooter"),ye,0,f,"x2",y-1,y,1,u)),d.colfooters&&(u=ue(n.footerBand,F,null),i=be(e,d.colfooters,l,y,y,ue(h,"columnFooter"),ye,1,f,"y2",w-y,1,y,u)),d.rowtitle&&(s=ue(n.titleAnchor,G),c=ue(h,"rowTitle"),c=s===m?o+c:r-c,u=ue(n.titleBand,G,.5),xe(e,d.rowtitle,c,0,v,u)),d.coltitle&&(s=ue(n.titleAnchor,F),c=ue(h,"columnTitle"),c=s===m?i+c:a-c,u=ue(n.titleBand,F,.5),xe(e,d.coltitle,c,1,v,u))}function fe(e,t){return"x1"===t?e.x||0:"y1"===t?e.y||0:"x2"===t?(e.x||0)+(e.width||0):"y2"===t?(e.y||0)+(e.height||0):void 0}function he(e,t){return e.bounds[t]}function me(e,t){return Math.floor(Math.min(e,t))}function ye(e,t){return Math.ceil(Math.max(e,t))}function be(e,t,n,r,a,o,i,s,u,c,d,l,f,h){var m,y,b,x,g,p,w,v,k,M=n.length,E=0,T=0;if(!M)return E;for(m=d;m<M;m+=l)n[m]&&(E=i(E,u(n[m],c)));if(!t.length)return E;for(t.length>a&&(e.warn("Grid headers exceed limit: "+a),t=t.slice(0,a)),E+=o,y=0,x=t.length;y<x;++y)e.dirty(t[y]),t[y].mark.bounds.clear();for(m=d,y=0,x=t.length;y<x;++y,m+=l){for(g=(p=t[y]).mark.bounds,b=m;b>=0&&null==(w=n[b]);b-=f);s?(v=null==h?w.x:Math.round(w.bounds.x1+h*w.bounds.width()),k=E):(v=E,k=null==h?w.y:Math.round(w.bounds.y1+h*w.bounds.height())),g.union(p.bounds.translate(v-(p.x||0),k-(p.y||0))),p.x=v,p.y=k,e.dirty(p),T=i(T,g[c])}return T}function xe(e,t,n,r,a,o){if(t){e.dirty(t);var i=n,s=n;r?i=Math.round(a.x1+o*a.width()):s=Math.round(a.y1+o*a.height()),t.bounds.translate(i-(t.x||0),s-(t.y||0)),t.mark.bounds.clear().union(t.bounds),t.x=i,t.y=s,e.dirty(t)}}function ge(e,t,n,r,y,b,x){const g=function(e,t){const n=e[t]||{};return(t,r)=>null!=n[t]?n[t]:null!=e[t]?e[t]:r}(n,t),p=function(e,t){var n=-1/0;return e.forEach(e=>{null!=e.offset&&(n=Math.max(n,e.offset))}),n>-1/0?n:t}(e,g("offset",0)),w=g("anchor",f),v=w===m?1:w===h?.5:0,k={align:P,bounds:g("bounds",C),columns:"vertical"===g("direction")?1:e.length,padding:g("margin",8),center:g("center"),nodirty:!0};switch(t){case o:k.anchor={x:Math.floor(r.x1)-p,column:m,y:v*(x||r.height()+2*r.y1),row:w};break;case i:k.anchor={x:Math.ceil(r.x2)+p,y:v*(x||r.height()+2*r.y1),row:w};break;case a:k.anchor={y:Math.floor(y.y1)-p,row:m,x:v*(b||y.width()+2*y.x1),column:w};break;case s:k.anchor={y:Math.ceil(y.y2)+p,x:v*(b||y.width()+2*y.x1),column:w};break;case u:k.anchor={x:p,y:p};break;case c:k.anchor={x:b-p,y:p,column:m};break;case d:k.anchor={x:p,y:x-p,row:m};break;case l:k.anchor={x:b-p,y:x-p,column:m,row:m}}return k}function pe(e,t){var r,a,u,c,d=t.items[0],l=d.datum,f=d.orient,h=d.bounds,y=d.x,b=d.y;return d._bounds?d._bounds.clear().union(h):d._bounds=h.clone(),h.clear(),function(e,t,n){var r=t.padding,a=r-n.x,u=r-n.y;if(t.datum.title){var c=t.items[1].items[0],d=c.anchor,l=t.titlePadding||0,f=r-c.x,h=r-c.y;switch(c.orient){case o:a+=Math.ceil(c.bounds.width())+l;break;case i:case s:break;default:u+=c.bounds.height()+l}switch((a||u)&&ve(e,n,a,u),c.orient){case o:h+=we(t,n,c,d,1,1);break;case i:f+=we(t,n,c,m,0,0)+l,h+=we(t,n,c,d,1,1);break;case s:f+=we(t,n,c,d,0,0),h+=we(t,n,c,m,-1,0,1)+l;break;default:f+=we(t,n,c,d,0,0)}(f||h)&&ve(e,c,f,h),(f=Math.round(c.bounds.x1-r))<0&&(ve(e,n,-f,0),ve(e,c,-f,0))}else(a||u)&&ve(e,n,a,u)}(e,d,d.items[0].items[0]),h=function(e,t){return e.items.forEach(e=>t.union(e.bounds)),t.x1=e.padding,t.y1=e.padding,t}(d,h),r=2*d.padding,a=2*d.padding,h.empty()||(r=Math.ceil(h.width()+r),a=Math.ceil(h.height()+a)),l.type===D&&(u=d.items[0].items[0].items[0].items,c=u.reduce((function(e,t){return e[t.column]=Math.max(t.bounds.x2-t.x,e[t.column]||0),e}),{}),u.forEach((function(e){e.width=c[e.column],e.height=e.bounds.y2-e.y}))),f!==L&&(d.x=y=0,d.y=b=0),d.width=r,d.height=a,n.boundStroke(h.set(y,b,y+r,b+a),d),d.mark.bounds.clear().union(h),d}function we(e,t,r,a,o,i,s){const u="symbol"!==e.datum.type,c=r.datum.vgrad,d=(!u||!i&&c||s?t:t.items[0]).bounds[o?"y2":"x2"]-e.padding,l=c&&i?d:0,h=c&&i?0:d,y=o<=0?0:n.multiLineOffset(r);return Math.round(a===f?l:a===m?h-y:.5*(d-y))}function ve(e,t,n,r){t.x+=n,t.y+=r,t.bounds.translate(n,r),t.mark.bounds.translate(n,r),e.dirty(t)}function ke(e){t.Transform.call(this,null,e)}r.inherits(ke,t.Transform).transform=function(e,t){var r=t.dataflow;return e.mark.items.forEach((function(t){e.layout&&le(r,t,e.layout),function(e,t,r){var u,c,d,l,h,y=t.items,b=Math.max(0,t.width||0),D=Math.max(0,t.height||0),I=(new n.Bounds).set(0,0,b,D),P=I.clone(),C=I.clone(),F=[];for(l=0,h=y.length;l<h;++l)switch((c=y[l]).role){case g:(re(c)?P:C).union(ae(e,c,b,D));break;case p:u=c;break;case k:F.push(pe(e,c));break;case w:case v:case M:case E:case T:case _:case A:case z:P.union(c.bounds),C.union(c.bounds);break;default:I.union(c.bounds)}if(F.length){const t={};F.forEach(e=>{(d=e.orient||i)!==L&&(t[d]||(t[d]=[])).push(e)});for(let n in t){const a=t[n];de(e,a,ge(a,n,r.legends,P,C,b,D))}F.forEach(t=>{const n=t.bounds;if(n.equals(t._bounds)||(t.bounds=t._bounds,e.dirty(t),t.bounds=n,e.dirty(t)),r.autosize&&r.autosize.type===O)switch(t.orient){case o:case i:I.add(n.x1,0).add(n.x2,0);break;case a:case s:I.add(0,n.y1).add(0,n.y2)}else I.union(n)})}I.union(P).union(C),u&&I.union(function(e,t,n,r,u){var c,d=t.items[0],l=d.frame,h=d.orient,y=d.anchor,b=d.offset,g=d.padding,p=d.items[0].items[0],w=d.items[1]&&d.items[1].items[0],v=h===o||h===i?r:n,k=0,M=0,E=0,T=0,_=0;if(l!==x?h===o?(k=u.y2,v=u.y1):h===i?(k=u.y1,v=u.y2):(k=u.x1,v=u.x2):h===o&&(k=r,v=0),c=y===f?k:y===m?v:(k+v)/2,w&&w.text){switch(h){case a:case s:_=p.bounds.height()+g;break;case o:T=p.bounds.width()+g;break;case i:T=-p.bounds.width()-g}te.clear().union(w.bounds),te.translate(T-(w.x||0),_-(w.y||0)),ne(w,"x",T)|ne(w,"y",_)&&(e.dirty(w),w.bounds.clear().union(te),w.mark.bounds.clear().union(te),e.dirty(w)),te.clear().union(w.bounds)}else te.clear();switch(te.union(p.bounds),h){case a:M=c,E=u.y1-te.height()-b;break;case o:M=u.x1-te.width()-b,E=c;break;case i:M=u.x2+te.width()+b,E=c;break;case s:M=c,E=u.y2+b;break;default:M=d.x,E=d.y}return ne(d,"x",M)|ne(d,"y",E)&&(te.translate(M,E),e.dirty(d),d.bounds.clear().union(te),t.bounds.clear().union(te),e.dirty(d)),d.bounds}(e,u,b,D,I));t.clip&&I.set(0,0,t.width||0,t.height||0);!function(e,t,n,r){var a=r.autosize||{},o=a.type,i=e._width,s=e._height,u=e.padding();if(e._autosize<1||!o)return;var c=Math.max(0,t.width||0),d=Math.max(0,Math.ceil(-n.x1)),l=Math.max(0,Math.ceil(n.x2-c)),f=Math.max(0,t.height||0),h=Math.max(0,Math.ceil(-n.y1)),m=Math.max(0,Math.ceil(n.y2-f));a.contains===B&&(i-=u.left+u.right,s-=u.top+u.bottom);o===L?(d=0,h=0,c=i,f=s):o===O?(c=Math.max(0,i-d-l),f=Math.max(0,s-h-m)):o===j?(c=Math.max(0,i-d-l),s=f+h+m):o===q?(i=c+d+l,f=Math.max(0,s-h-m)):o===S&&(i=c+d+l,s=f+h+m);e._resizeView(i,s,c,f,[d,h],a.resize)}(e,t,I,r)}(r,t,e)})),e.modified()&&t.reflow(),t},e.bound=H,e.identifier=V,e.mark=W,e.overlap=J,e.render=ee,e.viewlayout=ke,Object.defineProperty(e,"__esModule",{value:!0})})); |