From e2203ef3921983db6e1bf6be122c60867aeb7d76 Mon Sep 17 00:00:00 2001 From: nakul-krishnakumar Date: Mon, 6 Jul 2026 21:47:37 +0530 Subject: [PATCH 1/2] feat: add `ml/base/sgd-classification/loss-functions` --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../loss-functions/README.md | 201 ++++++++++++++++++ .../loss-functions/benchmark/benchmark.js | 48 +++++ .../loss-functions/docs/repl.txt | 36 ++++ .../loss-functions/docs/types/index.d.ts | 35 +++ .../loss-functions/docs/types/test.ts | 32 +++ .../loss-functions/examples/index.js | 36 ++++ .../base/sgd-classification/loss_functions.h | 54 +++++ .../loss-functions/lib/data.json | 11 + .../loss-functions/lib/enum.js | 72 +++++++ .../loss-functions/lib/index.js | 47 ++++ .../loss-functions/lib/main.js | 44 ++++ .../loss-functions/manifest.json | 36 ++++ .../loss-functions/package.json | 66 ++++++ .../loss-functions/test/test.js | 87 ++++++++ 14 files changed, 805 insertions(+) create mode 100644 lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/README.md create mode 100644 lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/examples/index.js create mode 100644 lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/include/stdlib/ml/base/sgd-classification/loss_functions.h create mode 100644 lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/data.json create mode 100644 lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/enum.js create mode 100644 lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/index.js create mode 100644 lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/main.js create mode 100644 lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/manifest.json create mode 100644 lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/package.json create mode 100644 lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/test/test.js diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/README.md b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/README.md new file mode 100644 index 000000000000..b96eedf6bd48 --- /dev/null +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/README.md @@ -0,0 +1,201 @@ + + +# Loss functions + +> SGD classification loss functions. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var lossFunctions = require( '@stdlib/ml/base/sgd-classification/loss-functions' ); +``` + +#### lossFunctions() + +Returns a list of SGD classification loss functions. + +```javascript +var out = lossFunctions(); +// e.g., returns [ 'hinge', 'log', 'modifiedHuber', 'squaredHinge', 'perceptron', 'squaredError', 'huber', 'epsilonInsensitive', 'squaredEpsilonInsensitive' ] +``` + +The output array contains the following loss functions: + +- `hinge`: Hinge loss function. Corresponds to a soft-margin linear Support Vector Machine (SVM), which can handle non-linearly separable data. +- `log`: Logistic loss function. Corresponds to Logistic Regression. +- `modifiedHuber`: Huber loss function variant for classification. +- `squaredHinge`: Squared hinge loss function SVM (L2-SVM). +- `perceptron`: Hinge loss function without a margin. Corresponds to the original perceptron by Rosenblatt (1957). +- `squaredError`: Squared error loss, i.e. the squared difference of the observed and fitted values. +- `huber`: Squared-error loss for observations with error smaller than epsilon in magnitude, linear loss otherwise. Should be used in order to decrease the influence of outliers on the model fit. +- `epsilonInsensitive`: Penalty is the absolute value of the error whenever the absolute error exceeds epsilon and zero otherwise. +- `squaredEpsilonInsensitive`: Squared epsilon insensitive loss function. + + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var contains = require( '@stdlib/array/base/assert/contains' ).factory; +var lossFunction = require( '@stdlib/ml/base/sgd-classification/loss-functions' ); + +var isLossFunction = contains( lossFunction() ); + +var bool = isLossFunction( 'hinge' ); +// returns true + +bool = isLossFunction( 'log' ); +// returns true + +bool = isLossFunction( 'beep' ); +// returns false +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/ml/base/sgd-classification/loss_functions.h" +``` + +#### STDLIB_ML_SGD_CLASSIFICATION + +An enumeration of SGD classification loss functions with the following fields: + +- **STDLIB_ML_BASE_SGD_CLASSIFICATION_HINGE**: Corresponds to a soft-margin linear Support Vector Machine (SVM), which can handle non-linearly separable data. +- **STDLIB_ML_BASE_SGD_CLASSIFICATION_LOG**: Corresponds to Logistic Regression. +- **STDLIB_ML_BASE_SGD_CLASSIFICATION_MODIFIED_HUBER**: Huber loss function variant for classification. +- **STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_HINGE**: Squared hinge loss function SVM (L2-SVM). +- **STDLIB_ML_BASE_SGD_CLASSIFICATION_PERCEPTRON**: Corresponds to the original perceptron by Rosenblatt (1957). +- **STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_ERROR**: Squared difference of the observed and fitted values. +- **STDLIB_ML_BASE_SGD_CLASSIFICATION_HUBER**: Squared-error loss for observations with error smaller than epsilon in magnitude, linear loss otherwise. +- **STDLIB_ML_BASE_SGD_CLASSIFICATION_EPSILON_INSENSITIVE**: Penalty is the absolute value of the error whenever the absolute error exceeds epsilon and zero otherwise. +- **STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_EPSILON_INSENSITIV**: Squared epsilon insensitive loss function. + +```c +#include "stdlib/ml/base/sgd-classification/loss_functions.h" + +const enum STDLIB_ML_SGD_CLASSIFICATION_LOSS_FUNCTIONS v = STDLIB_ML_SGD_CLASSIFICATION_LLOYD; +``` + +
+ + + + + +
+ +### Notes + +- Enumeration constants should be considered opaque values, and one should **not** rely on specific integer values. + +
+ + + + + +
+ +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/benchmark/benchmark.js b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/benchmark/benchmark.js new file mode 100644 index 000000000000..fc9b818bd1cd --- /dev/null +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/benchmark/benchmark.js @@ -0,0 +1,48 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var pkg = require( './../package.json' ).name; +var lossFunctions = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = lossFunctions(); + if ( out.length < 2 ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isStringArray( out ) ) { + b.fail( 'should return an array of strings' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/repl.txt b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/repl.txt new file mode 100644 index 000000000000..da07309fef0c --- /dev/null +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/repl.txt @@ -0,0 +1,36 @@ + +{{alias}}() + Returns a list of SGD classification loss functions. + + The output array contains the following loss functions: + + - hinge: Hinge loss function. Corresponds to a soft-margin linear Support + Vector Machine (SVM), which can handle non-linearly separable data. + - log: Logistic loss function. Corresponds to Logistic Regression. + - modifiedHuber: Huber loss function variant for classification. + - squaredHinge: Squared hinge loss function SVM (L2-SVM). + - perceptron: Hinge loss function without a margin. Corresponds to the + original perceptron by Rosenblatt (1957). + - squaredError: Squared error loss, i.e. the squared difference of the + observed and fitted values. + - huber: Squared-error loss for observations with error smaller than epsilon + in magnitude, linear loss otherwise. Should be used in order to decrease the + influence of outliers on the model fit. + - epsilonInsensitive: Penalty is the absolute value of the error whenever + the absolute error exceeds epsilon and zero otherwise. + - squaredEpsilonInsensitive: Squared epsilon insensitive loss function. + + + Returns + ------- + out: Array + List of loss functions. + + Examples + -------- + > var out = {{alias}}() + [...] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/types/index.d.ts b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/types/index.d.ts new file mode 100644 index 000000000000..15e98c863003 --- /dev/null +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/types/index.d.ts @@ -0,0 +1,35 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Returns a list of SGD classification loss functions. +* +* @returns list of loss functions +* +* @example +* var list = lossFunctions(); +* // e.g., returns [ 'hinge', 'log', 'modifiedHuber', 'squaredHinge', 'perceptron', 'squaredError', 'huber', 'epsilonInsensitive', 'squaredEpsilonInsensitive' ] +*/ +declare function lossFunctions(): Array; + + +// EXPORTS // + +export = lossFunctions; diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/types/test.ts b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/types/test.ts new file mode 100644 index 000000000000..6c51642dacaa --- /dev/null +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/types/test.ts @@ -0,0 +1,32 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import lossFunctions = require( './index' ); + + +// TESTS // + +// The function returns an array of strings... +{ + lossFunctions(); // $ExpectType string[] +} + +// The compiler throws an error if the function is provided any arguments... +{ + lossFunctions( 9 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/examples/index.js b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/examples/index.js new file mode 100644 index 000000000000..1fa9e2f61bbf --- /dev/null +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/examples/index.js @@ -0,0 +1,36 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var contains = require( '@stdlib/array/base/assert/contains' ).factory; +var lossFunctions = require( './../lib' ); + +var isLossFunction = contains( lossFunctions() ); + +var bool = isLossFunction( 'hinge' ); +console.log( bool ); +// => true + +bool = isLossFunction( 'log' ); +console.log( bool ); +// => true + +bool = isLossFunction( 'beep' ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/include/stdlib/ml/base/sgd-classification/loss_functions.h b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/include/stdlib/ml/base/sgd-classification/loss_functions.h new file mode 100644 index 000000000000..1d5e58929b5f --- /dev/null +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/include/stdlib/ml/base/sgd-classification/loss_functions.h @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_ML_BASE_SGD_CLASSIFICATION_LOSS_FUNCTIONS_H +#define STDLIB_ML_BASE_SGD_CLASSIFICATION_LOSS_FUNCTIONS_H + +/** +* Enumeration of SGD classification loss functions. +*/ +enum STDLIB_ML_BASE_SGD_CLASSIFICATION_LOSS_FUNCTIONS { + // Corresponds to a soft-margin linear Support Vector Machine (SVM), which can handle non-linearly separable data: + STDLIB_ML_BASE_SGD_CLASSIFICATION_HINGE = 0, + + // Corresponds to Logistic Regression: + STDLIB_ML_BASE_SGD_CLASSIFICATION_LOG, + + // Huber loss function variant for classification: + STDLIB_ML_BASE_SGD_CLASSIFICATION_MODIFIED_HUBER, + + // Squared hinge loss function SVM (L2-SVM): + STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_HINGE, + + // Corresponds to the original perceptron by Rosenblatt (1957): + STDLIB_ML_BASE_SGD_CLASSIFICATION_PERCEPTRON, + + // Squared difference of the observed and fitted values: + STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_ERROR, + + // Squared-error loss for observations with error smaller than epsilon in magnitude, linear loss otherwise: + STDLIB_ML_BASE_SGD_CLASSIFICATION_HUBER, + + // Penalty is the absolute value of the error whenever the absolute error exceeds epsilon and zero otherwise: + STDLIB_ML_BASE_SGD_CLASSIFICATION_EPSILON_INSENSITIVE, + + // Squared epsilon insensitive loss function: + STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_EPSILON_INSENSITIVE +}; + +#endif // !STDLIB_ML_BASE_SGD_CLASSIFICATION_LOSS_FUNCTIONS_H diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/data.json b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/data.json new file mode 100644 index 000000000000..63a9974c9dc8 --- /dev/null +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/data.json @@ -0,0 +1,11 @@ +[ + "hinge", + "log", + "modifiedHuber", + "squaredHinge", + "perceptron", + "squaredError", + "huber", + "epsilonInsensitive", + "squaredEpsilonInsensitive" +] diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/enum.js b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/enum.js new file mode 100644 index 000000000000..609ecbfbd37e --- /dev/null +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/enum.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Returns an object mapping supported loss functions to integer values for purposes of C inter-operation. +* +* ## Notes +* +* - Downstream consumers of this mapping should **not** rely on specific integer values (e.g., `HINGE == 0`). Instead, the object should be used in an opaque manner. +* - The main purpose of this function is JavaScript and C inter-operation. +* +* @returns {Object} object mapping supported loss functions to integer values +* +* @example +* var table = enumerated(); +* // returns +*/ +function enumerated() { + // NOTE: the following should match the C `loss functions.h` enumeration!!!! + return { + // Corresponds to a soft-margin linear Support Vector Machine (SVM), which can handle non-linearly separable data: + 'hinge': 0, + + // Corresponds to Logistic Regression: + 'log': 1, + + // Huber loss function variant for classification: + 'modifiedHuber': 2, + + // Squared hinge loss function SVM (L2-SVM): + 'squaredHinge': 3, + + // Corresponds to the original perceptron by Rosenblatt (1957): + 'perceptron': 4, + + // Squared difference of the observed and fitted values: + 'squaredError': 5, + + // Squared-error loss for observations with error smaller than epsilon in magnitude, linear loss otherwise: + 'huber': 6, + + // Penalty is the absolute value of the error whenever the absolute error exceeds epsilon and zero otherwise: + 'epsilonInsensitive': 7, + + // Squared epsilon insensitive loss function: + 'squaredEpsilonInsensitive': 8 + }; +} + + +// EXPORTS // + +module.exports = enumerated; diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/index.js b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/index.js new file mode 100644 index 000000000000..6ea3a169fdff --- /dev/null +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/index.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Return a list of SGD classification loss functions. +* +* @module @stdlib/ml/base/sgd-classification/loss-functions +* +* @example +* var lossFunctions = require( '@stdlib/ml/base/sgd-classification/loss-functions' ); +* +* var list = lossFunctions(); +* // e.g., returns [ 'hinge', 'log', 'modifiedHuber', 'squaredHinge', 'perceptron', 'squaredError', 'huber', 'epsilonInsensitive', 'squaredEpsilonInsensitive' ] +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var enumeration = require( './enum.js' ); + + +// MAIN // + +setReadOnly( main, 'enum', enumeration ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/main.js b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/main.js new file mode 100644 index 000000000000..f5272415c8ce --- /dev/null +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/main.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var DATA = require( './data.json' ); + + +// MAIN // + +/** +* Returns a list of SGD classification loss functions. +* +* @returns {Array} list of loss functions +* +* @example +* var list = lossFunctions(); +* // e.g., returns [ 'hinge', 'log', 'modifiedHuber', 'squaredHinge', 'perceptron', 'squaredError', 'huber', 'epsilonInsensitive', 'squaredEpsilonInsensitive' ] +*/ +function lossFunctions() { + return DATA.slice(); +} + + +// EXPORTS // + +module.exports = lossFunctions; diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/manifest.json b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/manifest.json new file mode 100644 index 000000000000..844d692f6439 --- /dev/null +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/manifest.json @@ -0,0 +1,36 @@ +{ + "options": {}, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "src": [], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [] + } + ] +} diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/package.json b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/package.json new file mode 100644 index 000000000000..8fb42101d6a1 --- /dev/null +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/ml/base/sgd-classification/loss-functions", + "version": "0.0.0", + "description": "SGD classification loss functions.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "ml", + "machine", + "learning", + "sgd classification", + "loss functions", + "utilities", + "utility", + "utils", + "util", + "enum" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/test/test.js b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/test/test.js new file mode 100644 index 000000000000..fe02bab71d1e --- /dev/null +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/test/test.js @@ -0,0 +1,87 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var lossFunctions = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof lossFunctions, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns a list of SGD classification loss functions', function test( t ) { + var expected; + var actual; + + expected = [ + 'hinge', + 'log', + 'modifiedHuber', + 'squaredHinge', + 'perceptron', + 'squaredError', + 'huber', + 'epsilonInsensitive', + 'squaredEpsilonInsensitive' + ]; + actual = lossFunctions(); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main function is an `enum` method to return an object mapping loss functions to integer values for C inter-operation', function test( t ) { + var obj; + var o; + var i; + + t.strictEqual( hasOwnProp( lossFunctions, 'enum' ), true, 'has property' ); + t.strictEqual( typeof lossFunctions.enum, 'function', 'has method' ); + + obj = lossFunctions.enum(); + t.strictEqual( typeof obj, 'object', 'returns expected value' ); + + // List of values which should be supported... + o = [ + 'hinge', + 'log', + 'modifiedHuber', + 'squaredHinge', + 'perceptron', + 'squaredError', + 'huber', + 'epsilonInsensitive', + 'squaredEpsilonInsensitive' + ]; + for ( i = 0; i < o.length; i++ ) { + t.strictEqual( hasOwnProp( obj, o[ i ] ), true, 'has property `' + o[ i ] + '`' ); + t.strictEqual( isNonNegativeInteger( obj[ o[i] ] ), true, 'returns expected value' ); + } + + t.end(); +}); From 54a5a86fd98629853d22a57aa8829d5ff1745afa Mon Sep 17 00:00:00 2001 From: nakul-krishnakumar Date: Tue, 7 Jul 2026 13:13:08 +0530 Subject: [PATCH 2/2] refactor: update enum list to follow alphabetical order --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../loss-functions/README.md | 20 ++++++------ .../loss-functions/docs/repl.txt | 14 ++++---- .../loss-functions/docs/types/index.d.ts | 2 +- .../base/sgd-classification/loss_functions.h | 24 +++++++------- .../loss-functions/lib/data.json | 18 +++++------ .../loss-functions/lib/enum.js | 32 +++++++++---------- .../loss-functions/lib/index.js | 2 +- .../loss-functions/lib/main.js | 2 +- .../loss-functions/test/test.js | 16 +++++----- 9 files changed, 65 insertions(+), 65 deletions(-) diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/README.md b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/README.md index b96eedf6bd48..9e016060d1c8 100644 --- a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/README.md +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/README.md @@ -46,20 +46,20 @@ Returns a list of SGD classification loss functions. ```javascript var out = lossFunctions(); -// e.g., returns [ 'hinge', 'log', 'modifiedHuber', 'squaredHinge', 'perceptron', 'squaredError', 'huber', 'epsilonInsensitive', 'squaredEpsilonInsensitive' ] +// e.g., returns [ 'epsilonInsensitive', 'hinge', 'huber', 'log', 'modifiedHuber', 'perceptron', 'squaredEpsilonInsensitive', 'squaredError', 'squaredHinge' ] ``` The output array contains the following loss functions: +- `epsilonInsensitive`: Penalty is the absolute value of the error whenever the absolute error exceeds epsilon and zero otherwise. - `hinge`: Hinge loss function. Corresponds to a soft-margin linear Support Vector Machine (SVM), which can handle non-linearly separable data. +- `huber`: Squared-error loss for observations with error smaller than epsilon in magnitude, linear loss otherwise. Should be used in order to decrease the influence of outliers on the model fit. - `log`: Logistic loss function. Corresponds to Logistic Regression. - `modifiedHuber`: Huber loss function variant for classification. -- `squaredHinge`: Squared hinge loss function SVM (L2-SVM). - `perceptron`: Hinge loss function without a margin. Corresponds to the original perceptron by Rosenblatt (1957). -- `squaredError`: Squared error loss, i.e. the squared difference of the observed and fitted values. -- `huber`: Squared-error loss for observations with error smaller than epsilon in magnitude, linear loss otherwise. Should be used in order to decrease the influence of outliers on the model fit. -- `epsilonInsensitive`: Penalty is the absolute value of the error whenever the absolute error exceeds epsilon and zero otherwise. - `squaredEpsilonInsensitive`: Squared epsilon insensitive loss function. +- `squaredError`: Squared error loss, i.e. the squared difference of the observed and fitted values. +- `squaredHinge`: Squared hinge loss function SVM (L2-SVM). @@ -132,20 +132,20 @@ bool = isLossFunction( 'beep' ); An enumeration of SGD classification loss functions with the following fields: +- **STDLIB_ML_BASE_SGD_CLASSIFICATION_EPSILON_INSENSITIVE**: Penalty is the absolute value of the error whenever the absolute error exceeds epsilon and zero otherwise. - **STDLIB_ML_BASE_SGD_CLASSIFICATION_HINGE**: Corresponds to a soft-margin linear Support Vector Machine (SVM), which can handle non-linearly separable data. +- **STDLIB_ML_BASE_SGD_CLASSIFICATION_HUBER**: Squared-error loss for observations with error smaller than epsilon in magnitude, linear loss otherwise. - **STDLIB_ML_BASE_SGD_CLASSIFICATION_LOG**: Corresponds to Logistic Regression. - **STDLIB_ML_BASE_SGD_CLASSIFICATION_MODIFIED_HUBER**: Huber loss function variant for classification. -- **STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_HINGE**: Squared hinge loss function SVM (L2-SVM). - **STDLIB_ML_BASE_SGD_CLASSIFICATION_PERCEPTRON**: Corresponds to the original perceptron by Rosenblatt (1957). +- **STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_EPSILON_INSENSITIVE**: Squared epsilon insensitive loss function. - **STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_ERROR**: Squared difference of the observed and fitted values. -- **STDLIB_ML_BASE_SGD_CLASSIFICATION_HUBER**: Squared-error loss for observations with error smaller than epsilon in magnitude, linear loss otherwise. -- **STDLIB_ML_BASE_SGD_CLASSIFICATION_EPSILON_INSENSITIVE**: Penalty is the absolute value of the error whenever the absolute error exceeds epsilon and zero otherwise. -- **STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_EPSILON_INSENSITIV**: Squared epsilon insensitive loss function. +- **STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_HINGE**: Squared hinge loss function SVM (L2-SVM). ```c #include "stdlib/ml/base/sgd-classification/loss_functions.h" -const enum STDLIB_ML_SGD_CLASSIFICATION_LOSS_FUNCTIONS v = STDLIB_ML_SGD_CLASSIFICATION_LLOYD; +const enum STDLIB_ML_SGD_CLASSIFICATION_LOSS_FUNCTIONS v = STDLIB_ML_SGD_CLASSIFICATION_HINGE; ``` diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/repl.txt b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/repl.txt index da07309fef0c..292ae56bc590 100644 --- a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/repl.txt +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/repl.txt @@ -4,21 +4,21 @@ The output array contains the following loss functions: + - epsilonInsensitive: Penalty is the absolute value of the error whenever + the absolute error exceeds epsilon and zero otherwise. - hinge: Hinge loss function. Corresponds to a soft-margin linear Support Vector Machine (SVM), which can handle non-linearly separable data. + - huber: Squared-error loss for observations with error smaller than epsilon + in magnitude, linear loss otherwise. Should be used in order to decrease the + influence of outliers on the model fit. - log: Logistic loss function. Corresponds to Logistic Regression. - modifiedHuber: Huber loss function variant for classification. - - squaredHinge: Squared hinge loss function SVM (L2-SVM). - perceptron: Hinge loss function without a margin. Corresponds to the original perceptron by Rosenblatt (1957). + - squaredEpsilonInsensitive: Squared epsilon insensitive loss function. - squaredError: Squared error loss, i.e. the squared difference of the observed and fitted values. - - huber: Squared-error loss for observations with error smaller than epsilon - in magnitude, linear loss otherwise. Should be used in order to decrease the - influence of outliers on the model fit. - - epsilonInsensitive: Penalty is the absolute value of the error whenever - the absolute error exceeds epsilon and zero otherwise. - - squaredEpsilonInsensitive: Squared epsilon insensitive loss function. + - squaredHinge: Squared hinge loss function SVM (L2-SVM). Returns diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/types/index.d.ts b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/types/index.d.ts index 15e98c863003..c107c17522ef 100644 --- a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/docs/types/index.d.ts @@ -25,7 +25,7 @@ * * @example * var list = lossFunctions(); -* // e.g., returns [ 'hinge', 'log', 'modifiedHuber', 'squaredHinge', 'perceptron', 'squaredError', 'huber', 'epsilonInsensitive', 'squaredEpsilonInsensitive' ] +* // e.g., returns [ 'epsilonInsensitive', 'hinge', 'huber', 'log', 'modifiedHuber', 'perceptron', 'squaredEpsilonInsensitive', 'squaredError', 'squaredHinge' ] */ declare function lossFunctions(): Array; diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/include/stdlib/ml/base/sgd-classification/loss_functions.h b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/include/stdlib/ml/base/sgd-classification/loss_functions.h index 1d5e58929b5f..2fb7b3fc33ef 100644 --- a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/include/stdlib/ml/base/sgd-classification/loss_functions.h +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/include/stdlib/ml/base/sgd-classification/loss_functions.h @@ -23,8 +23,14 @@ * Enumeration of SGD classification loss functions. */ enum STDLIB_ML_BASE_SGD_CLASSIFICATION_LOSS_FUNCTIONS { + // Penalty is the absolute value of the error whenever the absolute error exceeds epsilon and zero otherwise: + STDLIB_ML_BASE_SGD_CLASSIFICATION_EPSILON_INSENSITIVE = 0, + // Corresponds to a soft-margin linear Support Vector Machine (SVM), which can handle non-linearly separable data: - STDLIB_ML_BASE_SGD_CLASSIFICATION_HINGE = 0, + STDLIB_ML_BASE_SGD_CLASSIFICATION_HINGE, + + // Squared-error loss for observations with error smaller than epsilon in magnitude, linear loss otherwise: + STDLIB_ML_BASE_SGD_CLASSIFICATION_HUBER, // Corresponds to Logistic Regression: STDLIB_ML_BASE_SGD_CLASSIFICATION_LOG, @@ -32,23 +38,17 @@ enum STDLIB_ML_BASE_SGD_CLASSIFICATION_LOSS_FUNCTIONS { // Huber loss function variant for classification: STDLIB_ML_BASE_SGD_CLASSIFICATION_MODIFIED_HUBER, - // Squared hinge loss function SVM (L2-SVM): - STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_HINGE, - // Corresponds to the original perceptron by Rosenblatt (1957): STDLIB_ML_BASE_SGD_CLASSIFICATION_PERCEPTRON, + // Squared epsilon insensitive loss function: + STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_EPSILON_INSENSITIVE, + // Squared difference of the observed and fitted values: STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_ERROR, - // Squared-error loss for observations with error smaller than epsilon in magnitude, linear loss otherwise: - STDLIB_ML_BASE_SGD_CLASSIFICATION_HUBER, - - // Penalty is the absolute value of the error whenever the absolute error exceeds epsilon and zero otherwise: - STDLIB_ML_BASE_SGD_CLASSIFICATION_EPSILON_INSENSITIVE, - - // Squared epsilon insensitive loss function: - STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_EPSILON_INSENSITIVE + // Squared hinge loss function SVM (L2-SVM): + STDLIB_ML_BASE_SGD_CLASSIFICATION_SQUARED_HINGE }; #endif // !STDLIB_ML_BASE_SGD_CLASSIFICATION_LOSS_FUNCTIONS_H diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/data.json b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/data.json index 63a9974c9dc8..98f5d1b4148b 100644 --- a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/data.json +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/data.json @@ -1,11 +1,11 @@ [ - "hinge", - "log", - "modifiedHuber", - "squaredHinge", - "perceptron", - "squaredError", - "huber", - "epsilonInsensitive", - "squaredEpsilonInsensitive" + "epsilonInsensitive", + "hinge", + "huber", + "log", + "modifiedHuber", + "perceptron", + "squaredEpsilonInsensitive", + "squaredError", + "squaredHinge" ] diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/enum.js b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/enum.js index 609ecbfbd37e..c9931875a64f 100644 --- a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/enum.js +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/enum.js @@ -37,32 +37,32 @@ function enumerated() { // NOTE: the following should match the C `loss functions.h` enumeration!!!! return { + // Penalty is the absolute value of the error whenever the absolute error exceeds epsilon and zero otherwise: + 'epsilonInsensitive': 0, + // Corresponds to a soft-margin linear Support Vector Machine (SVM), which can handle non-linearly separable data: - 'hinge': 0, + 'hinge': 1, + + // Squared-error loss for observations with error smaller than epsilon in magnitude, linear loss otherwise: + 'huber': 2, // Corresponds to Logistic Regression: - 'log': 1, + 'log': 3, // Huber loss function variant for classification: - 'modifiedHuber': 2, - - // Squared hinge loss function SVM (L2-SVM): - 'squaredHinge': 3, + 'modifiedHuber': 4, // Corresponds to the original perceptron by Rosenblatt (1957): - 'perceptron': 4, - - // Squared difference of the observed and fitted values: - 'squaredError': 5, + 'perceptron': 5, - // Squared-error loss for observations with error smaller than epsilon in magnitude, linear loss otherwise: - 'huber': 6, + // Squared epsilon insensitive loss function: + 'squaredEpsilonInsensitive': 6, - // Penalty is the absolute value of the error whenever the absolute error exceeds epsilon and zero otherwise: - 'epsilonInsensitive': 7, + // Squared difference of the observed and fitted values: + 'squaredError': 7, - // Squared epsilon insensitive loss function: - 'squaredEpsilonInsensitive': 8 + // Squared hinge loss function SVM (L2-SVM): + 'squaredHinge': 8 }; } diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/index.js b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/index.js index 6ea3a169fdff..9445ed9b1243 100644 --- a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/index.js +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/index.js @@ -27,7 +27,7 @@ * var lossFunctions = require( '@stdlib/ml/base/sgd-classification/loss-functions' ); * * var list = lossFunctions(); -* // e.g., returns [ 'hinge', 'log', 'modifiedHuber', 'squaredHinge', 'perceptron', 'squaredError', 'huber', 'epsilonInsensitive', 'squaredEpsilonInsensitive' ] +* // e.g., returns [ 'epsilonInsensitive', 'hinge', 'huber', 'log', 'modifiedHuber', 'perceptron', 'squaredEpsilonInsensitive', 'squaredError', 'squaredHinge' ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/main.js b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/main.js index f5272415c8ce..225b36bdae0d 100644 --- a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/main.js +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/lib/main.js @@ -32,7 +32,7 @@ var DATA = require( './data.json' ); * * @example * var list = lossFunctions(); -* // e.g., returns [ 'hinge', 'log', 'modifiedHuber', 'squaredHinge', 'perceptron', 'squaredError', 'huber', 'epsilonInsensitive', 'squaredEpsilonInsensitive' ] +* // e.g., returns [ 'epsilonInsensitive', 'hinge', 'huber', 'log', 'modifiedHuber', 'perceptron', 'squaredEpsilonInsensitive', 'squaredError', 'squaredHinge' ] */ function lossFunctions() { return DATA.slice(); diff --git a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/test/test.js b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/test/test.js index fe02bab71d1e..217485fd546b 100644 --- a/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/test/test.js +++ b/lib/node_modules/@stdlib/ml/base/sgd-classification/loss-functions/test/test.js @@ -39,15 +39,15 @@ tape( 'the function returns a list of SGD classification loss functions', functi var actual; expected = [ + 'epsilonInsensitive', 'hinge', + 'huber', 'log', 'modifiedHuber', - 'squaredHinge', 'perceptron', + 'squaredEpsilonInsensitive', 'squaredError', - 'huber', - 'epsilonInsensitive', - 'squaredEpsilonInsensitive' + 'squaredHinge' ]; actual = lossFunctions(); @@ -68,15 +68,15 @@ tape( 'attached to the main function is an `enum` method to return an object map // List of values which should be supported... o = [ + 'epsilonInsensitive', 'hinge', + 'huber', 'log', 'modifiedHuber', - 'squaredHinge', 'perceptron', + 'squaredEpsilonInsensitive', 'squaredError', - 'huber', - 'epsilonInsensitive', - 'squaredEpsilonInsensitive' + 'squaredHinge' ]; for ( i = 0; i < o.length; i++ ) { t.strictEqual( hasOwnProp( obj, o[ i ] ), true, 'has property `' + o[ i ] + '`' );