text: /**
  * @license Apache-2.0
  *
  * Copyright (c) 2018 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 isObject = require( '@stdlib/assert/is-object' );
  var onlineSGDRegression = require( './../lib' );
  
  
  // TESTS //
  
  tape( 'main export is a function', function test( t ) {
  	t.ok( true, __filename );
  	t.equal( typeof onlineSGDRegression, 'function', 'main export is a function' );
  	t.end();
  });
  
  tape( 'the function throws an error if the `options` object is not a simple object', function test( t ) {
  	var values;
  	var i;
  
  	values = [
  		'abc',
  		5,
  		null,
  		true,
  		undefined,
  		NaN,
  		[],
  		function noop() {}
  	];
  
  	for ( i = 0; i < values.length; i++ ) {
  		t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
  	}
  	t.end();
  
  	function badValue( value ) {
  		return function badValue() {
  			onlineSGDRegression( value );
  		};
  	}
  });
  
  tape( 'the `loss` option of the function specifies the used loss function', function test( t ) {
  	var values;
  	var model;
  	var len;
  	var i;
  
  	values = [
  		'epsilonInsensitive',
  		'huber',
  		'squaredError'
  	];
  	len = values.length;
  
  	for ( i = 0; i < len; i++ ) {
  		model = onlineSGDRegression({
  			'loss': values[ i ]
  		});
  		t.equal( isObject( model ), true, 'returns an object' );
  	}
  
  	t.end();
  });
  
  tape( 'the function throws an error if supplied an unknown `loss` option', function test( t ) {
  	t.throws( badValue, Error, 'throws an error when provided unknown loss' );
  	t.end();
  
  	function badValue() {
  		onlineSGDRegression({
  			'loss': 'hilbert'
  		});
  	}
  });
  
  tape( 'the `learningRate` option can be used to set the strength schedule of the gradient descent algorithm', function test( t ) {
  	var values;
  	var len;
  	var i;
  
  	values = [
  		'basic',
  		'constant',
  		'pegasos'
  	];
  	for ( i = 0; i < len; i++ ) {
  		onlineSGDRegression({
  			'learningRate': values[ i ]
  		});
  	}
  	t.end();
  });
  
  tape( 'the constructor throws an error if supplied an unknown `learningRate` option', function test( t ) {
  	t.throws( badValue, Error, 'throws an error when provided unknown learning rate' );
  	t.end();
  
  	function badValue() {
  		onlineSGDRegression({
  			'learningRate': 'scaling'
  		});
  	}
  });
  
  tape( 'the function has an `intercept` option determining whether the regression model should include an implicit intercept / bias term', function test( t ) {
  	var model;
  
  	model = onlineSGDRegression({
  		'intercept': true
  	});
  	model.update( [ 1.0, 1.0, 1.0 ], 2.0 );
  	t.equal( model.coefs.length, 4, 'the model contains a regression coefficient for the intercept' );
  
  	model = onlineSGDRegression({
  		'intercept': false
  	});
  	model.update( [ 1.0, 1.0, 1.0 ], 2.0 );
  	t.equal( model.coefs.length, 3, 'the model does not contain an intercept regression coefficient' );
  
  	t.end();
  });
  
  tape( 'the `update` method throws an error if the `x` value is not an array', function test( t ) {
  	var values;
  	var model;
  	var i;
  	var y;
  
  	model = onlineSGDRegression();
  	values = [
  		'abc',
  		5,
  		null,
  		true,
  		undefined,
  		NaN,
  		{},
  		function noop() {}
  	];
  	y = 2.0;
  
  	for ( i = 0; i < values.length; i++ ) {
  		t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
  	}
  	t.end();
  
  	function badValue( value ) {
  		return function badValue() {
  			model.update( value, y );
  		};
  	}
  });
  
  tape( 'the `update` method throws an error if the `x` is an array with an invalid number of elements', function test( t ) {
  	var model;
  	var i;
  	var y;
  	var x;
  
  	model = onlineSGDRegression();
  	y = 2.0;
  	x = [ 1.0, 1.0 ];
  	model.update( x, y );
  
  	for ( i = 0; i < 10; i++ ) {
  		x.push( 1.0 );
  		t.throws( badValue, TypeError, 'throws an error when provided an array of any length other than two' );
  	}
  	t.end();
  
  	function badValue() {
  		model.update( x, y );
  	}
  });
  
  tape( 'the `predict` method calculates the inner product of the weights and feature vector `x`', function test( t ) {
  	var expected;
  	var weights;
  	var actual;
  	var model;
  	var i;
  	var x;
  
  	model = onlineSGDRegression();
  	model.update( [ 0.0, 0.0 ], 2.0 );
  	weights = model.coefs;
  
  	x = [ 2.0, 2.0 ];
  	actual = model.predict( x );
  
  	// Add intercept...
  	x.push( 1.0 );
  	expected = 0;
  	for ( i = 0; i < weights.length; i++ ) {
  		expected += x[ i ] * weights[ i ];
  	}
  	t.deepEqual( actual, expected, 'deep equal' );
  
  	t.end();
  });
  
  tape( 'the `predict` method throws an error if the `x` value is not an array', function test( t ) {
  	var values;
  	var model;
  	var i;
  
  	model = onlineSGDRegression();
  	values = [
  		'abc',
  		5,
  		null,
  		true,
  		undefined,
  		NaN,
  		{},
  		function noop() {}
  	];
  
  	for ( i = 0; i < values.length; i++ ) {
  		t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
  	}
  	t.end();
  
  	function badValue( value ) {
  		return function badValue() {
  			model.predict( value );
  		};
  	}
  });
  
  tape( 'the `predict` method throws an error if the `x` is an array with an invalid number of elements', function test( t ) {
  	var model;
  	var i;
  	var x;
  
  	model = onlineSGDRegression();
  	x = [ 1.0, 1.0 ];
  	model.update( x, 2.0 );
  
  	for ( i = 0; i < 10; i++ ) {
  		x.push( 1.0 );
  		t.throws( badValue, TypeError, 'throws an error when provided an array of any length other than two' );
  	}
  	t.end();
  
  	function badValue() {
  		model.predict( x );
  	}
  });
  