train() {
        let output = new Object();
        if (this.dataPos > this.trainingData.length - 1) {
            return output;
        }
        let result = this.processData(this.trainingData[this.dataPos]);
        for(let i = 0; i < this.weights.length; i++){
            let error = this.expectedResults[this.dataPos] - result;
            console.log('Error: ' + error);
            console.log('Old weight: ' + this.weights[i]);
            this.weights[i] += error * this.trainingData[this.dataPos][i] * this.learningRate;
            console.log('training data value: ' + this.trainingData[this.dataPos][i]);
            console.log('New weight: ' + this.weights[i]);
        }
        
        output.x = this.trainingData[this.dataPos][0];
        output.y = this.trainingData[this.dataPos][1];
        output.success = result == this.expectedResults[this.dataPos];
        this.dataPos++;
        return output;
    }
/*
    Take the training data and adjust the weights to get the appropriate
    result.
    */
Take the training data and adjust the weights to get the appropriate
result.
Take the training data and adjust the weights to get the appropriate result .
train() {
        let output = new Object();
        if (this.dataPos > this.trainingData.length - 1) {
            return output;
        }
        let result = this.processData(this.trainingData[this.dataPos]);
        for(let i = 0; i < this.weights.length; i++){
            let error = this.expectedResults[this.dataPos] - result;
            console.log('Error: ' + error);
            console.log('Old weight: ' + this.weights[i]);
            this.weights[i] += error * this.trainingData[this.dataPos][i] * this.learningRate;
            console.log('training data value: ' + this.trainingData[this.dataPos][i]);
            console.log('New weight: ' + this.weights[i]);
        }
        output.x = this.trainingData[this.dataPos][0];
        output.y = this.trainingData[this.dataPos][1];
        output.success = result == this.expectedResults[this.dataPos];
        this.dataPos++;
        return output;
    }
train ( ) { let output = new Object ( ) ; if ( this . dataPos > this . trainingData . length - 1 ) { return output ; } let result = this . processData ( this . trainingData [ this . dataPos ] ) ; for ( let i = 0 ; i < this . weights . length ; i ++ ) { let error = this . expectedResults [ this . dataPos ] - result ; console . log ( 'Error: ' + error ) ; console . log ( 'Old weight: ' + this . weights [ i ] ) ; this . weights [ i ] += error * this . trainingData [ this . dataPos ] [ i ] * this . learningRate ; console . log ( 'training data value: ' + this . trainingData [ this . dataPos ] [ i ] ) ; console . log ( 'New weight: ' + this . weights [ i ] ) ; } output . x = this . trainingData [ this . dataPos ] [ 0 ] ; output . y = this . trainingData [ this . dataPos ] [ 1 ] ; output . success = result == this . expectedResults [ this . dataPos ] ; this . dataPos ++ ; return output ; }
Take the training data and adjust the weights to get the appropriate
result.
Take the training data and adjust the weights to get the appropriate result .