Skip to content

Commit

Permalink
Neural Network - Machine Learning in JavaScript using Brain JS
Browse files Browse the repository at this point in the history
  • Loading branch information
Parathantl committed Sep 28, 2018
0 parents commit db3365b
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
40 changes: 40 additions & 0 deletions data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[
{
"input": "Inside Chi's nursery",
"output": "kardashian"
},
{
"input": "Why I dyed my hair pink",
"output": "kardashian"
},
{
"input": "Feeling Blue (wearing @kkwbeauty powder contour in medium & dark contour kit as eye shadow, & a new lip coming soon)",
"output": "kardashian"
},
{
"input": "The Classic Blossom Palette is SOLD OUT 🌸 Can’t wait to see all your looks with this! Sign up for restock updates: https://kkwbeauty.com/pages/signup )",
"output": "kardashian"
},
{
"input": "Awww this part of GABBANA makes me so sad 😢😢😢",
"output": "kardashian"
},


{
"input": "Dem Memo: FBI did not disclose who the clients were - the Clinton Campaign and the DNC. Wow!",
"output": "trump"
},
{
"input": "Thank you to the great men and women of the United States @SecretService for a job well done!",
"output": "trump"
},
{
"input": "Congressman Lee Zeldin is doing a fantastic job in D.C. Tough and smart, he loves our Country and will always be there to do the right thing. He has my Complete and Total Endorsement!",
"output": "trump"
},
{
"input": "China is actually placing propaganda ads in the Des Moines Register and other papers, made to look like news. That’s because we are beating them on Trade, opening markets, and the farmers will make a fortune when this is over!",
"output": "trump"
}
]
18 changes: 18 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const brain = require('brain.js');
const data = require('./data.json');

const network = new brain.recurrent.LSTM();

const trainingData = data.map(item => ({
input : item.input,
output : item.output
}));

network.train(trainingData,{
iterations : 100
});

const output = network.run("Jobless Claims fell to their lowest level in 49 years!");


console.log(`Person: ${output}`);
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Machine_Learning_in_JavaScript",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"brain.js": "^1.4.1"
}
}

0 comments on commit db3365b

Please sign in to comment.