Skip to content

Commit 8860e1f

Browse files
committed
Move SGD packages to incr namespace
1 parent 582b041 commit 8860e1f

53 files changed

Lines changed: 221 additions & 312 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/node_modules/@stdlib/ml/README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ var algs = ml;
3939
// returns {...}
4040
```
4141

42+
The namespace contains the following sub-namespaces:
43+
4244
<!-- <toc pattern="*"> -->
4345

4446
<div class="namespace-toc">
4547

46-
- <span class="signature">[`onlineBinaryClassification( [options] )`][@stdlib/ml/online-binary-classification]</span><span class="delimiter">: </span><span class="description">online binary classification via Stochastic Gradient Descent.</span>
47-
- <span class="signature">[`onlineSGDRegression( [options] )`][@stdlib/ml/online-sgd-regression]</span><span class="delimiter">: </span><span class="description">online regression via Stochastic Gradient Descent.</span>
48-
4948
</div>
5049

5150
<!-- </toc> -->
@@ -77,10 +76,6 @@ console.log( objectKeys( ml ) );
7776

7877
<!-- <toc-links> -->
7978

80-
[@stdlib/ml/online-binary-classification]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ml/online-binary-classification
81-
82-
[@stdlib/ml/online-sgd-regression]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ml/online-sgd-regression
83-
8479
<!-- </toc-links> -->
8580

8681
</section>

lib/node_modules/@stdlib/ml/docs/types/index.d.ts

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
/* tslint:disable:max-file-line-count */
2323

2424
import incr = require( '@stdlib/ml/incr' );
25-
import onlineBinaryClassification = require( '@stdlib/ml/online-binary-classification' );
26-
import onlineSGDRegression = require( '@stdlib/ml/online-sgd-regression' );
2725

2826
/**
2927
* Interface describing the `ml` namespace.
@@ -33,90 +31,6 @@ interface Namespace {
3331
* Standard library incremental machine learning algorithms.
3432
*/
3533
incr: typeof incr;
36-
37-
/**
38-
* Online learning for classification using stochastic gradient descent (SGD).
39-
*
40-
* ## Method
41-
*
42-
* The sub-gradient of the loss function is estimated for each datum and the classification model is updated incrementally, with a decreasing learning rate and regularization of the feature weights based on L2 regularization.
43-
*
44-
* ## References
45-
*
46-
* - Shalev-Shwartz, S., Singer, Y., Srebro, N., & Cotter, A. (2011). Pegasos: Primal estimated sub-gradient solver for SVM. Mathematical Programming, 127(1), 3–30. doi:10.1007/s10107-010-0420-4
47-
*
48-
* @param options - options object
49-
* @param options.epsilon - insensitivity parameter (default: 0.1)
50-
* @param options.eta0 - constant learning rate (default: 0.02)
51-
* @param options.lambda - regularization parameter (default: 1e-3)
52-
* @param options.learningRate - string denoting the learning rate to use. Can be `constant`, `pegasos`, or `basic` (default: 'basic')
53-
* @param options.loss - string denoting the loss function to use. Can be `hinge`, `log`, `modifiedHuber`, `perceptron`, or `squaredHinge` (default: 'log')
54-
* @param options.intercept - boolean indicating whether to include an intercept (default: true)
55-
* @throws must provide valid options
56-
* @returns classification model
57-
*
58-
* @example
59-
* var ns.onlineBinaryClassification = require( `@stdlib/streams/ml/online-sgd-classification` );
60-
*
61-
* var model = ns.onlineBinaryClassification({
62-
* 'intercept': true
63-
* 'lambda': 1e-5
64-
* });
65-
*
66-
* // Update model as observations come in:
67-
* var y = -1;
68-
* var x = [ 2.3, 1.0, 5.0 ];
69-
* model.update( x, y );
70-
*
71-
* // Predict new observation:
72-
* var yHat = model.predict( x );
73-
*
74-
* // Retrieve coefficients:
75-
* var coefs = model.coefs;
76-
*/
77-
onlineBinaryClassification: typeof onlineBinaryClassification;
78-
79-
/**
80-
* Online learning for regression using stochastic gradient descent (SGD).
81-
*
82-
* ## Method
83-
*
84-
* The sub-gradient of the loss function is estimated for each datum and the regression model is updated incrementally, with a decreasing learning rate and regularization of the feature weights based on L2 regularization.
85-
*
86-
* ## References
87-
*
88-
* - Shalev-Shwartz, S., Singer, Y., Srebro, N., & Cotter, A. (2011). Pegasos: Primal estimated sub-gradient solver for SVM. Mathematical Programming, 127(1), 3–30. doi:10.1007/s10107-010-0420-4
89-
*
90-
* @param options - options object
91-
* @param options.epsilon - insensitivity parameter (default: 0.1)
92-
* @param options.eta0 - constant learning rate (default: 0.02)
93-
* @param options.lambda - regularization parameter (default: 1e-3)
94-
* @param options.learningRate - string denoting the learning rate to use. Can be `constant`, `pegasos`, or `basic` (default: 'basic')
95-
* @param options.loss - string denoting the loss function to use. Can be `squaredError`, `epsilonInsensitive`, or `huber` (default: 'squaredError')
96-
* @param options.intercept - boolean indicating whether to include an intercept (default: true)
97-
* @throws must provide valid options
98-
* @returns regression model
99-
*
100-
* @example
101-
* var ns.onlineSGDRegression = require( `@stdlib/streams/ml/online-sgd-regression` );
102-
*
103-
* var model = ns.onlineSGDRegression({
104-
* 'intercept': true
105-
* 'lambda': 1e-5
106-
* });
107-
*
108-
* // Update model as observations come in:
109-
* var y = 3.5;
110-
* var x = [ 2.3, 1.0, 5.0 ];
111-
* model.update( x, y );
112-
*
113-
* // Predict new observation:
114-
* var yHat = model.predict( x );
115-
*
116-
* // Retrieve coefficients:
117-
* var coefs = model.coefs;
118-
*/
119-
onlineSGDRegression: typeof onlineSGDRegression;
12034
}
12135

12236
/**

lib/node_modules/@stdlib/ml/online-binary-classification/README.md renamed to lib/node_modules/@stdlib/ml/incr/binary-classification/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ limitations under the License.
2929
<!-- eslint-disable id-length -->
3030

3131
```javascript
32-
var onlineBinaryClassification = require( '@stdlib/ml/online-binary-classification' );
32+
var incrBinaryClassification = require( '@stdlib/ml/incr/binary-classification' );
3333
```
3434

35-
#### onlineBinaryClassification( \[options] )
35+
#### incrBinaryClassification( \[options] )
3636

3737
Creates an online linear regression model fitted via [stochastic gradient descent][stochastic-gradient-descent]. The module performs [L2 regularization][l2-regularization] of the model coefficients, shrinking them towards zero by penalizing the squared [euclidean norm][euclidean-norm] of the coefficients.
3838

3939
```javascript
40-
var model = onlineBinaryClassification();
40+
var model = incrBinaryClassification();
4141

