New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ml-regression-power

Package Overview
Dependencies
Maintainers
6
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-regression-power - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

src/__tests__/index.test.js

37

lib/index.js
'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var mlRegressionBase = require('ml-regression-base');
var mlRegressionSimpleLinear = require('ml-regression-simple-linear');
var BaseRegression = require('ml-regression-base');
var BaseRegression__default = _interopDefault(BaseRegression);
var SimpleLinearRegression = _interopDefault(require('ml-regression-simple-linear'));
class PowerRegression extends BaseRegression__default {
class PowerRegression extends mlRegressionBase.BaseRegression {
constructor(x, y) {

@@ -17,3 +14,3 @@ super();

} else {
BaseRegression.checkArrayLength(x, y);
mlRegressionBase.checkArrayLength(x, y);
regress(this, x, y);

@@ -24,3 +21,3 @@ }

_predict(newInputs) {
return this.A * Math.pow(newInputs, this.B);
return this.A * newInputs ** this.B;
}

@@ -32,3 +29,3 @@

A: this.A,
B: this.B
B: this.B,
};

@@ -38,6 +35,6 @@ }

toString(precision) {
return `f(x) = ${BaseRegression.maybeToPrecision(
return `f(x) = ${mlRegressionBase.maybeToPrecision(
this.A,
precision
)} * x^${BaseRegression.maybeToPrecision(this.B, precision)}`;
precision,
)} * x^${mlRegressionBase.maybeToPrecision(this.B, precision)}`;
}

@@ -48,11 +45,11 @@

if (this.B >= 0) {
latex = `f(x) = ${BaseRegression.maybeToPrecision(
latex = `f(x) = ${mlRegressionBase.maybeToPrecision(
this.A,
precision
)}x^{${BaseRegression.maybeToPrecision(this.B, precision)}}`;
precision,
)}x^{${mlRegressionBase.maybeToPrecision(this.B, precision)}}`;
} else {
latex = `f(x) = \\frac{${BaseRegression.maybeToPrecision(
latex = `f(x) = \\frac{${mlRegressionBase.maybeToPrecision(
this.A,
precision
)}}{x^{${BaseRegression.maybeToPrecision(-this.B, precision)}}}`;
precision,
)}}{x^{${mlRegressionBase.maybeToPrecision(-this.B, precision)}}}`;
}

@@ -80,3 +77,3 @@ latex = latex.replace(/e([+-]?[0-9]+)/g, 'e^{$1}');

const linear = new SimpleLinearRegression(xl, yl);
const linear = new mlRegressionSimpleLinear.SimpleLinearRegression(xl, yl);
pr.A = Math.exp(linear.intercept);

@@ -86,2 +83,2 @@ pr.B = linear.slope;

module.exports = PowerRegression;
exports.PowerRegression = PowerRegression;
{
"name": "ml-regression-power",
"version": "2.0.0",
"version": "3.0.0",
"description": "Power regression",

@@ -15,4 +15,6 @@ "main": "lib/index.js",

"eslint-fix": "npm run eslint -- --fix",
"prepublishOnly": "npm run compile",
"test": "npm run test-coverage && npm run eslint",
"prepack": "npm run compile",
"prettier": "prettier --check src",
"prettier-write": "prettier --write src",
"test": "npm run test-coverage && npm run eslint && npm run prettier",
"test-only": "jest",

@@ -36,14 +38,14 @@ "test-coverage": "jest --coverage"

"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.4.4",
"eslint": "^5.16.0",
"eslint-config-cheminfo": "^1.20.1",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-jest": "^22.5.1",
"jest": "^24.7.1",
"rollup": "^1.10.1"
"@babel/plugin-transform-modules-commonjs": "^7.24.1",
"@types/jest": "^29.5.12",
"eslint": "^8.57.0",
"eslint-config-cheminfo": "^9.2.0",
"jest": "^29.7.0",
"prettier": "^3.2.5",
"rollup": "^4.17.2"
},
"dependencies": {
"ml-regression-base": "^2.0.1",
"ml-regression-simple-linear": "^2.0.2"
"ml-regression-base": "^4.0.0",
"ml-regression-simple-linear": "^3.0.0"
}
}

@@ -23,5 +23,5 @@ # regression-power

[npm-url]: https://npmjs.org/package/ml-regression-power
[travis-image]: https://img.shields.io/travis/mljs/regression-power/master.svg?style=flat-square
[travis-image]: https://img.shields.io/travis/mljs/regression-power/main.svg?style=flat-square
[travis-url]: https://travis-ci.org/mljs/regression-power
[download-image]: https://img.shields.io/npm/dm/ml-regression-power.svg?style=flat-square
[download-url]: https://npmjs.org/package/ml-regression-power

@@ -1,8 +0,9 @@

import BaseRegression, {
import {
BaseRegression,
checkArrayLength,
maybeToPrecision
maybeToPrecision,
} from 'ml-regression-base';
import SimpleLinearRegression from 'ml-regression-simple-linear';
import { SimpleLinearRegression } from 'ml-regression-simple-linear';
export default class PowerRegression extends BaseRegression {
export class PowerRegression extends BaseRegression {
constructor(x, y) {

@@ -21,3 +22,3 @@ super();

_predict(newInputs) {
return this.A * Math.pow(newInputs, this.B);
return this.A * newInputs ** this.B;
}

@@ -29,3 +30,3 @@

A: this.A,
B: this.B
B: this.B,
};

@@ -37,3 +38,3 @@ }

this.A,
precision
precision,
)} * x^${maybeToPrecision(this.B, precision)}`;

@@ -47,3 +48,3 @@ }

this.A,
precision
precision,
)}x^{${maybeToPrecision(this.B, precision)}}`;

@@ -53,3 +54,3 @@ } else {

this.A,
precision
precision,
)}}{x^{${maybeToPrecision(-this.B, precision)}}}`;

@@ -56,0 +57,0 @@ }

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