Support Vector Machine (SVM) library for nodejs

Overview

node-svm

Support Vector Machine (SVM) library for nodejs.

NPM Build Status Coverage Status

Support Vector Machines

Wikipedia :

Support vector machines are supervised learning models that analyze data and recognize patterns. A special property is that they simultaneously minimize the empirical classification error and maximize the geometric margin; hence they are also known as maximum margin classifiers. Wikipedia image

Installation

npm install --save node-svm

Quick start

If you are not familiar with SVM I highly recommend this guide.

Here's an example of using node-svm to approximate the XOR function :

var svm = require('node-svm');

var xor = [
    [[0, 0], 0],
    [[0, 1], 1],
    [[1, 0], 1],
    [[1, 1], 0]
];

// initialize a new predictor
var clf = new svm.CSVC();

clf.train(xor).done(function () {
    // predict things
    xor.forEach(function(ex){
        var prediction = clf.predictSync(ex[0]);
        console.log('%d XOR %d => %d', ex[0][0], ex[0][1], prediction);
    });
});

/******** CONSOLE ********
    0 XOR 0 => 0
    0 XOR 1 => 1
    1 XOR 0 => 1
    1 XOR 1 => 0
 */

More examples are available here.

Note: There's no reason to use SVM to figure out XOR BTW...

API

Classifiers

Possible classifiers are:

Classifier Type Params Initialization
C_SVC multi-class classifier c = new svm.CSVC(opts)
NU_SVC multi-class classifier nu = new svm.NuSVC(opts)
ONE_CLASS one-class classifier nu = new svm.OneClassSVM(opts)
EPSILON_SVR regression c, epsilon = new svm.EpsilonSVR(opts)
NU_SVR regression c, nu = new svm.NuSVR(opts)

Kernels

Possible kernels are:

Kernel Parameters
LINEAR No parameter
POLY degree, gamma, r
RBF gamma
SIGMOID gamma, r

Parameters and options

Possible parameters/options are:

Name Default value(s) Description
svmType C_SVC Used classifier
kernelType RBF Used kernel
c [0.01,0.125,0.5,1,2] Cost for C_SVC, EPSILON_SVR and NU_SVR. Can be a Number or an Array of numbers
nu [0.01,0.125,0.5,1] For NU_SVC, ONE_CLASS and NU_SVR. Can be a Number or an Array of numbers
epsilon [0.01,0.125,0.5,1] For EPSILON_SVR. Can be a Number or an Array of numbers
degree [2,3,4] For POLY kernel. Can be a Number or an Array of numbers
gamma [0.001,0.01,0.5] For POLY, RBF and SIGMOID kernels. Can be a Number or an Array of numbers
r [0.125,0.5,0,1] For POLY and SIGMOID kernels. Can be a Number or an Array of numbers
kFold 4 k parameter for k-fold cross validation. k must be >= 1. If k===1 then entire dataset is use for both testing and training.
normalize true Whether to use mean normalization during data pre-processing
reduce true Whether to use PCA to reduce dataset's dimensions during data pre-processing
retainedVariance 0.99 Define the acceptable impact on data integrity (require reduce to be true)
eps 1e-3 Tolerance of termination criterion
cacheSize 200 Cache size in MB.
shrinking true Whether to use the shrinking heuristics
probability false Whether to train a SVC or SVR model for probability estimates

The example below shows how to use them:

var svm = require('node-svm');

var clf = new svm.SVM({
    svmType: 'C_SVC',
    c: [0.03125, 0.125, 0.5, 2, 8], 
    
    // kernels parameters
    kernelType: 'RBF',  
    gamma: [0.03125, 0.125, 0.5, 2, 8],
    
    // training options
    kFold: 4,               
    normalize: true,        
    reduce: true,           
    retainedVariance: 0.99, 
    eps: 1e-3,              
    cacheSize: 200,               
    shrinking : true,     
    probability : false     
});

Notes :

  • You can override default values by creating a .nodesvmrc file (JSON) at the root of your project.
  • If at least one parameter has multiple values, node-svm will go through all possible combinations to see which one gives the best results (it performs grid-search to maximize f-score for classification and minimize Mean Squared Error for regression).

##Training

SVMs can be trained using svm#train(dataset) method.

Pseudo code :

var clf = new svm.SVM(options);

clf
.train(dataset)
.progress(function(rate){
    // ...
})
.spread(function(trainedModel, trainingReport){
    // ...
});

Notes :

  • trainedModel can be used to restore the predictor later (see this example for more information).
  • trainingReport contains information about predictor's accuracy (such as MSE, precison, recall, fscore, retained variance etc.)

Prediction

Once trained, you can use the classifier object to predict values for new inputs. You can do so :

  • Synchronously using clf#predictSync(inputs)
  • Asynchronously using clf#predict(inputs).then(function(predicted){ ... });

If you enabled probabilities during initialization you can also predict probabilities for each class :

  • Synchronously using clf#predictProbabilitiesSync(inputs).
  • Asynchronously using clf#predictProbabilities(inputs).then(function(probabilities){ ... }).

Note : inputs must be a 1d array of numbers

Model evaluation

Once the predictor is trained it can be evaluated against a test set.

Pseudo code :

var svm = require('node-svm');
var clf = new svm.SVM(options);
 
svm.read(trainFile)
.then(function(dataset){
    return clf.train(dataset);
})
.then(function(trainedModel, trainingReport){
     return svm.read(testFile);
})
.then(function(testset){
    return clf.evaluate(testset);
})
.done(function(report){
    console.log(report);
});

CLI

node-svm comes with a build-in Command Line Interpreter.

To use it you have to install node-svm globally using npm install -g node-svm.

See $ node-svm -h for complete command line reference.

help

$ node-svm help [<command>]

Display help information about node-svm

train

$ node-svm train <dataset file> [<where to save the prediction model>] [<options>]

Train a new model with given data set

Note: use $ node-svm train -i to set parameters values dynamically.

evaluate

$ node-svm evaluate <model file> <testset file> [<options>]

