Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ Returns a list of SGD classification penalties.

```javascript
var out = penalties();
// e.g., returns [ 'elasticnet', 'l1', 'l2' ]
// e.g., returns [ 'elasticnet', 'l1', 'l2', 'none' ]
```

The output array contains the following penalties:

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

</section>

Expand Down Expand Up @@ -128,6 +129,7 @@ An enumeration of SGD classification penalties with the following fields:
- **STDLIB_ML_SGD_CLASSIFICATION_ELASTICNET**: regularization method that linearly combines the L1 and L2 penalties of the lasso and ridge methods.
- **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.
- **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.
- **STDLIB_ML_SGD_CLASSIFICATION_NONE**: no regularization.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This naming convention is a bit risky insofar as this doesn't clash with any other enum belonging to other parameterizations (e.g., loss functions, learning rates, etc).

Fine to leave as is for now. Otherwise, we may need to update our conventions if this assumption is invalidated in the future.


```c
#include "stdlib/ml/base/sgd-classification/penalties.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- l2: L2 regularization (also called ridge regression) encourages smaller,
more evenly distributed weights by adding a penalty based on the square of
the coefficients.
- none: no regularization.

Returns
-------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @example
* var list = penalties();
* // e.g., returns [ 'elasticnet', 'l1', 'l2' ]
* // e.g., returns [ 'elasticnet', 'l1', 'l2', 'none' ]
*/
declare function penalties(): Array<string>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ enum STDLIB_ML_SGD_CLASSIFICATION_PENALTY {
STDLIB_ML_SGD_CLASSIFICATION_L1,

// L2 regularization (also called ridge regression) encourages smaller, more evenly distributed weights by adding a penalty based on the square of the coefficients:
STDLIB_ML_SGD_CLASSIFICATION_L2
STDLIB_ML_SGD_CLASSIFICATION_L2,

// No regularization:
STDLIB_ML_SGD_CLASSIFICATION_NONE
};

#endif // !STDLIB_ML_BASE_SGD_CLASSIFICATION_PENALTIES_H
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
"elasticnet",
"l1",
"l2"
"l2",
"none"
]
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ function enumerated() {
'l1': 1,

// L2 regularization (also called ridge regression) encourages smaller, more evenly distributed weights by adding a penalty based on the square of the coefficients:
'l2': 2
'l2': 2,

// No regularization:
'none': 3
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* var penalties = require( '@stdlib/ml/base/sgd-classification/penalties' );
*
* var list = penalties();
* // e.g., returns [ 'elasticnet', 'l1', 'l2' ]
* // e.g., returns [ 'elasticnet', 'l1', 'l2', 'none' ]
*/

// MODULES //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var DATA = require( './data.json' );
*
* @example
* var list = penalties();
* // e.g., returns [ 'elasticnet', 'l1', 'l2' ]
* // e.g., returns [ 'elasticnet', 'l1', 'l2', 'none' ]
*/
function penalties() {
return DATA.slice();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ tape( 'the function returns a list of SGD classification penalties', function te
expected = [
'elasticnet',
'l1',
'l2'
'l2',
'none'
];
actual = penalties();

Expand All @@ -64,7 +65,8 @@ tape( 'attached to the main function is an `enum` method to return an object map
o = [
'elasticnet',
'l1',
'l2'
'l2',
'none'
];
for ( i = 0; i < o.length; i++ ) {
t.strictEqual( hasOwnProp( obj, o[ i ] ), true, 'has property `' + o[ i ] + '`' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ bench( pkg, function benchmark( b ) {
values = [
str2enum( 'elasticnet' ),
str2enum( 'l1' ),
str2enum( 'l2' )
str2enum( 'l2' ),
str2enum( 'none' )
];

b.tic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ var enum2str = require( './../lib' );
var VALUES = [
'elasticnet',
'l1',
'l2'
'l2',
'none'
];


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ bench( pkg, function benchmark( b ) {
values = [
'elasticnet',
'l1',
'l2'
'l2',
'none'
];

b.tic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ var str2enum = require( './../lib' );
var VALUES = [
'elasticnet',
'l1',
'l2'
'l2',
'none'
];


Expand Down