nl_tokens: Determine the coefficient of determination ( r^2 ) of a fit from the observations and predictions .
pl_tokens: function determinationCoefficient ( data , results ) { const predictions = [ ] ; const observations = [ ] ; data . forEach ( ( d , i ) => { if ( d [ 1 ] !== null ) { observations . push ( d ) ; predictions . push ( results [ i ] ) ; } } ) ; const sum = observations . reduce ( ( a , observation ) => a + observation [ 1 ] , 0 ) ; const mean = sum / observations . length ; const ssyy = observations . reduce ( ( a , observation ) => { const difference = observation [ 1 ] - mean ; return a + ( difference * difference ) ; } , 0 ) ; const sse = observations . reduce ( ( accum , observation , index ) => { const prediction = predictions [ <mask> ] ; const residual = observation [ 1 ] - prediction [ 1 ] ; return accum + ( residual * residual ) ; } , 0 ) ; return 1 - ( sse / ssyy ) ; }