コード例 #1
0
def R_run_loess(x, y, span=0.75):
    """
    Predict y as function of x. Takes two numpy vectors.
    """
    # Ensure that Inf/-Inf values are substituted
    x[utils.where_null(x)] = robj.NA_Real
    y[utils.where_null(x)] = robj.NA_Real
    data = robj.DataFrame({"x": x, "y": y})
    loess_fit = r.loess("y ~ x", data=data, span=span, family="symmetric")
    correction_factor = np.array(list(r.predict(loess_fit, x)))
    corrected_y = \
        np.array(list(y)) - correction_factor
    return corrected_y, correction_factor
コード例 #2
0
ファイル: normalizers.py プロジェクト: hjanime/normpy
def R_run_loess(x, y, span=0.75):
    """
    Predict y as function of x. Takes two numpy vectors.
    """
    # Ensure that Inf/-Inf values are substituted
    x[utils.where_null(x)] = robj.NA_Real
    y[utils.where_null(x)] = robj.NA_Real
    data = robj.DataFrame({"x": x, "y": y})
    loess_fit = r.loess("y ~ x", data=data, span=span,
                        family="symmetric")
    correction_factor = np.array(list(r.predict(loess_fit, x)))
    corrected_y = \
        np.array(list(y)) - correction_factor
    return corrected_y, correction_factor
コード例 #3
0
def run_lowess(X, Y, frac=0.75, missing="none"):
    """
    Y ~ X lowess.

    Parameters:
    -----------

    X: X values
    Y: Y values
    frac: fraction of data used to estimate each y-value.
    missing: how to handle missing values (by default "drop" them).
    """
    X[utils.where_null(X)] = np.nan
    Y[utils.where_null(Y)] = np.nan
    # Lowess takes Y values first
    fitted_Y = lowess(Y, X, return_sorted=False, frac=frac, missing=missing)
    return fitted_Y
コード例 #4
0
ファイル: normalizers.py プロジェクト: hjanime/normpy
def run_lowess(X, Y,
               frac=0.75,
               missing="none"):
    """
    Y ~ X lowess.

    Parameters:
    -----------

    X: X values
    Y: Y values
    frac: fraction of data used to estimate each y-value.
    missing: how to handle missing values (by default "drop" them).
    """
    X[utils.where_null(X)] = np.nan
    Y[utils.where_null(Y)] = np.nan
    # Lowess takes Y values first
    fitted_Y = lowess(Y, X,
                      return_sorted=False,
                      frac=frac,
                      missing=missing)
    return fitted_Y