swh:1:snp:4e3e7077647a709f15b8c1b32ce7100175d0580b
Raw File
Tip revision: 23c6d135ae81f12205d4d57c22652628ecc2adf1 authored by Jean Kossaifi on 06 January 2017, 13:34:08 UTC
Better github ribbon (especially for mobiles)
Tip revision: 23c6d13
regression.py
import numpy as np

# Author: Jean Kossaifi <jean.kossaifi+tensors@gmail.com>


def MSE(y_true, y_pred):
    """Returns the mean squared error between the two predictions

    Parameters
    ----------
    y_true : array of shape (n_samples, )
        Ground truth (correct) target values.
    y_pred : array of shape (n_samples, )
        Estimated target values.

    Returns
    -------
    float
    """
    return np.mean((y_true - y_pred) ** 2)


def RMSE(y_true, y_pred):
    """Returns the regularised mean squared error between the two predictions
    (the square-root is applied to the mean_squared_error)

    Parameters
    ----------
    y_true : array of shape (n_samples, )
        Ground truth (correct) target values.
    y_pred : array of shape (n_samples, )
        Estimated target values.

    Returns
    -------
    float
    """
    return np.sqrt(MSE(y_true, y_pred))

back to top