Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vega-regression

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-regression - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

7

build/vega-regression.js

@@ -106,2 +106,3 @@ (function (global, factory) {

const Methods = {
constant: vegaStatistics.regressionConstant,
linear: vegaStatistics.regressionLinear,

@@ -179,3 +180,3 @@ log: vegaStatistics.regressionLog,

method = _.method || 'linear',
order = _.order || 3,
order = _.order == null ? 3 : _.order,
dof = degreesOfFreedom(method, order),

@@ -221,4 +222,4 @@ as = _.as || [vegaUtil.accessorName(_.x), vegaUtil.accessorName(_.y)],

};
if (method === 'linear') {
// for linear regression we only need the end points
if (method === 'linear' || method === 'constant') {
// for linear or constant regression we only need the end points
dom.forEach(x => add([x, model.predict(x)]));

@@ -225,0 +226,0 @@ } else {

@@ -1,2 +0,2 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("vega-statistics"),require("vega-dataflow"),require("vega-util")):"function"==typeof define&&define.amd?define(["exports","vega-statistics","vega-dataflow","vega-util"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).vega={},e.vega,e.vega,e.vega)}(this,(function(e,r,a,t){"use strict";function s(e,r){var a,t,s,n,i,o,l=[],u=function(e){return e(n)};if(null==r)l.push(e);else for(a={},t=0,s=e.length;t<s;++t)n=e[t],(o=a[i=r.map(u)])||(a[i]=o=[],o.dims=i,l.push(o)),o.push(n);return l}function n(e){a.Transform.call(this,null,e)}n.Definition={type:"Loess",metadata:{generates:!0},params:[{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"bandwidth",type:"number",default:.3},{name:"as",type:"string",array:!0}]},t.inherits(n,a.Transform,{transform(e,n){const i=n.fork(n.NO_SOURCE|n.NO_FIELDS);if(!this.value||n.changed()||e.modified()){const o=s(n.materialize(n.SOURCE).source,e.groupby),l=(e.groupby||[]).map(t.accessorName),u=l.length,d=e.as||[t.accessorName(e.x),t.accessorName(e.y)],f=[];o.forEach((t=>{r.regressionLoess(t,e.x,e.y,e.bandwidth||.3).forEach((e=>{const r={};for(let e=0;e<u;++e)r[l[e]]=t.dims[e];r[d[0]]=e[0],r[d[1]]=e[1],f.push(a.ingest(r))}))})),this.value&&(i.rem=this.value),this.value=i.add=i.source=f}return i}});const i={linear:r.regressionLinear,log:r.regressionLog,exp:r.regressionExp,pow:r.regressionPow,quad:r.regressionQuad,poly:r.regressionPoly};function o(e){a.Transform.call(this,null,e)}o.Definition={type:"Regression",metadata:{generates:!0},params:[{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"string",default:"linear",values:Object.keys(i)},{name:"order",type:"number",default:3},{name:"extent",type:"number",array:!0,length:2},{name:"params",type:"boolean",default:!1},{name:"as",type:"string",array:!0}]},t.inherits(o,a.Transform,{transform(e,n){const o=n.fork(n.NO_SOURCE|n.NO_FIELDS);if(!this.value||n.changed()||e.modified()){const l=s(n.materialize(n.SOURCE).source,e.groupby),u=(e.groupby||[]).map(t.accessorName),d=e.method||"linear",f=e.order||3,m=((e,r)=>"poly"===e?r:"quad"===e?2:1)(d,f),p=e.as||[t.accessorName(e.x),t.accessorName(e.y)],g=i[d],c=[];let h=e.extent;t.hasOwnProperty(i,d)||t.error("Invalid regression method: "+d),null!=h&&"log"===d&&h[0]<=0&&(n.dataflow.warn("Ignoring extent with values <= 0 for log regression."),h=null),l.forEach((s=>{if(s.length<=m)return void n.dataflow.warn("Skipping regression with more parameters than data points.");const i=g(s,e.x,e.y,f);if(e.params)return void c.push(a.ingest({keys:s.dims,coef:i.coef,rSquared:i.rSquared}));const o=h||t.extent(s,e.x),l=e=>{const r={};for(let e=0;e<u.length;++e)r[u[e]]=s.dims[e];r[p[0]]=e[0],r[p[1]]=e[1],c.push(a.ingest(r))};"linear"===d?o.forEach((e=>l([e,i.predict(e)]))):r.sampleCurve(i.predict,o,25,200).forEach(l)})),this.value&&(o.rem=this.value),this.value=o.add=o.source=c}return o}}),e.loess=n,e.regression=o}));
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("vega-statistics"),require("vega-dataflow"),require("vega-util")):"function"==typeof define&&define.amd?define(["exports","vega-statistics","vega-dataflow","vega-util"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).vega={},e.vega,e.vega,e.vega)}(this,(function(e,r,a,t){"use strict";function s(e,r){var a,t,s,n,o,i,l=[],u=function(e){return e(n)};if(null==r)l.push(e);else for(a={},t=0,s=e.length;t<s;++t)n=e[t],(i=a[o=r.map(u)])||(a[o]=i=[],i.dims=o,l.push(i)),i.push(n);return l}function n(e){a.Transform.call(this,null,e)}n.Definition={type:"Loess",metadata:{generates:!0},params:[{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"bandwidth",type:"number",default:.3},{name:"as",type:"string",array:!0}]},t.inherits(n,a.Transform,{transform(e,n){const o=n.fork(n.NO_SOURCE|n.NO_FIELDS);if(!this.value||n.changed()||e.modified()){const i=s(n.materialize(n.SOURCE).source,e.groupby),l=(e.groupby||[]).map(t.accessorName),u=l.length,d=e.as||[t.accessorName(e.x),t.accessorName(e.y)],f=[];i.forEach((t=>{r.regressionLoess(t,e.x,e.y,e.bandwidth||.3).forEach((e=>{const r={};for(let e=0;e<u;++e)r[l[e]]=t.dims[e];r[d[0]]=e[0],r[d[1]]=e[1],f.push(a.ingest(r))}))})),this.value&&(o.rem=this.value),this.value=o.add=o.source=f}return o}});const o={constant:r.regressionConstant,linear:r.regressionLinear,log:r.regressionLog,exp:r.regressionExp,pow:r.regressionPow,quad:r.regressionQuad,poly:r.regressionPoly};function i(e){a.Transform.call(this,null,e)}i.Definition={type:"Regression",metadata:{generates:!0},params:[{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"string",default:"linear",values:Object.keys(o)},{name:"order",type:"number",default:3},{name:"extent",type:"number",array:!0,length:2},{name:"params",type:"boolean",default:!1},{name:"as",type:"string",array:!0}]},t.inherits(i,a.Transform,{transform(e,n){const i=n.fork(n.NO_SOURCE|n.NO_FIELDS);if(!this.value||n.changed()||e.modified()){const l=s(n.materialize(n.SOURCE).source,e.groupby),u=(e.groupby||[]).map(t.accessorName),d=e.method||"linear",f=null==e.order?3:e.order,m=((e,r)=>"poly"===e?r:"quad"===e?2:1)(d,f),p=e.as||[t.accessorName(e.x),t.accessorName(e.y)],g=o[d],c=[];let h=e.extent;t.hasOwnProperty(o,d)||t.error("Invalid regression method: "+d),null!=h&&"log"===d&&h[0]<=0&&(n.dataflow.warn("Ignoring extent with values <= 0 for log regression."),h=null),l.forEach((s=>{if(s.length<=m)return void n.dataflow.warn("Skipping regression with more parameters than data points.");const o=g(s,e.x,e.y,f);if(e.params)return void c.push(a.ingest({keys:s.dims,coef:o.coef,rSquared:o.rSquared}));const i=h||t.extent(s,e.x),l=e=>{const r={};for(let e=0;e<u.length;++e)r[u[e]]=s.dims[e];r[p[0]]=e[0],r[p[1]]=e[1],c.push(a.ingest(r))};"linear"===d||"constant"===d?i.forEach((e=>l([e,o.predict(e)]))):r.sampleCurve(o.predict,i,25,200).forEach(l)})),this.value&&(i.rem=this.value),this.value=i.add=i.source=c}return i}}),e.loess=n,e.regression=i}));
//# sourceMappingURL=vega-regression.min.js.map

