|
| 1 | +/** |
| 2 | +* @license Apache-2.0 |
| 3 | +* |
| 4 | +* Copyright (c) 2025 The Stdlib Authors. |
| 5 | +* |
| 6 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +* you may not use this file except in compliance with the License. |
| 8 | +* You may obtain a copy of the License at |
| 9 | +* |
| 10 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +* |
| 12 | +* Unless required by applicable law or agreed to in writing, software |
| 13 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +* See the License for the specific language governing permissions and |
| 16 | +* limitations under the License. |
| 17 | +*/ |
| 18 | + |
| 19 | +'use strict'; |
| 20 | + |
| 21 | +/** |
| 22 | +* Incrementally perform supervised classification using lvq1. |
| 23 | +* |
| 24 | +* @module @stdlib/ml/incr/lvq |
| 25 | +* |
| 26 | +* @example |
| 27 | +* var Float64Array = require( '@stdlib/array/float64' ); |
| 28 | +* var Int32Array = require( '@stdlib/array/int32' ); |
| 29 | +* var ndarray = require( '@stdlib/ndarray/ctor' ); |
| 30 | +* var incrlvq = require( '@stdlib/ml/incr/lvq' ); |
| 31 | +* |
| 32 | +* // Define initial prototype locations (2 prototypes, 2 dimensions): |
| 33 | +* var buffer = new Float64Array( [ 0.0, 0.0, 1.0, 1.0 ] ); |
| 34 | +* var prototypes = ndarray( 'float64', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); |
| 35 | +* |
| 36 | +* // Define prototype labels: |
| 37 | +* var labelBuffer = new Int32Array( [ 0, 1 ] ); |
| 38 | +* var labels = ndarray( 'int32', labelBuffer, [ 2 ], [ 1 ], 0, 'row-major' ); |
| 39 | +* |
| 40 | +* // Create an LVQ accumulator: |
| 41 | +* var accumulator = incrlvq( prototypes, labels ); |
| 42 | +* |
| 43 | +* var out = accumulator(); |
| 44 | +* // returns {...} |
| 45 | +* |
| 46 | +* // Create a data vector: |
| 47 | +* var vecBuffer = new Float64Array( 2 ); |
| 48 | +* var vec = ndarray( 'float64', vecBuffer, [ 2 ], [ 1 ], 0, 'row-major' ); |
| 49 | +* |
| 50 | +* // Provide labeled data to the accumulator: |
| 51 | +* vec.set( 0, 0.5 ); |
| 52 | +* vec.set( 1, 0.5 ); |
| 53 | +* |
| 54 | +* out = accumulator( vec, 0 ); // data point with label 0 |
| 55 | +* // returns {...} |
| 56 | +* |
| 57 | +* vec.set( 0, 1.5 ); |
| 58 | +* vec.set( 1, 1.5 ); |
| 59 | +* |
| 60 | +* out = accumulator( vec, 1 ); // data point with label 1 |
| 61 | +* // returns {...} |
| 62 | +* |
| 63 | +* // Retrieve the current results: |
| 64 | +* out = accumulator(); |
| 65 | +* // returns {...} |
| 66 | +*/ |
| 67 | + |
| 68 | +// MAIN // |
| 69 | + |
| 70 | +var main = require( './main.js' ); |
| 71 | + |
| 72 | + |
| 73 | +// EXPORTS // |
| 74 | + |
| 75 | +module.exports = main; |
0 commit comments