XGMatrix
- matrix(data, row, col, missing = NaN) ⇒
XGMatrix
- restoreMatrix(file) ⇒
XGMatrix
- matrixFromCSC(data, indptr, indices, n = 0) ⇒
XGMatrix
- matrixFromCSR(data, indptr, indices, n = 0) ⇒
XGMatrix
XGModel
- XGModel(file) ⇒
XGModel
- XGModel.predict(xgmatrix, mask = 0, ntree = 0) ⇒
Result
- XGModel.predictAsync(xgmatrix, mask = 0, ntree = 0, cb: (err, res: Float32Array | null) => {})
Result
Kind: object - input matrix for XGModel
Field | Type | Description |
---|---|---|
matrix | internal |
readonly property |
error | Error |
error status |
Kind: global function
Returns: XGMatrix
- xgboost matrix
Param | Type | Description |
---|---|---|
data | Float32Array |
input matrix with row-major order |
row | Integer |
matrix row |
col | Integer |
matrix col |
missing | Number = NaN |
missing value place holder |
const xgboost = require('xgboost');
const input = new Float32Array([
5.1, 3.5, 1.4, 0.2, // class 0
6.6, 3. , 4.4, 1.4, // class 1
5.9, 3. , 5.1, 1.8 // class 2
]);
const mat = new xgboost.matrix(input, 3, 4);
Kind: member function
Returns: Result
- return matrix column size
mat.col();
Kind: member function
Returns: Result
- return matrix row size
mat.row();
Kind: global function
Returns: XGMatrix
- xgboost matrix
Param | Type | Description |
---|---|---|
file | string |
input matrix file path |
const matFromFile = xgboost.restoreMatrix('test/data/xgmatrix.bin');
Kind: global function
Returns: XGMatrix
- xgboost matrix
Param | Type | Description |
---|---|---|
data | Float32Array |
input matrix |
indptr | Uint32Array |
pointer to col headers |
indices | Uint32Array |
findex |
n | Integer = 0 |
number of rows; when it's set to 0, then guess from data |
// [
// 1, 2, 3, 1,
// 0, 1, 2, 3,
// 0, 1, 1, 1,
// ]
const sparseCSC = xgboost.matrixFromCSC(
new Float32Array([1, 2, 1, 1, 3, 2, 1, 1, 3, 1]),
new Uint32Array([0, 1, 4, 7, 10]),
new Uint32Array([0, 0, 1, 2, 0, 1, 2, 0, 1, 2]),
0);
Kind: global function
Returns: XGMatrix
- xgboost matrix
Param | Type | Description |
---|---|---|
data | Float32Array |
input matrix |
indptr | Uint32Array |
pointer to row headers |
indices | Uint32Array |
findex |
n | Integer = 0 |
number of columns; when it's set to 0, then guess from data |
// [
// 1, 2, 3, 1,
// 0, 1, 2, 3,
// 0, 1, 1, 1,
// ]
const sparseCSR = xgboost.matrixFromCSR(
new Float32Array([1, 2, 3, 1, 1, 2, 3, 1, 1, 1]),
new Uint32Array([0, 4, 7, 10]),
new Uint32Array([0, 1, 2, 3, 1, 2, 3, 1, 2, 3]),
0);
Kind: object - Trained XGModel
Field | Type | Description |
---|---|---|
model | internal |
readonly property |
error | Error |
error status |
Kind: global function
Returns: XGModel
- xgboost model
Param | Type | Description |
---|---|---|
file | string |
model file path |
const model = xgboost.XGModel('test/data/iris.xg.model');
Kind: member function
Returns: Result
- prediction result with Float32Array
Param | Type | Description |
---|---|---|
matrix | XGMatrix |
input matrix |
mask | Integer = 0 |
options taken in prediction, possible values, 0:normal prediction, 1:output margin instead of transformed value, 2:output leaf index of trees instead of leaf value, note leaf index is unique per tree, 4:output feature contributions to individual predictions |
ntree | Integer = 0 |
limit number of trees used for prediction, this is only valid for boosted trees when the parameter is set to 0, we will use all the trees |
model.predict(mat);
Kind: member function
Param | Type | Description |
---|---|---|
matrix | XGMatrix |
input matrix |
mask | Integer = 0 |
options taken in prediction, possible values, 0:normal prediction, 1:output margin instead of transformed value, 2:output leaf index of trees instead of leaf value, note leaf index is unique per tree, 4:output feature contributions to individual predictions |
ntree | Integer = 0 |
limit number of trees used for prediction, this is only valid for boosted trees when the parameter is set to 0, we will use all the trees |
cb | Function |
callback function to accept error status and a Float32Array result |
model.predictAsync(mat, 0, 0, (err, res) => {
console.log(err);
console.log(res);
});
Kind: object
Field | Type | Description |
---|---|---|
value | Float32Array | number |
prediction result or method result |
error | Error |
error status |