@@ -1,2 +0,2 @@

import { regressionLoess, sampleCurve, regressionLinear, regressionLog, regressionExp, regressionPow, regressionQuad, regressionPoly } from 'vega-statistics';
import { regressionLoess, sampleCurve, regressionConstant, regressionLinear, regressionLog, regressionExp, regressionPow, regressionQuad, regressionPoly } from 'vega-statistics';
import { Transform, ingest } from 'vega-dataflow';

@@ -104,2 +104,3 @@ import { inherits, accessorName, hasOwnProperty, error, extent } from 'vega-util';

const Methods = {
constant: regressionConstant,
linear: regressionLinear,

@@ -177,3 +178,3 @@ log: regressionLog,

method = _.method || 'linear',
order = _.order || 3,
order = _.order == null ? 3 : _.order,
dof = degreesOfFreedom(method, order),

@@ -219,4 +220,4 @@ as = _.as || [accessorName(_.x), accessorName(_.y)],

};
if (method === 'linear') {
// for linear regression we only need the end points
if (method === 'linear' || method === 'constant') {
// for linear or constant regression we only need the end points
dom.forEach(x => add([x, model.predict(x)]));

@@ -223,0 +224,0 @@ } else {

{
"name": "vega-regression",
"version": "1.1.1",
"version": "1.2.0",
"description": "Regression transform for Vega dataflows.",

@@ -26,3 +26,3 @@ "keywords": [

"vega-dataflow": "^5.7.3",
"vega-statistics": "^1.7.9",
"vega-statistics": "^1.9.0",
"vega-util": "^1.15.2"

@@ -33,3 +33,3 @@ },

},
"gitHead": "fb1092f6b931d450f9c210b67ae4752bd3dd461b"
"gitHead": "a7a312ebe9db675ae03bd354f193ed34a976d21f"
}
import partition from './partition';
import {Transform, ingest} from 'vega-dataflow';
import {
regressionExp, regressionLinear, regressionLog,
regressionConstant, regressionExp, regressionLinear, regressionLog,
regressionPoly, regressionPow, regressionQuad, sampleCurve

@@ -10,8 +10,9 @@ } from 'vega-statistics';

const Methods = {
linear: regressionLinear,
log: regressionLog,
exp: regressionExp,
pow: regressionPow,
quad: regressionQuad,
poly: regressionPoly
constant: regressionConstant,
linear: regressionLinear,
log: regressionLog,
exp: regressionExp,
pow: regressionPow,
quad: regressionQuad,
poly: regressionPoly
};

@@ -61,3 +62,3 @@

method = _.method || 'linear',
order = _.order || 3,
order = _.order == null ? 3 : _.order,
dof = degreesOfFreedom(method, order),

@@ -111,4 +112,4 @@ as = _.as || [accessorName(_.x), accessorName(_.y)],

if (method === 'linear') {
// for linear regression we only need the end points
if (method === 'linear' || method === 'constant') {
// for linear or constant regression we only need the end points
dom.forEach(x => add([x, model.predict(x)]));

@@ -115,0 +116,0 @@ } else {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc