示例#1
0
def test_lm(fit_intercept):
    X, y = make_regression(n_samples=100, n_features=5, chunksize=10)
    lr = LinearRegression(fit_intercept=fit_intercept)
    lr.fit(X, y)
    lr.predict(X)
    if fit_intercept:
        assert lr.intercept_ is not None
示例#2
0
def test_lm(fit_intercept, is_sparse, is_cupy):
    X, y = make_regression(n_samples=100,
                           n_features=5,
                           chunksize=10,
                           is_sparse=is_sparse)
    if is_cupy and not is_sparse:
        cupy = pytest.importorskip('cupy')
        X, y = to_dask_cupy_array_xy(X, y, cupy)
    lr = LinearRegression(fit_intercept=fit_intercept)
    lr.fit(X, y)
    lr.predict(X)
    if fit_intercept:
        assert lr.intercept_ is not None
示例#3
0
def glm_example():
	client = Client(processes=False, threads_per_worker=4, n_workers=1, memory_limit='2GB')

	X, y = make_regression(n_samples=200000, n_features=100, n_informative=5, chunksize=10000)
	X, y = dask.persist(X, y)

	b = dask_glm.algorithms.admm(X, y, max_iter=5)
	print(b)

	b = dask_glm.algorithms.proximal_grad(X, y, max_iter=5)
	print(b)

	family = dask_glm.families.Poisson()
	regularizer = dask_glm.regularizers.ElasticNet()
	b = dask_glm.algorithms.proximal_grad(
		X, y,
		max_iter=5,
		family=family,
		regularizer=regularizer,
	)
	print(b)