Socket
Socket
Sign inDemoInstall

monkeylearn

Package Overview
Dependencies
4
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    monkeylearn

Official Node client for the MonkeyLearn API.


Version published
Weekly downloads
404
increased by124.44%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

monkeylearn-node

Official Node client for the MonkeyLearn API. Build and consume machine learning models for language processing from your Node apps.

Install

You can use npm to install the library:

npm install monkeylearn

Usage examples

Here are some examples of how to use the library in order to create and use classifiers:

var MonkeyLearn, ml, p, module_id, root_id, negative_id, positive_id, samples;

MonkeyLearn = require('monkeylearn');

// Use the API key from your account
ml = new MonkeyLearn('<YOUR API KEY HERE>');

// Create a new classifier
p = ml.classifiers.create('Test Classifier').then(function (res) {
    // Get the id of the new module    
    module_id = res.result.classifier.hashed_id
    
    // Get the classifier detail
    return ml.classifiers.detail(module_id);
}).then(function (res) {    
    // Get the id of the root node
    root_id = res.result.sandbox_categories[0].id
    
    // Create a negative category on the root node
    return ml.classifiers.categories.create(module_id, 'Negative', root_id);
}).then(function (res) {   
    // Get the id of the negative category
    negative_id = res.result.category.id
    
    // Create a positive category on the root node
    return ml.classifiers.categories.create(module_id, 'Positive', root_id);
}).then(function (res) {    
    // Get the id of the positive category
    positive_id = res.result.category.id
    
    // Now let's upload some samples
    samples = [['The movie was terrible, I hated it.', negative_id], ['I love this movie, I want to watch it again!', positive_id]];
    return ml.classifiers.uploadSamples(module_id, samples);
}).then(function (res) {    
    // Now let's train the module!
    return ml.classifiers.train(module_id);
}).then(function (res) {
    // Classify some texts
    return ml.classifiers.classify(module_id, ['I love the movie', 'I hate the movie'], true);
}).then(function (res) {    
    console.log(res.result);
});

You can also use the sdk with extractors and pipelines:

var MonkeyLearn = require('monkeylearn');
var ml = new MonkeyLearn('<YOUR API KEY HERE>');
var res = ml.extractors.extract('<Extractor ID>', ['Some text for the extractor.', 'Some more text']);
var res = ml.pipelines.run('<Pipeline ID>', {'input':[{'text': 'some text for the pipeline.'}]}, false);

Keywords

FAQs

Last updated on 21 Mar 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc