Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
samir-nasibli committed Sep 2, 2024
1 parent da6a3e7 commit f1d5691
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions sklearnex/linear_model/tests/test_incremental_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ def test_sklearnex_fit_on_gold_data(dataframe, queue, fit_intercept, macro_block
inclin.fit(X_df, y_df)

y_pred = inclin.predict(X_df)
y_pred_as_numpy = _as_numpy(y_pred)
np_y_pred = _as_numpy(y_pred)

tol = 2e-6 if y_pred_as_numpy.dtype == np.float32 else 1e-7
tol = 2e-6 if dtype == np.float32 else 1e-7
assert_allclose(inclin.coef_, [1], atol=tol)
if fit_intercept:
assert_allclose(inclin.intercept_, [0], atol=tol)
assert_allclose(y_pred_as_numpy, y, atol=tol)
assert_allclose(np_y_pred, y, atol=tol)


@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
Expand Down Expand Up @@ -85,15 +85,15 @@ def test_sklearnex_partial_fit_on_gold_data(

X_df = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
y_pred = inclin.predict(X_df)
y_pred_as_numpy = _as_numpy(y_pred)
np_y_pred = _as_numpy(y_pred)

assert inclin.n_features_in_ == 1
tol = 2e-6 if y_pred_as_numpy.dtype == np.float32 else 1e-7
tol = 2e-6 if dtype == np.float32 else 1e-7
assert_allclose(inclin.coef_, [[1]], atol=tol)
if fit_intercept:
assert_allclose(inclin.intercept_, 3, atol=tol)

assert_allclose(y_pred_as_numpy, y, atol=tol)
assert_allclose(np_y_pred, y, atol=tol)


@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
Expand Down Expand Up @@ -126,15 +126,15 @@ def test_sklearnex_partial_fit_multitarget_on_gold_data(

X_df = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
y_pred = inclin.predict(X_df)
y_pred_as_numpy = _as_numpy(y_pred)
np_y_pred = _as_numpy(y_pred)

assert inclin.n_features_in_ == 2
tol = 7e-6 if y_pred_as_numpy.dtype == np.float32 else 1e-7
tol = 7e-6 if dtype == np.float32 else 1e-7
assert_allclose(inclin.coef_, [1.0, 2.0], atol=tol)
if fit_intercept:
assert_allclose(inclin.intercept_, 3.0, atol=tol)

assert_allclose(y_pred_as_numpy, y, atol=tol)
assert_allclose(np_y_pred, y, atol=tol)


@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
Expand Down
12 changes: 6 additions & 6 deletions sklearnex/preview/decomposition/tests/test_incremental_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def check_pca_on_gold_data(incpca, dtype, whiten, transformed_data):
)

tol = 1e-7
if transformed_data.dtype == np.float32:
if dtype == np.float32:
tol = 7e-6 if whiten else 1e-6

assert incpca.n_samples_seen_ == expected_n_samples_seen_
Expand Down Expand Up @@ -112,7 +112,7 @@ def check_pca_on_gold_data(incpca, dtype, whiten, transformed_data):


def check_pca(incpca, dtype, whiten, data, transformed_data):
tol = 3e-3 if transformed_data.dtype == np.float32 else 2e-6
tol = 3e-3 if dtype == np.float32 else 2e-6

n_components = incpca.n_components_

Expand Down Expand Up @@ -200,7 +200,7 @@ def test_sklearnex_partial_fit_on_gold_data(dataframe, queue, whiten, num_blocks

X_df = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
transformed_data = incpca.transform(X_df)
check_pca_on_gold_data(incpca, dtype, whiten, _as_numpy(transformed_data))
check_pca_on_gold_data(incpca, dtype, whiten, transformed_data)


@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
Expand All @@ -217,7 +217,7 @@ def test_sklearnex_fit_on_gold_data(dataframe, queue, whiten, num_blocks, dtype)
incpca.fit(X_df)
transformed_data = incpca.transform(X_df)

check_pca_on_gold_data(incpca, dtype, whiten, _as_numpy(transformed_data))
check_pca_on_gold_data(incpca, dtype, whiten, transformed_data)


@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
Expand All @@ -235,7 +235,7 @@ def test_sklearnex_fit_transform_on_gold_data(
X_df = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
transformed_data = incpca.fit_transform(X_df)

check_pca_on_gold_data(incpca, dtype, whiten, _as_numpy(transformed_data))
check_pca_on_gold_data(incpca, dtype, whiten, transformed_data)


@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
Expand Down Expand Up @@ -263,4 +263,4 @@ def test_sklearnex_partial_fit_on_random_data(

X_df = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
transformed_data = incpca.transform(X_df)
check_pca(incpca, dtype, whiten, X, _as_numpy(transformed_data))
check_pca(incpca, dtype, whiten, X, transformed_data)

0 comments on commit f1d5691

Please sign in to comment.