Skip to content

Commit c6e0176

Browse files
authored
Create neural-network.js
1 parent b4ba87a commit c6e0176

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

routes/neural-network.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import express from 'express';
2+
import * as brain from 'brain.js';
3+
4+
const router = express.Router();
5+
const net = new brain.NeuralNetwork();
6+
7+
router.post('/train-neural-network', (req, res) => {
8+
const { trainingData } = req.body;
9+
net.train(trainingData);
10+
res.json({ trainingError: net.error });
11+
});
12+
13+
router.post('/make-prediction', (req, res) => {
14+
const { inputData } = req.body;
15+
const output = net.run(inputData);
16+
res.json({ output });
17+
});
18+
19+
export default router;

0 commit comments

Comments
 (0)