Evaluate model's accuracy against a test set

How it work

node-svm uses the official libsvm C++ library, version 3.20.

For more information see also :

Contributions

Feel free to fork and improve/enhance node-svm in any way your want.

If you feel that the community will benefit from your changes, please send a pull request :

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add documentation if necessary.
  • Add tests for it. This is important so I don't break it in a future version unintentionally (run grunt or npm test).
  • Send a pull request to the develop branch.

#FAQ ###Segmentation fault Q : Node returns 'segmentation fault' error during training. What's going on?

A1 : Your dataset is empty or its format is incorrect.

A2 : Your dataset is too big.

###Difference between nu-SVC and C-SVC Q : What is the difference between nu-SVC and C-SVC?

A : Answer here

###Other questions

License

MIT

githalytics.com alpha

Comments
  • Segfault for large dataset

    Segfault for large dataset

    I'm getting a segmentation fault when attempting to train with a rather large dataset.

    I have extracted overfeat features from the mnist dataset. When I try to train on a subset of this data using your library, things work fine. If I manually stick the full dataset into a text file in the libsvm format and run the libsvm executables for training, it also works fine. However, if I try to train on the full dataset using your library, I get a segmentation fault.

    Any idea how I can help debug this and/or verify that I am doing things correctly?

    Just for reference, each overfeat feature has 4,096 dimensions and there are 60,000 of them for the full mnist training set.

    opened by Queuecumber 16
  • issue about predictProbabilitiesSync

    issue about predictProbabilitiesSync

    Here is the code:

    'use strict';
    
    var so = require('stringify-object');
    var svm = require('../lib');
    var _a = require('mout/array');
    var fileName = './examples/datasets/housing.ds';
    
    
    var clf = new svm.EpsilonSVR({
      gamma: [0.125, 0.5, 1],
      c: [8, 16, 32],
      epsilon: [0.001, 0.125, 0.5],
      normalize: true, // (default)
      reduce: true, // (default)
      retainedVariance: 0.995,
      kFold: 5,
      probability : true
    });
    
    
    svm.read(fileName)
        .then(function (dataset) {
            // train the svm with entire dataset
            return clf.train(dataset)
                .progress(function(progress){
                    console.log('training progress: %d%', Math.round(progress*100));
                })
                .spread(function (model, report) {
                    console.log('SVM trained. \nReport :\n%s', so(report));
                    return dataset;
                });
        })
        .then(function (dataset) {
            // randomly pick m values and display predictions
            _a.pick(dataset, 5).forEach(function (ex, i) {
                var prediction = clf.predictProbabilitiesSync(ex[0]);
                console.log(' { #%d, expected: %d, predicted: %d}',i+1, ex[1], prediction);
                console.log(prediction);
            });
        })
        .fail(function (err) {
            throw err;
        })
        .done(function () {
            console.log('done.');
        });
    

    when I run, I got the fault.

    [1]    16488 segmentation fault  node examples/regression-with-PCA-example.js
    

    node version: v4.4.3 Please help.

    opened by yjhjstz 8
  • unable to predict from load previous model

    unable to predict from load previous model

    Hello, I train a data set and store it into other folder. (in index.js) After that, I create a file called predict.js, main code is like:

    var persistedModel = JSON.parse(fs.readFileSync('./model/poker_sim_test.json')); var clf = new svm.NuSVC({ model: persistedModel }); var prediction = clf.predict(guess);

    when I run it I face a problem that:

    assert.js:89 throw new assert.AssertionError({ ^ AssertionError: false == true at NuSVC.SVM.predict (/Users/ives/Downloads/SVM_PokerHand/node_modules/node-svm/lib/core/svm.js:147:5)

    How can I fix problems.

    Thanks!!

    opened by BoChengHuang 8
  • Node6 support

    Node6 support

    Hi NicolasPanel

    When updating to Node6.0, a huge amount of error is thrown:

    Also please upgrade graceful-fs to ^4.0.0 to suppress the depreciation warnings.

    Security context: 0x1287ef1c9e59 #0# 1: .node [module.js:568] [pc=0x3d9744c377c4](this=0x1902f98d9431 <an Object with map 0x335eb18161>#1#,module=0x3360d238dc61 <a Module with map 0x335ebb2001>#2#,filename=0x3360d238dbf9 <String[73]: SampleProj/node_modules/node-svm/build/Release/addon.node) 2: load [module.js:458] [pc=0x3d9744a396f2](this=0x3360d238dc61 <a Module with map 0x335ebb2001>#2#,filename=0x3360d238dbf9 <String[73]: SampleProj/node_modules/node-svm/build/Release/addon.node) 3: tryModuleLoad(aka tryModuleLoad) [module.js:417] [pc=0x3d9744a3921d](this=0x1287ef104189 ,module=0x3360d238dc61 <a Module with map 0x335ebb2001>#2#,filename=0x3360d238dbf9 <String[73]: SampleProj/node_modules/node-svm/build/Release/addon.node) 4: load [module.js:409] [pc=0x3d9744a34e02] (this=0x1902f98d9559 <JS Function Module (SharedFunctionInfo 0x1902f9825909)>#3# 1: v8::Template::Set(v8::Localv8::Name, v8::Localv8::Data, v8::PropertyAttribute) 2: NodeSvm::Init(v8::Localv8::Object) 3: node::DLOpen(v8::FunctionCallbackInfov8::Value const&) 4: v8::internal::FunctionCallbackArguments::Call(void ()(v8::FunctionCallbackInfov8::Value const&)) 5: v8::internal::MaybeHandlev8::internal::Object v8::internal::(anonymous namespace)::HandleApiCallHelper(v8::internal::Isolate_, v8::internal::(anonymous namespace)::BuiltinArguments<(v8::internal::BuiltinExtraArguments)1>) 6: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object*, v8::internal::Isolate) 7: 0x3d974490961b (node) v8::ObjectTemplate::Set() with non-primitive values is deprecated (node) and will stop working in the next major release.

    enhancement 
    opened by wenq1 6
  • Predictions always 0

    Predictions always 0

    Hi,

    First of all, big fan of the module! It's really simple, customizable and is quite fast, compared to other SVM implementations. However, I'm having problems with the dataset I currently use (input.txt).

    The code I am currently using to create and train the SVM is:

    // Create SVM
    var clf = new svm.SVM({
        type: 'EPSILON_SVR',
        kernel: 'POLY',
        gamma: 0.25,
        c: 1, 
        normalize: false,
        reduce: false,
        kFold: 1
    });
    
    // Train SVM
    console.log("Training...");
    clf.train(svmData).done(function () {
        // Predict
        console.log("Predicting...");
        svmData.forEach(function(ex){
            var prediction = clf.predictSync(ex[0]);
            console.log('%d => %d', ex[1], prediction);
        });
    });
    

    No matter what variation of SVM options I try, the prediction I receive is always 0. Could the problem be that my data is to small (I pre-normalize my data between -1 and 1)?

    Kind regards!

    opened by csysmans 6
  • Error: Module version mismatch.

    Error: Module version mismatch.

    I tried this module on Electron(v1.4.0). I got the error as blow.

    2016-10-31 20 07 01

    Also, I tried electron-rebuild script(./node_modules/.bin/electron-rebuild). However, I got the same error with running Electron. I would like to know the appropriate Electron version.

    opened by mimorisuzuko 5
  • Issue with installing node-svm

    Issue with installing node-svm

    I get this error in the log when installing:

    15369 verbose lifecycle [email protected]~install: unsafe-perm in lifecycle false 15370 verbose lifecycle [email protected]~install: PATH: /root/.nvm/versions/node/v5.8.0/lib/node_modules/npm/bin/node-gyp-bin:/root/.nvm/versions/node/v5.8.0/lib/node_modules/node-svm/node_modules/.bin:/root/.nvm/versions/node/v5.8.0/lib/node_modules/.bin:/root/.nvm/versions/node/v5.8.0/bin:/root/.nvm/versions/node/v5.8.0/bin:/opt/mono/bin:/usr/local/rvm/gems/ruby-2.3.0/bin:/usr/local/rvm/gems/ruby-2.3.0@global/bin:/usr/local/rvm/rubies/ruby-2.3.0/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/rvm/bin:/root/bin 15371 verbose lifecycle [email protected]~install: CWD: /root/.nvm/versions/node/v5.8.0/lib/node_modules/node-svm 15372 silly lifecycle [email protected]~install: Args: [ '-c', 'node-gyp rebuild' ] 15373 silly lifecycle [email protected]~install: Returned: code: 1 signal: null 15374 info lifecycle [email protected]~install: Failed to exec install script 15375 verbose unlock done using /root/.npm/_locks/staging-99687042021890b5.lock for /root/.nvm/versions/node/v5.8.0/lib/node_modules/.staging 15376 silly rollbackFailedOptional Starting 15377 silly rollbackFailedOptional Finishing 15378 silly runTopLevelLifecycles Starting 15379 silly runTopLevelLifecycles Finishing 15380 silly install printInstalled 15381 verbose stack Error: [email protected] install: node-gyp rebuild 15381 verbose stack Exit status 1 15381 verbose stack at EventEmitter. (/root/.nvm/versions/node/v5.8.0/lib/node_modules/npm/lib/utils/lifecycle.js:239:16) 15381 verbose stack at emitTwo (events.js:100:13) 15381 verbose stack at EventEmitter.emit (events.js:185:7) 15381 verbose stack at ChildProcess. (/root/.nvm/versions/node/v5.8.0/lib/node_modules/npm/lib/utils/spawn.js:24:14) 15381 verbose stack at emitTwo (events.js:100:13) 15381 verbose stack at ChildProcess.emit (events.js:185:7) 15381 verbose stack at maybeClose (internal/child_process.js:850:16) 15381 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5) 15382 verbose pkgid [email protected] 15383 verbose cwd /root/studentproject/gotjs/JS16_ProjectB_Group6 15384 error Linux 2.6.32-042stab111.12 15385 error argv "/root/.nvm/versions/node/v5.8.0/bin/node" "/root/.nvm/versions/node/v5.8.0/bin/npm" "install" "-g" "node-svm" 15386 error node v5.8.0 15387 error npm v3.8.1 15388 error code ELIFECYCLE 15389 error [email protected] install: node-gyp rebuild 15389 error Exit status 1 15390 error Failed at the [email protected] install script 'node-gyp rebuild'. 15390 error Make sure you have the latest version of node.js and npm installed. 15390 error If you do, this is most likely a problem with the node-svm package, 15390 error not with npm itself. 15390 error Tell the author that this fails on your system: 15390 error node-gyp rebuild 15390 error You can get information on how to open an issue for this project with: 15390 error npm bugs node-svm 15390 error Or if that isn't available, you can get their info via: 15390 error npm owner ls node-svm 15390 error There is likely additional logging output above. 15391 verbose exit [ 1, true ]

    opened by Hack3l 5
  • No convergence

    No convergence

    Hello.

    I am getting this error node_modules/numeric/numeric-1.2.6.js:4340 throw 'Error: no convergence.'

    I passed this data https://raw.githubusercontent.com/mailgun/talon/master/talon/signature/data/train.data where the last position is the expected outcome.

    This is the code that throws the error.

      fs.readFile('traineddata.txt', 'utf8', function(err, content){
        var train_data = [];
        S(content.trim()).lines().forEach(function(line){
          var spllited_line = line.split(',');
          supervisory_signal = spllited_line[spllited_line.length - 1];
          var vector = [];
          for (i = 0; i < spllited_line.length -1; i++) {
            vector.push(spllited_line[i]);
          }
          train_data.push([vector, supervisory_signal]);
        });
          var clf = new svm.SVM();
         clf.train(train_data).done(function () {
        var prediction = clf.predictSync(input);
      });
      });
    

    Any advice about how can I fix it?

    question 
    opened by ricardopolo 5
  • ld: library not found for -lgcc_s.10.5 error when installing

    ld: library not found for -lgcc_s.10.5 error when installing

    npm install node-svm --save fails with error ld: library not found for -lgcc_s.10.5. Any idea? - > [email protected] install /Users/tuananh/hq_src/fraud-fight/node_modules/node-svm > node-gyp rebuild

          CXX(target) Release/obj.target/addon/src/libsvm/svm.o
          CXX(target) Release/obj.target/addon/src/addon.o
          CXX(target) Release/obj.target/addon/src/node-svm/node-svm.o
          SOLINK_MODULE(target) Release/addon.node
        ld: library not found for -lgcc_s.10.5
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
        make: *** [Release/addon.node] Error 1
        gyp ERR! build error
        gyp ERR! stack Error: `make` failed with exit code: 2
        gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
        gyp ERR! stack     at emitTwo (events.js:87:13)
        gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
        gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
        gyp ERR! System Darwin 15.0.0
        gyp ERR! command "/usr/local/bin/iojs" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
        gyp ERR! cwd /Users/tuananh/hq_src/fraud-fight/node_modules/node-svm
        gyp ERR! node -v v2.4.0
        gyp ERR! node-gyp -v v2.0.1
        gyp ERR! not ok
        npm ERR! Darwin 15.0.0
        npm ERR! argv "/usr/local/bin/iojs" "/usr/local/bin/npm" "install" "node-svm" "--save"
        npm ERR! node v2.4.0
        npm ERR! npm  v2.13.0
        npm ERR! code ELIFECYCLE
    
        npm ERR! [email protected] install: `node-gyp rebuild`
        npm ERR! Exit status 1
        npm ERR!
        npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
        npm ERR! This is most likely a problem with the node-svm package,
        npm ERR! not with npm itself.
        npm ERR! Tell the author that this fails on your system:
        npm ERR!     node-gyp rebuild
        npm ERR! You can get their info via:
        npm ERR!     npm owner ls node-svm
        npm ERR! There is likely additional logging output above.
    
        npm ERR! Please include the following file with any support request:
        npm ERR!     /Users/tuananh/hq_src/fraud-fight/npm-debug.log
    
    opened by tuananh 5
  • Can't install on windows10

    Can't install on windows10

    If I try to install on windows 10, it has error.

    $ npm i node-svm
    npm WARN deprecated [email protected]: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
    
    > [email protected] install C:\Users\hoya1\hWorkspace\AI_Playground\MNIST_React\node_modules\node-svm
    > node-gyp rebuild
    
    
    C:\Users\hoya1\hWorkspace\AI_Playground\MNIST_React\node_modules\node-svm>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
    Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
      svm.cpp
      addon.cc
      node-svm.cc
      win_delay_load_hook.cc
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm/node-svm.h(88): warning C4244: '=': conversion f rom 'int64_t' to 'int', possible loss of data (compiling source file ..\src\addon.cc) [C:\Users\hoya1\hWorkspace\AI_Playground\MNIST_Re act\node_modules\node-svm\build\addon.vcxproj]
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm/node-svm.h(125): warning C4244: '=': conversion
    from 'int64_t' to 'int', possible loss of data (compiling source file ..\src\addon.cc) [C:\Users\hoya1\hWorkspace\AI_Playground\MNIST_R eact\node_modules\node-svm\build\addon.vcxproj]
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm/node-svm.h(137): warning C4244: '=': conversion
    from 'int64_t' to 'int', possible loss of data (compiling source file ..\src\addon.cc) [C:\Users\hoya1\hWorkspace\AI_Playground\MNIST_R eact\node_modules\node-svm\build\addon.vcxproj]
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm/node-svm.h(212): warning C4244: '=': conversion
    from 'int64_t' to 'int', possible loss of data (compiling source file ..\src\addon.cc) [C:\Users\hoya1\hWorkspace\AI_Playground\MNIST_R eact\node_modules\node-svm\build\addon.vcxproj]
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm/node-svm.h(216): warning C4244: '=': conversion
    from 'int64_t' to 'int', possible loss of data (compiling source file ..\src\addon.cc) [C:\Users\hoya1\hWorkspace\AI_Playground\MNIST_R eact\node_modules\node-svm\build\addon.vcxproj]
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm/node-svm.h(243): warning C4244: '=': conversion
    from 'int64_t' to 'int', possible loss of data (compiling source file ..\src\addon.cc) [C:\Users\hoya1\hWorkspace\AI_Playground\MNIST_R eact\node_modules\node-svm\build\addon.vcxproj]
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm/node-svm.h(256): warning C4244: '=': conversion
    from 'int64_t' to 'int', possible loss of data (compiling source file ..\src\addon.cc) [C:\Users\hoya1\hWorkspace\AI_Playground\MNIST_R eact\node_modules\node-svm\build\addon.vcxproj]
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm\node-svm.h(88): warning C4244: '=': conversion f rom 'int64_t' to 'int', possible loss of data (compiling source file ..\src\node-svm\node-svm.cc) [C:\Users\hoya1\hWorkspace\AI_Playgro und\MNIST_React\node_modules\node-svm\build\addon.vcxproj]
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm\node-svm.h(125): warning C4244: '=': conversion
    from 'int64_t' to 'int', possible loss of data (compiling source file ..\src\node-svm\node-svm.cc) [C:\Users\hoya1\hWorkspace\AI_Playgr ound\MNIST_React\node_modules\node-svm\build\addon.vcxproj]
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm\node-svm.h(137): warning C4244: '=': conversion
    from 'int64_t' to 'int', possible loss of data (compiling source file ..\src\node-svm\node-svm.cc) [C:\Users\hoya1\hWorkspace\AI_Playgr ound\MNIST_React\node_modules\node-svm\build\addon.vcxproj]
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm\node-svm.h(212): warning C4244: '=': conversion
    from 'int64_t' to 'int', possible loss of data (compiling source file ..\src\node-svm\node-svm.cc) [C:\Users\hoya1\hWorkspace\AI_Playgr ound\MNIST_React\node_modules\node-svm\build\addon.vcxproj]
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm\node-svm.h(216): warning C4244: '=': conversion
    from 'int64_t' to 'int', possible loss of data (compiling source file ..\src\node-svm\node-svm.cc) [C:\Users\hoya1\hWorkspace\AI_Playgr ound\MNIST_React\node_modules\node-svm\build\addon.vcxproj]
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm\node-svm.h(243): warning C4244: '=': conversion
    from 'int64_t' to 'int', possible loss of data (compiling source file ..\src\node-svm\node-svm.cc) [C:\Users\hoya1\hWorkspace\AI_Playgr ound\MNIST_React\node_modules\node-svm\build\addon.vcxproj]
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm\node-svm.h(256): warning C4244: '=': conversion
    from 'int64_t' to 'int', possible loss of data (compiling source file ..\src\node-svm\node-svm.cc) [C:\Users\hoya1\hWorkspace\AI_Playgr ound\MNIST_React\node_modules\node-svm\build\addon.vcxproj]
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm\training-worker.h(38): warning C4996: 'Nan::Call back::Call': was declared deprecated (compiling source file ..\src\node-svm\node-svm.cc) [C:\Users\hoya1\hWorkspace\AI_Playground\MNIST _React\node_modules\node-svm\build\addon.vcxproj]
      C:\Users\hoya1\hWorkspace\AI_Playground\MNIST_React\node_modules\nan\nan.h(1618): note: see declaration of 'Nan::Callback::Call' (com
      piling source file ..\src\node-svm\node-svm.cc)
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm\prediction-worker.h(36): warning C4996: 'Nan::Ca llback::Call': was declared deprecated (compiling source file ..\src\node-svm\node-svm.cc) [C:\Users\hoya1\hWorkspace\AI_Playground\MNI ST_React\node_modules\node-svm\build\addon.vcxproj]
      C:\Users\hoya1\hWorkspace\AI_Playground\MNIST_React\node_modules\nan\nan.h(1618): note: see declaration of 'Nan::Callback::Call' (com
      piling source file ..\src\node-svm\node-svm.cc)
    c:\users\hoya1\hworkspace\ai_playground\mnist_react\node_modules\node-svm\src\node-svm\probability-prediction-worker.h(46): warning C49 96: 'Nan::Callback::Call': was declared deprecated (compiling source file ..\src\node-svm\node-svm.cc) [C:\Users\hoya1\hWorkspace\AI_Pl ayground\MNIST_React\node_modules\node-svm\build\addon.vcxproj]
      C:\Users\hoya1\hWorkspace\AI_Playground\MNIST_React\node_modules\nan\nan.h(1618): note: see declaration of 'Nan::Callback::Call' (com
      piling source file ..\src\node-svm\node-svm.cc)
    ..\src\node-svm\node-svm.cc(37): error C2661: 'v8::Function::NewInstance': no overloaded function takes 2 arguments [C:\Users\hoya1\hWo rkspace\AI_Playground\MNIST_React\node_modules\node-svm\build\addon.vcxproj]
    gyp ERR! build error
    gyp ERR! stack Error: `msbuild` failed with exit code: 1
    gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
    gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
    gyp ERR! System Windows_NT 10.0.17134
    gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
    gyp ERR! cwd C:\Users\hoya1\hWorkspace\AI_Playground\MNIST_React\node_modules\node-svm
    gyp ERR! node -v v10.3.0
    gyp ERR! node-gyp -v v3.6.2
    gyp ERR! not ok
    npm WARN [email protected] No description
    npm WARN [email protected] No repository field.
    
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! [email protected] install: `node-gyp rebuild`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the [email protected] install script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    

    Help me...

    Windows10 Major Minor Build Revision


    10 0 17134 0

    node v10.3.0 npm v6.1.0 node-gyp v3.8.0 (my installed version is different with messages) python v2.7.15 .NET v4.6.2

    opened by llHoYall 3
  • Limitation on amount of features

    Limitation on amount of features

    Hi,

    I'm having another problem. The SVM works great, but is there a limitation on the amount of features? I use the following input data: svmData.txt, I create the SVM like so:

    // Create SVM
    var clf = new svm.SVM({
        svmType: 'NU_SVR',
        kernel: 'RBF',
        normalize: true,
        reduce: false,
        kFold: 4,
        cacheSize: 1000
    });
    
    // Train SVM
    console.log("Training...");
    var lastPercentage = "0.0";
    clf.train(svmData)
    .progress(function(rate){
        var percentage = (Math.round(rate*1000)/10).toFixed(1);
        if(lastPercentage != percentage){
            console.log("Training...(" + percentage + "%)");
            lastPercentage = percentage;
        }
    })
    .done(function () {
        console.log("Training done...");
    });
    

    The execution of the program gets terminated abruptly at 99%. I receive no errors or warnings. When I modify the data by removing one of the features (11 features instead of 12), the execution works as expected.

    Kind regards

    opened by csysmans 3
  • node 12.13: error: too few arguments to function call, single argument 'context' was not specified

    node 12.13: error: too few arguments to function call, single argument 'context' was not specified

    I'm installing with

    $ node --version
    v12.13.0
    $ npm --version
    6.13.1
    

    npm complains that

    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:256:59: error: too few arguments to function call, single argument 'context' was not specified
    

    full logging

    > [email protected] install /Users/loretoparisi/Documents/Projects/node-sdk/node_modules/node-svm
    > node-gyp rebuild
    
      CXX(target) Release/obj.target/addon/src/libsvm/svm.o
      CXX(target) Release/obj.target/addon/src/addon.o
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:88:96: error: too few arguments to function call, single argument 'context' was not specified
                svm_params->svm_type = Nan::Get(obj, svm_type_name).ToLocalChecked()->IntegerValue();
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2609:3: note: 'IntegerValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:101:84: error: too few arguments to function call, single argument 'context' was not specified
                    svm_params->C = Nan::Get(obj, str_c).ToLocalChecked()->NumberValue();
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2608:3: note: 'NumberValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:110:86: error: too few arguments to function call, single argument 'context' was not specified
                    svm_params->nu = Nan::Get(obj, str_nu).ToLocalChecked()->NumberValue();
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2608:3: note: 'NumberValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:118:90: error: too few arguments to function call, single argument 'context' was not specified
                    svm_params->p = Nan::Get(obj, str_epsilon).ToLocalChecked()->NumberValue();
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2608:3: note: 'NumberValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:125:101: error: too few arguments to function call, single argument 'context' was not specified
                svm_params->kernel_type = Nan::Get(obj, str_kernel_type).ToLocalChecked()->IntegerValue();
                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2609:3: note: 'IntegerValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:137:95: error: too few arguments to function call, single argument 'context' was not specified
                    svm_params->degree = Nan::Get(obj, str_degree).ToLocalChecked()->IntegerValue();
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2609:3: note: 'IntegerValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:147:92: error: too few arguments to function call, single argument 'context' was not specified
                    svm_params->gamma = Nan::Get(obj, str_gamma).ToLocalChecked()->NumberValue();
                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2608:3: note: 'NumberValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:156:88: error: too few arguments to function call, single argument 'context' was not specified
                    svm_params->coef0 = Nan::Get(obj, str_r).ToLocalChecked()->NumberValue();
                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2608:3: note: 'NumberValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:162:77: error: too few arguments to function call, single argument 'context' was not specified
                    Nan::Get(obj, str_cache_size).ToLocalChecked()->NumberValue() :
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2608:3: note: 'NumberValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:168:70: error: too few arguments to function call, single argument 'context' was not specified
                    Nan::Get(obj, str_eps).ToLocalChecked()->NumberValue() :
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2608:3: note: 'NumberValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:175:65: error: no matching member function for call to 'BooleanValue'
                    !Nan::Get(obj, str_shrinking).ToLocalChecked()->BooleanValue() ? 0 : 1;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2603:8: note: candidate function not viable: requires single argument 'isolate', but no arguments
          were provided
      bool BooleanValue(Isolate* isolate) const;
           ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2606:51: note: candidate function not viable: requires single argument 'context', but no
          arguments were provided
                    V8_WARN_UNUSED_RESULT Maybe<bool> BooleanValue(
                                                      ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:181:66: error: no matching member function for call to 'BooleanValue'
                    Nan::Get(obj, str_probability).ToLocalChecked()->BooleanValue() ? 1 : 0;
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2603:8: note: candidate function not viable: requires single argument 'isolate', but no arguments
          were provided
      bool BooleanValue(Isolate* isolate) const;
           ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2606:51: note: candidate function not viable: requires single argument 'context', but no
          arguments were provided
                    V8_WARN_UNUSED_RESULT Maybe<bool> BooleanValue(
                                                      ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:196:71: error: no matching member function for call to 'ToObject'
                setParameters(Nan::Get(obj, str_params).ToLocalChecked()->ToObject());
                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2576:44: note: candidate function not viable: requires single argument 'context', but no
          arguments were provided
      V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
                                               ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2590:31: note: candidate function not viable: requires single argument 'isolate', but no
          arguments were provided
                    Local<Object> ToObject(Isolate* isolate) const);
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:212:80: error: too few arguments to function call, single argument 'context' was not specified
                new_model->l = Nan::Get(obj, str_l).ToLocalChecked()->IntegerValue();
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2609:3: note: 'IntegerValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:216:94: error: too few arguments to function call, single argument 'context' was not specified
                new_model->nr_class = Nan::Get(obj, str_nr_class).ToLocalChecked()->IntegerValue();
                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2609:3: note: 'IntegerValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:228:41: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations]
                    Local<Value> elt = rho->Get(i);
                                            ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:3461:3: note: 'Get' has been explicitly marked deprecated here
      V8_DEPRECATED("Use maybe version", Local<Value> Get(uint32_t index));
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:311:29: note: expanded from macro 'V8_DEPRECATED'
      declarator __attribute__((deprecated(message)))
                                ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:230:54: error: too few arguments to function call, single argument 'context' was not specified
                    new_model->rho[i] = elt->NumberValue();
                                        ~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2608:3: note: 'NumberValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:241:48: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations]
                        Local<Value> elt = labels->Get(i);
                                                   ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:3461:3: note: 'Get' has been explicitly marked deprecated here
      V8_DEPRECATED("Use maybe version", Local<Value> Get(uint32_t index));
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:311:29: note: expanded from macro 'V8_DEPRECATED'
      declarator __attribute__((deprecated(message)))
                                ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:243:61: error: too few arguments to function call, single argument 'context' was not specified
                        new_model->label[i] = elt->IntegerValue();
                                              ~~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2609:3: note: 'IntegerValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:254:58: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations]
                        Local<Value> elt = nbSupportVectors->Get(i);
                                                             ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:3461:3: note: 'Get' has been explicitly marked deprecated here
      V8_DEPRECATED("Use maybe version", Local<Value> Get(uint32_t index));
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:311:29: note: expanded from macro 'V8_DEPRECATED'
      declarator __attribute__((deprecated(message)))
                                ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:256:59: error: too few arguments to function call, single argument 'context' was not specified
                        new_model->nSV[i] = elt->IntegerValue();
                                            ~~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2609:3: note: 'IntegerValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:268:47: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations]
                        Local<Value> elt = probA->Get(i);
                                                  ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:3461:3: note: 'Get' has been explicitly marked deprecated here
      V8_DEPRECATED("Use maybe version", Local<Value> Get(uint32_t index));
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:311:29: note: expanded from macro 'V8_DEPRECATED'
      declarator __attribute__((deprecated(message)))
                                ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:270:60: error: too few arguments to function call, single argument 'context' was not specified
                        new_model->probA[i] = elt->NumberValue();
                                              ~~~~~~~~~~~~~~~~ ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:2608:3: note: 'NumberValue' declared here
      V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
    #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                                  ^
    In file included from ../src/addon.cc:3:
    ../src/node-svm/node-svm.h:282:47: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations]
                        Local<Value> elt = probB->Get(i);
                                                  ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8.h:3461:3: note: 'Get' has been explicitly marked deprecated here
      V8_DEPRECATED("Use maybe version", Local<Value> Get(uint32_t index));
      ^
    /Users/loretoparisi/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:311:29: note: expanded from macro 'V8_DEPRECATED'
      declarator __attribute__((deprecated(message)))
                                ^
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    5 warnings and 20 errors generated.
    make: *** [Release/obj.target/addon/src/addon.o] Error 1
    gyp ERR! build error 
    gyp ERR! stack Error: `make` failed with exit code: 2
    gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
    gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
    gyp ERR! System Darwin 18.6.0
    gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /Users/loretoparisi/Documents/Projects/node-sdk/node_modules/node-svm
    gyp ERR! node -v v12.13.0
    gyp ERR! node-gyp -v v5.0.5
    gyp ERR! not ok 
    
    opened by loretoparisi 0
  • How do I save and load a model?

    How do I save and load a model?

    The github example does not help btw. I have trained a model using the RBF kernel and now I want to save it so I can use it in another file. How do I do so?

    opened by siddheshkrishnan1 1
  • How can I update an already trained machine learning model with only the new examples, without training the model over the whole dataset again?is it possible?

    How can I update an already trained machine learning model with only the new examples, without training the model over the whole dataset again?is it possible?

    First : I train with var xor = [ [[0, 0], 0], [[0, 1], 1],]; Then i save model When have new data I load and restore model And train it with new data
    var xor2=[ [[1, 0], 1], [[1, 1], 0] ] When i test with var test = [ [[0, 0], 0], [[0, 1], 1], [[1, 0], 1], [[1, 1], 0] ]; when result: 0 XOR 0 => 1 false 0 XOR 1 => 0 false 1 XOR 0 => 1 true 1 XOR 1 => 0 true

    opened by CaoThien96 1
  • npm audit report: critical vulnerability in dependendencies

    npm audit report: critical vulnerability in dependendencies

    Recently doing npm audit I have found this critical vulnerabilities in dependencies liketar, handlebars, uglify-js, etc. that has been patched already for release stated below. Could you please bump those packages to versions below?

    Thank you!

    ┌───────────────┬──────────────────────────────────────────────────────────────┐
    │ Critical      │ Symlink Arbitrary File Overwrite                             │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Package       │ tar                                                          │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Patched in    │ >=2.0.0                                                      │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Dependency of │ 973f04893cc6187d000700eeee953c325c0f7fd575e35e3aad013cb9a78… │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Path          │ 973f04893cc6187d000700eeee953c325c0f7fd575e35e3aad013cb9a78… │
    │               │ > node-svm > node-gyp > tar                                  │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ More info     │ https://nodesecurity.io/advisories/57  
    

    for handlebars

    ┌───────────────┬──────────────────────────────────────────────────────────────┐
    │ High          │ Cross-Site Scripting                                         │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Package       │ handlebars                                                   │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Patched in    │ >=4.0.0                                                      │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Dependency of │ 973f04893cc6187d000700eeee953c325c0f7fd575e35e3aad013cb9a78… │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Path          │ 973f04893cc6187d000700eeee953c325c0f7fd575e35e3aad013cb9a78… │
    │               │ > node-svm > handlebars                                      │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ More info     │ https://nodesecurity.io/advisories/61            
    

    and uglify-js

    │ Low           │ Incorrect Handling of Non-Boolean Comparisons During         │
    │               │ Minification                                                 │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Package       │ uglify-js                                                    │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Patched in    │ >= 2.4.24                                                    │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Dependency of │ 973f04893cc6187d000700eeee953c325c0f7fd575e35e3aad013cb9a78… │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Path          │ 973f04893cc6187d000700eeee953c325c0f7fd575e35e3aad013cb9a78… │
    │               │ > node-svm > handlebars > uglify-js                          │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ More info     │ https://nodesecurity.io/advisories/39 
    

    and inquirer>lodash

    Low           │ Prototype Pollution                                          │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Package       │ lodash                                                       │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Patched in    │ >=4.17.5                                                     │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Dependency of │ 973f04893cc6187d000700eeee953c325c0f7fd575e35e3aad013cb9a78… │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ Path          │ 973f04893cc6187d000700eeee953c325c0f7fd575e35e3aad013cb9a78… │
    │               │ > node-svm > inquirer > lodash                               │
    ├───────────────┼──────────────────────────────────────────────────────────────┤
    │ More info     │ https://nodesecurity.io/advisories/577    
    
    opened by loretoparisi 1
  • The predictSync function is giving the same values for any test case

    The predictSync function is giving the same values for any test case

    The Problem: I am getting the same predictions no matter what input data I am giving..

    Input Data: The input data files are attached as zip. testfat.zip

    I have ried with the fat dataset published in libsvm site. https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/regression/bodyfat I have used the last 19 records are test records and rest of them as train records. Below is the result. You can note that all the 19 records produced the same '1.05195' as the result.

    Code:

    var fs = require("fs");
    
    async function xor() {
        var trainDataString = fs.readFileSync('../src/assets/bp/trainfat.csv')+"";
        var testDataString = fs.readFileSync('../src/assets/bp/testfat.csv')+"";
        testNodeSVM(trainDataString.split('\n').splice(1),testDataString.split('\n').splice(1));
    }
    
    async function testNodeSVM(trainData,testData){
        var svm = require('node-svm');
         
        // initialize a new predictor 
        var fatSVM = new svm.EpsilonSVR({gamma:0.01,cost:1,epsilon:0.1});
    
        let nodeSVMFatArray = [];
    
        for(let i=0;i<trainData.length;i++){
            let line = trainData[i];
            let trainingRecord = line.split(",").map(data => parseFloat(data));
            if(trainingRecord.length === 15){
              let inputParams = trainingRecord.splice(1);
              nodeSVMFatArray.push([inputParams,trainingRecord[0]]);
            }
        }
        // console.log(nodeSVMSysArray);
        // console.log(testData);
        await fatSVM.train(nodeSVMFatArray);
        testData.forEach(element => {
            if(element.length > 0){
                // console.log(element);
                let dataArrayStr = element.split(",");
                let testDataArray = dataArrayStr.map(data => parseFloat(data));
                values = [];
                values.push(fatSVM.predictSync(testDataArray.splice(1)));
                console.log(values);
            }
        });
       
    }
    xor().then(() => console.log('done!'));
    

    Result:

    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    [ 1.05195 ]
    

    I have tested the same fat files on R also..Below are the commands and the final result..

    fatTest<-read.csv("C:\Code\WearableVitals\src/assets/bp/testfat.csv") fat<-read.csv("C:\Code\WearableVitals\src/assets/bp/trainfat.csv") fatFitRadialEsp<-svm(Fat~.,data=fat,type="eps-regression",kernel="radial") predFat<-predict(fatFitRadialEsp,fatTest) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1.042609 1.042513 1.053037 1.043323 1.031655 1.068895 1.033243 1.064847 1.026723 1.032486 1.036302 1.032156 1.064235 1.036778 1.069251 1.033492 1.034420 1.044378 1.038295

    Other trials:

    I have tried without any parameters and with various options and it has no effect.

    I also tried all the types of classifiers and regression types, with each of the type the prediction is different but it is the the same prediction for any input.

    Even of I give all 1s as the test input the prediction is still same.

    Please help me to solve this issue. I am stuck.

    opened by rguntha 0
Owner
Nicolas Panel
Nicolas Panel
machinelearn.js is a Machine Learning library written in Typescript

machinelearn.js is a Machine Learning library written in Typescript. It solves Machine Learning problems and teaches users how Machine Learning algorithms work.

machinelearn.js 522 Jan 2, 2023
Machine learning tools in JavaScript

ml.js - Machine learning tools in JavaScript Introduction This library is a compilation of the tools developed in the mljs organization. It is mainly

ml.js 2.3k Jan 1, 2023
Machine-learning for Node.js

Limdu.js Limdu is a machine-learning framework for Node.js. It supports multi-label classification, online learning, and real-time classification. The

Erel Segal-Halevi 1k Dec 16, 2022
Train and test machine learning models for your Arduino Nano 33 BLE Sense in the browser.

Tiny Motion Trainer Train and test IMU based TFLite models on the Web Overview Since 2009, coders have created thousands of experiments using Chrome,

Google Creative Lab 59 Nov 21, 2022
Visualizer for neural network, deep learning, and machine learning models

Netron is a viewer for neural network, deep learning and machine learning models. Netron supports ONNX, TensorFlow Lite, Caffe, Keras, Darknet, Paddle

Lutz Roeder 21k Jan 5, 2023
JavaScript Machine Learning Toolkit

The JavaScript Machine Learning Toolkit, or JSMLT, is an open source JavaScript library for education in machine learning.

JSMLT 25 Nov 23, 2022
Friendly machine learning for the web! 🤖

Read our ml5.js Code of Conduct and software licence here! This project is currently in development. Friendly machine learning for the web! ml5.js aim

ml5 5.9k Jan 2, 2023
Unsupervised machine learning with multivariate Gaussian mixture model which supports both offline data and real-time data stream.

Gaussian Mixture Model Unsupervised machine learning with multivariate Gaussian mixture model which supports both offline data and real-time data stre

Luka 26 Oct 7, 2022
Automated machine learning for analytics & production

auto_ml Automated machine learning for production and analytics Installation pip install auto_ml Getting started from auto_ml import Predictor from au

Preston Parry 1.6k Dec 26, 2022
Fork, customize and deploy your Candy Machine v2 super quickly

Candy Machine V2 Frontend This is a barebones implementation of Candy Machine V2 frontend, intended for users who want to quickly get started selling

AL 107 Oct 24, 2022
Run Keras models in the browser, with GPU support using WebGL

**This project is no longer active. Please check out TensorFlow.js.** The Keras.js demos still work but is no longer updated. Run Keras models in the

Leon Chen 4.9k Dec 29, 2022
JavaScript API for face detection and face recognition in the browser and nodejs with tensorflow.js

face-api.js JavaScript face recognition API for the browser and nodejs implemented on top of tensorflow.js core (tensorflow/tfjs-core) Click me for Li

Vincent Mühler 14.6k Jan 2, 2023
A neural network library built in JavaScript

A flexible neural network library for Node.js and the browser. Check out a live demo of a movie recommendation engine built with Mind. Features Vector

Steven Miller 1.5k Dec 31, 2022
architecture-free neural network library for node.js and the browser

Synaptic Important: Synaptic 2.x is in stage of discussion now! Feel free to participate Synaptic is a javascript neural network library for node.js a

Juan Cazala 6.9k Dec 27, 2022
A lightweight library for neural networks that runs anywhere

Synapses A lightweight library for neural networks that runs anywhere! Getting Started Why Sypapses? It's easy Add one dependency to your project. Wri

Dimos Michailidis 65 Nov 9, 2022
A JavaScript deep learning and reinforcement learning library.

neurojs is a JavaScript framework for deep learning in the browser. It mainly focuses on reinforcement learning, but can be used for any neural networ

Jan 4.4k Jan 4, 2023
A WebGL accelerated JavaScript library for training and deploying ML models.

TensorFlow.js TensorFlow.js is an open-source hardware-accelerated JavaScript library for training and deploying machine learning models. ⚠️ We recent

null 16.9k Jan 4, 2023
A library for prototyping realtime hand detection (bounding box), directly in the browser.

Handtrack.js View a live demo in your browser here. Handtrack.js is a library for prototyping realtime hand detection (bounding box), directly in the

Victor Dibia 2.7k Jan 3, 2023
A speech recognition library running in the browser thanks to a WebAssembly build of Vosk

A speech recognition library running in the browser thanks to a WebAssembly build of Vosk

Ciaran O'Reilly 207 Jan 3, 2023