class staticanalytics~preprocessing. Binarizer
Source: analyticsdoc.
Transform given array of labels into binary vector with different numeric value for elements when label matches specified label and for other elements. By default, these values are +1 for matching labels, and -1 for the rest.
Method
new Binarizer(y, positiveLabel[, positiveId][, negativeId])
Transforming arrays with labels to vector appropriate for binary classifiers.
Example
// import analytics module
var analytics = require('qminer').analytics;
// create binarizer with 'b' as positive label
var binarizer = new analytics.preprocessing.Binarizer('b');
Parameters
Name | Type | Optional | Description |
---|---|---|---|
y |
Array |
|
Labels. |
positiveLabel |
(string or number) |
|
Positive label. |
positiveId |
number |
Yes |
Value when matching positive label. Defaults to |
negativeId |
number |
Yes |
Value when not matching positive label. Defaults to |
Method
transform(y) → modul:la.Vector
Transform given array of labels to binary numeric vector.
Example
// import analytics module
var analytics = require('qminer').analytics;
// create binarizer with 'b' as positive label
var binarizer = new analytics.preprocessing.Binarizer('b');
// get vector with binarized labels
var bins = binarizer.transform(['a','b','a','c']);
Parameter
Name | Type | Optional | Description |
---|---|---|---|
y |
(Array of number, Array of string, module:la.Vector, or module:la.StrVector) |
|
Labels. |
- Returns
-
modul:la.Vector
Binarized vector.