[Javascript] Classify text into categories with machine learning in Natural
In this lesson, we will learn how to train a Naive Bayes classifier or a Logistic Regression classifier - basic machine learning algorithms - in order to classify text into categories.
var natural = require('natural');
var classifier = new natural.BayesClassifier();
var trainingData = [
{text: 'RE: Canadian drugs now on sale', label: 'spam'},
{text: 'Earn more from home', label: 'spam'},
{text: 'Information now available!!!', label: 'spam'},
{text: 'Earn easy cash', label: 'spam'},
{text: 'Your business trip is confirmed for Monday the 4th', label: 'notspam'},
{text: 'Project planning - next steps', label: 'notspam'},
{text:'Birthday party next weekend', label: 'notspam'},
{text: 'Drinks on Monday?', label: 'notspam'}
];
var testData = [
{text: 'Drugs for cheap', label: 'spam'},
{text: 'Next deadline due Monday', label: 'notspam'},
{text: 'Meet me at home?', label: 'notspam'},
{text: 'Hang out with someone near you', label: 'spam'}
];
trainingData.forEach(function(item){
classifier.addDocument(item.text, item.label);
});
classifier.train();
testData.forEach(function(item){
var labelGuess = classifier.classify(item.text);
console.log("\n");
console.log(item.text);
console.log("Label:", labelGuess);
console.log(classifier.getClassifications(item.text));
});
[Javascript] Classify text into categories with machine learning in Natural的更多相关文章
- [Javascript] Classify JSON text data with machine learning in Natural
In this lesson, we will learn how to train a Naive Bayes classifier and a Logistic Regression classi ...
- A Gentle Guide to Machine Learning
A Gentle Guide to Machine Learning Machine Learning is a subfield within Artificial Intelligence tha ...
- How do I learn machine learning?
https://www.quora.com/How-do-I-learn-machine-learning-1?redirected_qid=6578644 How Can I Learn X? ...
- 100 Most Popular Machine Learning Video Talks
100 Most Popular Machine Learning Video Talks 26971 views, 1:00:45, Gaussian Process Basics, David ...
- [C5] Andrew Ng - Structuring Machine Learning Projects
About this Course You will learn how to build a successful machine learning project. If you aspire t ...
- Machine Learning for Developers
Machine Learning for Developers Most developers these days have heard of machine learning, but when ...
- What is machine learning?
What is machine learning? One area of technology that is helping improve the services that we use on ...
- Machine Learning and Data Mining(机器学习与数据挖掘)
Problems[show] Classification Clustering Regression Anomaly detection Association rules Reinforcemen ...
- [C2P2] Andrew Ng - Machine Learning
##Linear Regression with One Variable Linear regression predicts a real-valued output based on an in ...
随机推荐
- [BZOJ5305][HAOI2018]苹果树 组合数学
链接 小 C 在自己家的花园里种了一棵苹果树, 树上每个结点都有恰好两个分支. 经过细心的观察, 小 C 发现每一天这棵树都会生长出一个新的结点. 第一天的时候, 果树会长出一个根结点, 以后每一天, ...
- Spring MVC 入门
1.准备开发环境和运行环境: ☆开发工具:eclipse ☆运行环境:tomcat6.0.20 ☆工程:动态web工程(springmvc-chapter2) ☆spring框架下载: spring- ...
- js创建dom操作select
document.getElementById("column-left").getElementsByTagName("header")[0].onclick ...
- Vue或React多页应用脚手架
https://github.com/zhujiasheng/vue-multipage https://github.com/MeCKodo/vue-multipage
- 学习参考《零基础入门学习Python》电子书PDF+笔记+课后题及答案
国内编写的关于python入门的书,初学者可以看看. 参考: <零基础入门学习Python>电子书PDF+笔记+课后题及答案 Python3入门必备; 小甲鱼手把手教授Python; 包含 ...
- hdparm
https://www.douban.com/note/244813504/ http://blog.sina.com.cn/s/blog_413d250e0101jtr7.html http://m ...
- XCode6报数组越界错误的问题
今天碰到一个非常奇葩的问题, 调试了半天: 错误:"index 0 beyond bounds for empty array", 意思就是说数据源数组为nil, 所以你调用直接 ...
- ORA-00922: 选项缺失或无效
1.错误描写叙述 SQL> create table info_stu from select t.stu_id,t.stu_name,t.stu_age from info t; create ...
- android5.x加入sim1,sim2标识
1,mobile_signal_group.xml ..... <FrameLayout android:id="@+id/mobile_combo" android:la ...
- [C/C++标准库]_[0基础]_[使用fstream合并文本文件]
场景: 1. 就是合并文本文件,而且从第2个文件起不要合并第一行. 2. 多加了一个功能,就是支持2个以上的文件合并. 3. 问题: http://ask.csdn.net/questions/192 ...