I’m using node.js and express to run train an ai model and make predictions on new data.
I’m using ml.js for the model.
const express = require('express')
const rf = require('ml-random-forest');
const options = {
seed: 3,
maxFeatures: 0.9, //number of features
replacement: true,
nEstimators: 25 //number of trees
};
var RF = new rf.RandomForestClassifier(options);
....MODEL LOGIC
const predictedLabel = [[45, 29, "3:09:00", "01/04/2020"]]; //new data predict
let result = RF.predict(predictedLabel); //predict the new data
const app = express()
const port = 3000
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.get('/', (req, res, next) => {
res.send(result);
});
app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))
What I would like to do next is allow for the user to input in a form new data which would send to the predictedLabel
and output the result back to the user.
The form would be something like:
Value:
Amount:
Time:
Date:
which would send the data to the server.
I’m not sure exactly how to implement the client side, maybe a web socket or something? Any ideas would be great!
Thanks so much!!