ml-regression
Advanced tools
Comparing version
@@ -25,5 +25,5 @@ 'use strict'; | ||
/** | ||
* @constructor | ||
* @param x: Independent variable | ||
* @param y: Dependent variable | ||
* @class | ||
* @param x - Independent variable | ||
* @param y - Dependent variable | ||
* @param M | ||
@@ -154,7 +154,5 @@ */ | ||
* Constructor for the 2D polynomial fitting | ||
* | ||
* @param inputs | ||
* @param outputs | ||
* @param options | ||
* @constructor | ||
*/ | ||
@@ -188,4 +186,3 @@ constructor(inputs, outputs, options = {}) { | ||
* The third argument is an object with the following options: | ||
* * order: order of the polynomial to fit. | ||
* | ||
* order: order of the polynomial to fit. | ||
* @param {Matrix} X - A matrix with n rows and 2 columns. | ||
@@ -223,5 +220,5 @@ * @param {Matrix} y - A vector of the prediction values. | ||
let scaleX1 = 1.0 / x1.clone().abs().max(); | ||
let scaleX2 = 1.0 / x2.clone().abs().max(); | ||
let scaleY = 1.0 / y.clone().abs().max(); | ||
let scaleX1 = 1 / x1.clone().abs().max(); | ||
let scaleX2 = 1 / x2.clone().abs().max(); | ||
let scaleY = 1 / y.clone().abs().max(); | ||
@@ -319,6 +316,5 @@ x1.mulColumn(0, scaleX1); | ||
* Function that given a column vector return this: vector^power | ||
* | ||
* @param x - Column vector. | ||
* @param power - Pow number. | ||
* @return {Suite|Matrix} | ||
* @returns {Suite|Matrix} | ||
*/ | ||
@@ -325,0 +321,0 @@ function powColVector(x, power) { |
{ | ||
"name": "ml-regression", | ||
"version": "6.2.0", | ||
"version": "6.3.0", | ||
"description": "Regression algorithms", | ||
@@ -12,2 +12,3 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"build": "cheminfo-build --entry src/index.js --root Regression", | ||
"compile": "rollup -c", | ||
@@ -20,4 +21,3 @@ "eslint": "eslint src", | ||
"test": "npm run test-coverage && npm run eslint && npm run prettier", | ||
"test-only": "jest", | ||
"test-coverage": "jest --coverage" | ||
"test-only": "vitest run --coverage" | ||
}, | ||
@@ -42,20 +42,18 @@ "repository": { | ||
"homepage": "https://github.com/mljs/regression", | ||
"jest": { | ||
"testEnvironment": "node" | ||
}, | ||
"devDependencies": { | ||
"@babel/plugin-transform-modules-commonjs": "^7.25.7", | ||
"@types/jest": "^29.5.13", | ||
"eslint": "^9.12.0", | ||
"eslint-config-cheminfo": "^12.0.1", | ||
"globals": "^15.11.0", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.3.3", | ||
"rollup": "^4.24.0" | ||
"@babel/plugin-transform-modules-commonjs": "^7.27.1", | ||
"@vitest/coverage-v8": "^3.1.3", | ||
"cheminfo-build": "^1.2.1", | ||
"eslint": "^9.26.0", | ||
"eslint-config-cheminfo": "^14.1.1", | ||
"globals": "^16.1.0", | ||
"prettier": "^3.5.3", | ||
"rollup": "^4.40.2", | ||
"vitest": "^3.1.3" | ||
}, | ||
"dependencies": { | ||
"ml-kernel": "^3.0.0", | ||
"ml-matrix": "^6.12.0", | ||
"ml-matrix": "^6.12.1", | ||
"ml-regression-base": "^4.0.0", | ||
"ml-regression-exponential": "^3.0.1", | ||
"ml-regression-exponential": "^3.0.2", | ||
"ml-regression-multivariate-linear": "^2.0.4", | ||
@@ -62,0 +60,0 @@ "ml-regression-polynomial": "^3.0.1", |
@@ -0,1 +1,3 @@ | ||
import { describe, it, expect } from "vitest"; | ||
import { PolinomialFitting2D as Polyfit } from ".."; | ||
@@ -52,3 +54,3 @@ | ||
let X = new Array(len); | ||
let val = 5.0; | ||
let val = 5; | ||
let y = new Array(len); | ||
@@ -55,0 +57,0 @@ for (let i = 0; i < len; ++i, val += 0.5) { |
import { Matrix } from "ml-matrix"; | ||
import { describe, it, expect } from "vitest"; | ||
@@ -3,0 +4,0 @@ import { KernelRidgeRegression } from ".."; |
@@ -0,1 +1,3 @@ | ||
import { describe, it, expect } from "vitest"; | ||
import { NLR } from ".."; | ||
@@ -6,3 +8,3 @@ | ||
it("Potential regression", () => { | ||
let x = [0.2, 0.4, 0.6, 0.8, 1.0]; | ||
let x = [0.2, 0.4, 0.6, 0.8, 1]; | ||
let y = [0.196, 0.785, 1.7665, 3.1405, 4.9075]; | ||
@@ -32,3 +34,3 @@ let result = new NLR.PotentialRegression(x, y, 2, { | ||
expect(regression.M).toBe(-1); | ||
expect(regression.toLaTeX()).toBe("f(x) = \\frac{1}{x^{1}}"); | ||
expect(regression.toLaTeX()).toBe(String.raw`f(x) = \frac{1}{x^{1}}`); | ||
@@ -35,0 +37,0 @@ let model = regression.toJSON(); |
@@ -0,1 +1,3 @@ | ||
import { describe, it, expect } from "vitest"; | ||
import * as regression from ".."; | ||
@@ -2,0 +4,0 @@ |
@@ -12,7 +12,5 @@ import { Matrix, SVD } from "ml-matrix"; | ||
* Constructor for the 2D polynomial fitting | ||
* | ||
* @param inputs | ||
* @param outputs | ||
* @param options | ||
* @constructor | ||
*/ | ||
@@ -46,4 +44,3 @@ constructor(inputs, outputs, options = {}) { | ||
* The third argument is an object with the following options: | ||
* * order: order of the polynomial to fit. | ||
* | ||
* order: order of the polynomial to fit. | ||
* @param {Matrix} X - A matrix with n rows and 2 columns. | ||
@@ -81,5 +78,5 @@ * @param {Matrix} y - A vector of the prediction values. | ||
let scaleX1 = 1.0 / x1.clone().abs().max(); | ||
let scaleX2 = 1.0 / x2.clone().abs().max(); | ||
let scaleY = 1.0 / y.clone().abs().max(); | ||
let scaleX1 = 1 / x1.clone().abs().max(); | ||
let scaleX2 = 1 / x2.clone().abs().max(); | ||
let scaleY = 1 / y.clone().abs().max(); | ||
@@ -177,6 +174,5 @@ x1.mulColumn(0, scaleX1); | ||
* Function that given a column vector return this: vector^power | ||
* | ||
* @param x - Column vector. | ||
* @param power - Pow number. | ||
* @return {Suite|Matrix} | ||
* @returns {Suite|Matrix} | ||
*/ | ||
@@ -183,0 +179,0 @@ function powColVector(x, power) { |
@@ -15,5 +15,5 @@ import { BaseRegression, maybeToPrecision } from "ml-regression-base"; | ||
/** | ||
* @constructor | ||
* @param x: Independent variable | ||
* @param y: Dependent variable | ||
* @class | ||
* @param x - Independent variable | ||
* @param y - Dependent variable | ||
* @param M | ||
@@ -20,0 +20,0 @@ */ |
30141
0.5%9
12.5%820
-0.49%Updated