Skip to content

Commit 4bc56fc

Browse files
feat: add support for none to indicate no regularization
PR-URL: #13672 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com> Signed-off-by: Athan Reines <kgryte@gmail.com> Ref: #12875
1 parent 04b5db2 commit 4bc56fc

13 files changed

Lines changed: 29 additions & 13 deletions

File tree

‎lib/node_modules/@stdlib/ml/base/sgd-classification/penalties/README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ Returns a list of SGD classification penalties.
4646

4747
```javascript
4848
var out = penalties();
49-
// e.g., returns [ 'elasticnet', 'l1', 'l2' ]
49+
// e.g., returns [ 'elasticnet', 'l1', 'l2', 'none' ]
5050
```
5151

5252
The output array contains the following penalties:
5353

5454
- `elasticnet`: regularization method that linearly combines the L1 and L2 penalties of the lasso and ridge methods.
5555
- `l1`: L1 regularization (also called LASSO) leads to sparse models by adding a penalty based on the absolute value of coefficients.
5656
- `l2`: L2 regularization (also called ridge regression) encourages smaller, more evenly distributed weights by adding a penalty based on the square of the coefficients.
57+
- `none`: no regularization.
5758

5859
</section>
5960

@@ -128,6 +129,7 @@ An enumeration of SGD classification penalties with the following fields:
128129
- **STDLIB_ML_SGD_CLASSIFICATION_ELASTICNET**: regularization method that linearly combines the L1 and L2 penalties of the lasso and ridge methods.
129130
- **STDLIB_ML_SGD_CLASSIFICATION_L1**: L1 regularization (also called LASSO) leads to sparse models by adding a penalty based on the absolute value of coefficients.
130131
- **STDLIB_ML_SGD_CLASSIFICATION_L2**: L2 regularization (also called ridge regression) encourages smaller, more evenly distributed weights by adding a penalty based on the square of the coefficients.
132+
- **STDLIB_ML_SGD_CLASSIFICATION_NONE**: no regularization.
131133

132134
```c
133135
#include "stdlib/ml/base/sgd-classification/penalties.h"

‎lib/node_modules/@stdlib/ml/base/sgd-classification/penalties/docs/repl.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- l2: L2 regularization (also called ridge regression) encourages smaller,
1212
more evenly distributed weights by adding a penalty based on the square of
1313
the coefficients.
14+
- none: no regularization.
1415

1516
Returns
1617
-------

‎lib/node_modules/@stdlib/ml/base/sgd-classification/penalties/docs/types/index.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
* @example
2727
* var list = penalties();
28-
* // e.g., returns [ 'elasticnet', 'l1', 'l2' ]
28+
* // e.g., returns [ 'elasticnet', 'l1', 'l2', 'none' ]
2929
*/
3030
declare function penalties(): Array<string>;
3131

‎lib/node_modules/@stdlib/ml/base/sgd-classification/penalties/include/stdlib/ml/base/sgd-classification/penalties.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ enum STDLIB_ML_SGD_CLASSIFICATION_PENALTY {
3030
STDLIB_ML_SGD_CLASSIFICATION_L1,
3131

3232
// L2 regularization (also called ridge regression) encourages smaller, more evenly distributed weights by adding a penalty based on the square of the coefficients:
33-
STDLIB_ML_SGD_CLASSIFICATION_L2
33+
STDLIB_ML_SGD_CLASSIFICATION_L2,
34+
35+
// No regularization:
36+
STDLIB_ML_SGD_CLASSIFICATION_NONE
3437
};
3538

3639
#endif // !STDLIB_ML_BASE_SGD_CLASSIFICATION_PENALTIES_H
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
22
"elasticnet",
33
"l1",
4-
"l2"
4+
"l2",
5+
"none"
56
]

‎lib/node_modules/@stdlib/ml/base/sgd-classification/penalties/lib/enum.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ function enumerated() {
4444
'l1': 1,
4545

4646
// L2 regularization (also called ridge regression) encourages smaller, more evenly distributed weights by adding a penalty based on the square of the coefficients:
47-
'l2': 2
47+
'l2': 2,
48+
49+
// No regularization:
50+
'none': 3
4851
};
4952
}
5053

‎lib/node_modules/@stdlib/ml/base/sgd-classification/penalties/lib/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* var penalties = require( '@stdlib/ml/base/sgd-classification/penalties' );
2828
*
2929
* var list = penalties();
30-
* // e.g., returns [ 'elasticnet', 'l1', 'l2' ]
30+
* // e.g., returns [ 'elasticnet', 'l1', 'l2', 'none' ]
3131
*/
3232

3333
// MODULES //

‎lib/node_modules/@stdlib/ml/base/sgd-classification/penalties/lib/main.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var DATA = require( './data.json' );
3232
*
3333
* @example
3434
* var list = penalties();
35-
* // e.g., returns [ 'elasticnet', 'l1', 'l2' ]
35+
* // e.g., returns [ 'elasticnet', 'l1', 'l2', 'none' ]
3636
*/
3737
function penalties() {
3838
return DATA.slice();

‎lib/node_modules/@stdlib/ml/base/sgd-classification/penalties/test/test.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ tape( 'the function returns a list of SGD classification penalties', function te
4141
expected = [
4242
'elasticnet',
4343
'l1',
44-
'l2'
44+
'l2',
45+
'none'
4546
];
4647
actual = penalties();
4748

@@ -64,7 +65,8 @@ tape( 'attached to the main function is an `enum` method to return an object map
6465
o = [
6566
'elasticnet',
6667
'l1',
67-
'l2'
68+
'l2',
69+
'none'
6870
];
6971
for ( i = 0; i < o.length; i++ ) {
7072
t.strictEqual( hasOwnProp( obj, o[ i ] ), true, 'has property `' + o[ i ] + '`' );

‎lib/node_modules/@stdlib/ml/base/sgd-classification/penalty-enum2str/benchmark/benchmark.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ bench( pkg, function benchmark( b ) {
3737
values = [
3838
str2enum( 'elasticnet' ),
3939
str2enum( 'l1' ),
40-
str2enum( 'l2' )
40+
str2enum( 'l2' ),
41+
str2enum( 'none' )
4142
];
4243

4344
b.tic();

0 commit comments

Comments
 (0)