Skip to content

Neural network output values over 1? #341

@vorticalbox

Description

@vorticalbox

What is wrong?

after training on iris data https://archive.ics.uci.edu/ml/datasets/Iris/ output of one iris is massively higher than the others

How do we replicate the issue?

download the csv of data

const brain = require('brain.js');
const net = new brain.NeuralNetwork();
const fs = require('fs');

const data = fs.readFileSync('./iris.csv').toString();
const trainingData = data.split('\r\n').map((d) => {
    const [slength, swidth, plength, pwidth, flower] = d.split(',');
    return {
        input: {
            slength: slength / 10,
            swidth: swidth / 10,
            plength: plength / 10,
            pwidth: pwidth / 10,
        },
        output: {
            [flower]: 1,
        },
    };
});
const trainResults = net.train(trainingData);
console.log(trainResults);
const result = net.run({ 
    slength: 0.51,
    swidth: 0.35,
    plength: 0.13999999999999999,
    pwidth: 0.1 });

console.log(result);

How important is this (1-5)?

3

Expected behavior

{ 'Iris-setosa': 0.9973204731941223,
  'Iris-versicolor': 0.003389077726751566,
  'Iris-virginica': 2.462011443240403e-13 }

should be more like

{ 'Iris-setosa': 0.9973204731941223,
  'Iris-versicolor': 0.003389077726751566,
  'Iris-virginica': 0.003 }

Other Comments

training results

{ error: 0.008838672393814171, iterations: 20000 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions