def test_lars_path_readonly_data():
    # When using automated memory mapping on large input, the
    # fold data is in read-only mode
    # This is a non-regression test for:
    # https://github.com/scikit-learn/scikit-learn/issues/4597
    splitted_data = train_test_split(X, y, random_state=42)
    with TempMemmap(splitted_data) as (X_train, X_test, y_train, y_test):
        # The following should not fail despite copy=False
        _lars_path_residues(X_train, y_train, X_test, y_test, copy=False)
def test_lars_path_readonly_data():
    # When using automated memory mapping on large input, the
    # fold data is in read-only mode
    # This is a non-regression test for:
    # https://github.com/scikit-learn/scikit-learn/issues/4597
    splitted_data = train_test_split(X, y, random_state=42)
    with TempMemmap(splitted_data) as (X_train, X_test, y_train, y_test):
        # The following should not fail despite copy=False
        _lars_path_residues(X_train, y_train, X_test, y_test, copy=False)
def test_lars_path_readonly_data():
    # When using automated memory mapping on large input, the
    # fold data is in read-only mode
    # This is a non-regression test for:
    # https://github.com/scikit-learn/scikit-learn/issues/4597
    splitted_data = train_test_split(X, y, random_state=42)
    temp_folder = tempfile.mkdtemp()
    try:
        fpath = op.join(temp_folder, 'data.pkl')
        joblib.dump(splitted_data, fpath)
        X_train, X_test, y_train, y_test = joblib.load(fpath, mmap_mode='r')

        # The following should not fail despite copy=False
        _lars_path_residues(X_train, y_train, X_test, y_test, copy=False)
    finally:
        shutil.rmtree(temp_folder)
Beispiel #4
0
def test_lars_path_readonly_data():
    # When using automated memory mapping on large input, the
    # fold data is in read-only mode
    # This is a non-regression test for:
    # https://github.com/scikit-learn/scikit-learn/issues/4597
    splitted_data = train_test_split(X, y, random_state=42)
    temp_folder = tempfile.mkdtemp()
    try:
        fpath = op.join(temp_folder, 'data.pkl')
        joblib.dump(splitted_data, fpath)
        X_train, X_test, y_train, y_test = joblib.load(fpath, mmap_mode='r')

        # The following should not fail despite copy=False
        _lars_path_residues(X_train, y_train, X_test, y_test, copy=False)
    finally:
        # try to release the mmap file handle in time to be able to delete
        # the temporary folder under windows
        del X_train, X_test, y_train, y_test
        try:
            shutil.rmtree(temp_folder)
        except shutil.WindowsError:
            warnings.warn("Could not delete temporary folder %s" % temp_folder)
    X = y.reshape(-1, 1)
    lars = linear_model.LassoLarsIC(normalize=False)
    assert_no_warnings(lars.fit, X, y)
    assert_true(np.any(np.isinf(lars.criterion_)))


def test_lars_path_readonly_data():
    # When using automated memory mapping on large input, the
    # fold data is in read-only mode
    # This is a non-regression test for:
    # https://github.com/scikit-learn/scikit-learn/issues/4597
    splitted_data = train_test_split(X, y, random_state=42)
    with TempMemmap(splitted_data) as (X_train, X_test, y_train, y_test):
        # The following should not fail despite copy=False
<<<<<<< HEAD
        _lars_path_residues(X_train, y_train, X_test, y_test, copy=False)
    finally:
        # try to release the mmap file handle in time to be able to delete
        # the temporary folder under windows
        del X_train, X_test, y_train, y_test
        try:
            shutil.rmtree(temp_folder)
        except shutil.WindowsError:
            warnings.warn("Could not delete temporary folder %s" % temp_folder)


def test_lars_path_positive_constraint():
    # this is the main test for the positive parameter on the lars_path method
    # the estimator classes just make use of this function

    # we do the test on the diabetes dataset