wormbait v1.0.0
Wormbait
Wormbait is a simple knn-like algo to identify clickbait titles.
What's so special about it ? Wormbait is trained with 1040 Inc.com titles, because besides having great articles, they have some of the most clickbaity titles out there.
Why is it called wormbait ?
- 1) Click ==> worms
- 2) I built
fishingrod
)(http://npmjs.org/package/fishingrod) so obviously you need bait and worms
CLI
Wormbait is bunbled with a very small CLI tool
Installation
npm install -g wormbait
Usage
$ wormbait "this is not clickbait" "deep fried chicken" Learning from 1040 sentences Finished Learning! YES: "this is not clickbait" is PROBABLY clickbait with a score of 0.2942307692307693 NO: "deep fried chicken" is PROBABLY NOT clickbait with a score of 0.013565
API
Wormbait is a class
you can instanciate and provides some utility methods
Installation
npm install wormbait
tl;dr
const Wormbait = require('wormbait');
let inc = new Wormbait();
inc.learn();
let is_bait = inc.predict('This is some title of some article');
if(is_bait){
console.log('CLICKBAIT!!!')
}
Methods
getDataSet()
Returns the data set bundled with wormbait, with over 1000 Inc.com article titles.
DataSet
is simply an array filled with strings.
learn(data)
data
: Array with strings
Learns from the provided data. Simple example:
let data = w.getDataSet().splice(0, 800);
w.learn(data);
predict(title)
title
: String
Returns boolean predicting if clickbait or not depending on data learned from.
test(data)
data
: Array with LearnObject
LearnObject
:
{
title: 'This is some title to test against',
clickbait: true
}
Tests the learning algorithm, and returns predictions and statistics
{
predictions: [{
score: 0.005,
val: true,
correct: false
}],
ratio: 0.8,
correct: 80,
wrong: 20
}
__predict(title)
Returns the associated score (0 to 1)
setThreshold(t)
Sets the minimum threshold to identify title as clickbait. Default is 0.2
6 years ago