'Numerical input, categorial output in brain.js

Is there a way to use brain.js to give an array of numbers, and get a categorial output (preferably accompanied with a reliability value)

Suppose this code

const brain = require('brain.js');

const network = new brain.NeuralNetwork(); //IS THIS THE ONE?

network.train([
// [word count, characters, special characters]   =>  [rating]
        
  { input: [0.10, 0.20, 0.40], output: ['hard'] }, // 1 input
  { input: [0.10, 0.50, 0.50], output: ['intermediate'] }, // 2 input
  { input: [0.10, 0.40, 0.60], output: ['simple'] }, // 3 input
  { input: [0.10, 0.40, 0.50], output: ['hard'] }, // 4 input
  { input: [0.10, 0.30, 0.30], output: ['simple'] }, // 5 input
  { input: [0.10, 0.70, 0.30], output: ['hard'] }  // 6 input
]);

//Evaluate to get a difficulty rating
const output = network.run([0.10, 0.50, 0.60]);

console.log(output);

The desired output would be one of the three ratings with a reliability value (perhaps a percentage of certainty).



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source