
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
The 'regression' npm package is a simple and efficient library for performing various types of regression analysis. It supports multiple regression models including linear, exponential, logarithmic, power, and polynomial regression. This package is useful for fitting data to a model and making predictions based on that model.
Linear Regression
Performs linear regression on a set of data points. The result includes the equation of the line, the slope, the intercept, and the R-squared value.
const regression = require('regression');
const data = [[0, 1], [32, 67], [12, 79]];
const result = regression.linear(data);
console.log(result);
Exponential Regression
Performs exponential regression on a set of data points. The result includes the equation of the curve and the R-squared value.
const regression = require('regression');
const data = [[0, 1], [32, 67], [12, 79]];
const result = regression.exponential(data);
console.log(result);
Logarithmic Regression
Performs logarithmic regression on a set of data points. The result includes the equation of the curve and the R-squared value.
const regression = require('regression');
const data = [[0, 1], [32, 67], [12, 79]];
const result = regression.logarithmic(data);
console.log(result);
Power Regression
Performs power regression on a set of data points. The result includes the equation of the curve and the R-squared value.
const regression = require('regression');
const data = [[0, 1], [32, 67], [12, 79]];
const result = regression.power(data);
console.log(result);
Polynomial Regression
Performs polynomial regression on a set of data points. The result includes the equation of the curve and the R-squared value. The order of the polynomial can be specified.
const regression = require('regression');
const data = [[0, 1], [32, 67], [12, 79]];
const result = regression.polynomial(data, { order: 2 });
console.log(result);
The 'simple-statistics' package provides a wide range of statistical tools, including various types of regression analysis. It is more comprehensive than 'regression' as it includes additional statistical functions such as mean, median, standard deviation, and more.
The 'ml-regression' package is part of the 'ml' suite of machine learning tools. It offers multiple regression models including linear, polynomial, and multivariate linear regression. It is designed to be used in conjunction with other machine learning tools in the 'ml' suite.
regression-js is a JavaScript module containing a collection of linear least-squares fitting methods for simple data analysis.
This module works on node and in the browser. It is available as the 'regression' package on npm. It is also available on a CDN.
npm install --save regression
import regression from 'regression';
const result = regression.linear([[0, 1], [32, 67], [12, 79]]);
const gradient = result.equation[0];
const yIntercept = result.equation[1];
Data is passed into the model as an array. A second parameter can be used to configure the model. The configuration parameter is optional. null
values are ignored. The precision option will set the number of significant figures the output is rounded to.
Below are the default values for the configuration parameter.
{
order: 2,
precision: 2,
}
equation
: an array containing the coefficients of the equationstring
: A string representation of the equationpoints
: an array containing the predicted data in the domain of the inputr2
: the coefficient of determination (R2)predict(x)
: This function will return the predicted valueregression.linear(data[, options])
Fits the input data to a straight line with the equation . It returns the coefficients in the form
[m, c]
.
regression.exponential(data[, options])
Fits the input data to a exponential curve with the equation . It returns the coefficients in the form
[a, b]
.
regression.logarithmic(data[, options])
Fits the input data to a logarithmic curve with the equation . It returns the coefficients in the form
[a, b]
.
regression.power(data[, options])
Fits the input data to a power law curve with the equation . It returns the coefficients in the form
[a, b]
.
regression.polynomial(data[, options])
Fits the input data to a polynomial curve with the equation . It returns the coefficients in the form
[an..., a1, a0]
. The order can be configure with the order
option.
const data = [[0,1],[32, 67] .... [12, 79]];
const result = regression.polynomial(data, { order: 3 });
npm install
dist
directory, use npm run build
npm run test
.2.0.1
FAQs
Javascript least squares data fitting methods
The npm package regression receives a total of 101,505 weekly downloads. As such, regression popularity was classified as popular.
We found that regression demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.