metrics.mean_squared_error

mean_squared_error(y_true: `object`, y_pred: `object`, __namedParameters: `object`)

Mean squared error regression loss

Usage

import { mean_squared_error } from 'machinelearn/metrics';

const y_true = [3, -0.5, 2, 7];
const y_pred = [2.5, 0.0, 2, 8];

console.log(mean_squared_error(y_true, y_pred));
// result: 0.375

const y_true1 = [[0.5, 1], [-1, 1], [7, -6]];
const y_pred1 = [[0, 2], [-1, 2], [8, -5]];

console.log(mean_squared_error(y_true1, y_pred1));
// result: 0.7083333134651184

Defined in metrics/regression.ts:114

Parameters:

ParamTypeDefaultDescription
ytruenumber[] or number[][]nullGround truth (correct) target values.
yprednumber[] or number[][]nullEstimated target values.
options.sampleweightnumbernullSample weights.

Returns:

number