You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ml-regression-base

Package Overview
Dependencies
Maintainers
8
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-regression-base - npm Package Compare versions

Comparing version

to
2.1.2

2

History.md

@@ -0,1 +1,3 @@

### [2.1.2](https://github.com/mljs/regression-base/compare/v2.1.1...v2.1.2) (2021-03-24)
## [2.1.1](https://github.com/mljs/regression-base/compare/v2.1.0...v2.1.1) (2020-02-04)

@@ -2,0 +4,0 @@

12

lib/index.js

@@ -5,6 +5,8 @@ 'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var isAnyArray = require('is-any-array');
var isAnyArray = _interopDefault(require('is-any-array'));
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var isAnyArray__default = /*#__PURE__*/_interopDefaultLegacy(isAnyArray);
function maybeToPrecision(value, digits) {

@@ -28,3 +30,3 @@ if (value < 0) {

function checkArraySize(x, y) {
if (!isAnyArray(x) || !isAnyArray(y)) {
if (!isAnyArray__default['default'](x) || !isAnyArray__default['default'](y)) {
throw new TypeError('x and y must be arrays');

@@ -47,3 +49,3 @@ }

return this._predict(x);
} else if (isAnyArray(x)) {
} else if (isAnyArray__default['default'](x)) {
const y = [];

@@ -82,3 +84,3 @@ for (let i = 0; i < x.length; i++) {

score(x, y) {
if (!isAnyArray(x) || !isAnyArray(y) || x.length !== y.length) {
if (!isAnyArray__default['default'](x) || !isAnyArray__default['default'](y) || x.length !== y.length) {
throw new Error('x and y must be arrays of the same length');

@@ -85,0 +87,0 @@ }

{
"name": "ml-regression-base",
"version": "2.1.1",
"version": "2.1.2",
"description": "Base class for regression modules",

@@ -38,18 +38,12 @@ "main": "lib/index.js",

"dependencies": {
"is-any-array": "0.0.3"
"is-any-array": "1.0.0"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.8.3",
"babel-jest": "^25.1.0",
"eslint": "^6.8.0",
"eslint-config-cheminfo": "^2.0.4",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jest": "^23.6.0",
"eslint-plugin-no-only-tests": "^2.4.0",
"eslint-plugin-prettier": "^3.1.2",
"jest": "^25.1.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.19.1",
"rollup": "^1.31.0"
"@babel/plugin-transform-modules-commonjs": "^7.13.8",
"eslint": "^7.22.0",
"eslint-config-cheminfo": "^5.2.3",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"rollup": "^2.42.3"
}
}
# regression-base
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![npm download][download-image]][download-url]
[![NPM version][npm-image]][npm-url]
[![build status][ci-image]][ci-url]
[![Test coverage][codecov-image]][codecov-url]
[![npm download][download-image]][download-url]

@@ -12,4 +13,6 @@ Base class for regression modules.

You only have to implement the `_predict` method. It is always called with a number.<br />
The model should be created in the constructor.<br />
You only have to implement the `_predict` method. It is always called with a number.
The model should be created in the constructor.
Optional methods that can be implemented: `toString`, `toLaTeX`.

@@ -21,12 +24,12 @@

class MyRegression extends BaseRegression {
constructor(factor) {
super();
this.factor = factor;
}
_predict(x) {
return x * this.factor;
}
toString() {
return `f(x) = x * ${this.factor}`;
}
constructor(factor) {
super();
this.factor = factor;
}
_predict(x) {
return x * this.factor;
}
toString() {
return `f(x) = x * ${this.factor}`;
}
}

@@ -37,4 +40,6 @@ ```

Convenience method to transform numbers to readable strings.<br />
If digits is not specified, "value.toString()" is used. Otherwise "value.toPrecision(digits)" is used.<br />
Convenience method to transform numbers to readable strings.
If digits is not specified, "value.toString()" is used. Otherwise "value.toPrecision(digits)" is used.
This method can be used to implement `toString()` or `toLaTeX()`.

@@ -49,9 +54,11 @@

[MIT](./LICENSE)
[MIT](./LICENSE)
[npm-image]: https://img.shields.io/npm/v/ml-regression-base.svg?style=flat-square
[npm-image]: https://img.shields.io/npm/v/ml-regression-base.svg
[npm-url]: https://npmjs.org/package/ml-regression-base
[travis-image]: https://img.shields.io/travis/mljs/regression-base/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/mljs/regression-base
[download-image]: https://img.shields.io/npm/dm/ml-regression-base.svg?style=flat-square
[codecov-image]: https://img.shields.io/codecov/c/github/mljs/regression-base.svg
[codecov-url]: https://codecov.io/gh/mljs/regression-base
[ci-image]: https://github.com/mljs/regression-base/workflows/Node.js%20CI/badge.svg?branch=master
[ci-url]: https://github.com/mljs/regression-base/actions?query=workflow%3A%22Node.js+CI%22
[download-image]: https://img.shields.io/npm/dm/ml-regression-base.svg
[download-url]: https://npmjs.org/package/ml-regression-base

@@ -0,0 +0,0 @@ declare module 'ml-regression-base' {

@@ -0,0 +0,0 @@ import checkArrayLength from '../checkArrayLength';

@@ -30,6 +30,6 @@ import maybeToPrecision from '../maybeToPrecision';

it('wrong digit option', () => {
expect(function() {
expect(function () {
maybeToPrecision(0, 0);
}).toThrow(/toPrecision\(\) argument must be between 1 and (100|21)/);
}).toThrow(/toPrecision\(\) argument must be between 1 and (?:100|21)/);
});
});

@@ -16,4 +16,3 @@ import BaseRegression from '..';

it('should not be directly constructable', () => {
expect(function() {
// eslint-disable-next-line no-new
expect(function () {
new BaseRegression();

@@ -25,3 +24,3 @@ }).toThrow(/BaseRegression must be subclassed/);

const reg = new NoPredict();
expect(function() {
expect(function () {
reg.predict(0);

@@ -40,3 +39,3 @@ }).toThrow(/_predict must be implemented/);

const basic = new Basic(2);
expect(function() {
expect(function () {
basic.predict();

@@ -43,0 +42,0 @@ }).toThrow(/must be a number or array/);

@@ -0,0 +0,0 @@ import isAnyArray from 'is-any-array';

@@ -0,0 +0,0 @@ import isAnyArray from 'is-any-array';

@@ -0,0 +0,0 @@ export default function maybeToPrecision(value, digits) {

Sorry, the diff of this file is not supported yet