4242
var idx;
4343
var i;
@@ -66,7 +66,7 @@ The function accepts the following `options`:
6666
<!-- run-disable -->
6767

6868
```javascript
69-
var model = onlineBinaryClassification({
69+
var model = incrBinaryClassification({
7070
'loss': 'modifiedHuber',
7171
'lambda': 1e-4
7272
});
@@ -107,7 +107,7 @@ opts = {
107107
};
108108
rand = createRandom( opts );
109109

110-
model = onlineBinaryClassification({
110+
model = incrBinaryClassification({
111111
'lambda': 1e-6,
112112
'loss': 'perceptron'
113113
});
@@ -123,7 +123,7 @@ coefs = model.coefs;
123123
// returns [ ~4.205, ~4.186, ~-4.206 ]
124124

125125
rand = createRandom( opts );
126-
model = onlineBinaryClassification({
126+
model = incrBinaryClassification({
127127
'lambda': 1e-2
128128
});
129129

@@ -143,15 +143,15 @@ Higher values of `lambda` reduce the variance of the model coefficient estimates
143143
By default, the model contains an `intercept` term. To omit the `intercept`, set the corresponding option to `false`:
144144

145145
```javascript
146-
var model = onlineBinaryClassification({
146+
var model = incrBinaryClassification({
147147
'intercept': false
148148
});
149149
model.update( [ 1.4, 0.5 ], 1 );
150150

151151
var dim = model.coefs.length;
152152
// returns 2
153153

154-
model = onlineBinaryClassification();
154+
model = incrBinaryClassification();
155155
model.update( [ 1.4, 0.5 ], -1 );
156156

157157
dim = model.coefs.length;
@@ -225,7 +225,7 @@ var coefs = model.coefs;
225225
var binomial = require( '@stdlib/random/base/binomial' );
226226
var normal = require( '@stdlib/random/base/normal' );
227227
var exp = require( '@stdlib/math/base/special/exp' );
228-
var onlineBinaryClassification = require( '@stdlib/ml/online-binary-classification' );
228+
var incrBinaryClassification = require( '@stdlib/ml/incr/binary-classification' );
229229

230230
var phat;
231231
var lp;
@@ -235,7 +235,7 @@ var y;
235235
var i;
236236

237237
// Create model:
238-
var model = onlineBinaryClassification({
238+
var model = incrBinaryClassification({
239239
'lambda': 1e-3,
240240
'loss': 'log',
241241
'intercept': true

lib/node_modules/@stdlib/ml/online-binary-classification/docs/types/index.d.ts renamed to lib/node_modules/@stdlib/ml/incr/binary-classification/docs/types/index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ interface Model {
118118
* @returns classification model
119119
*
120120
* @example
121-
* var onlineBinaryClassification = require( `@stdlib/streams/ml/online-sgd-classification` );
121+
* var incrBinaryClassification = require( `@stdlib/streams/ml/incr/sgd-classification` );
122122
*
123-
* var model = onlineBinaryClassification({
123+
* var model = incrBinaryClassification({
124124
* 'intercept': true
125125
* 'lambda': 1e-5
126126
* });
@@ -136,9 +136,9 @@ interface Model {
136136
* // Retrieve coefficients:
137137
* var coefs = model.coefs;
138138
*/
139-
declare function onlineBinaryClassification( options?: Options ): Model;
139+
declare function incrBinaryClassification( options?: Options ): Model;
140140

141141

142142
// EXPORTS //
143143

144-
export = onlineBinaryClassification;
144+
export = incrBinaryClassification;

0 commit comments

Comments
 (0)