Skip to content

Commit

Permalink
attempt 2
Browse files Browse the repository at this point in the history
  • Loading branch information
icfaust committed Feb 3, 2025
1 parent 71ae702 commit 9564498
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion .ci/run_tsne.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,30 @@ def test_sparse_precomputed_distance():
"""Make sure that TSNE works identically for sparse and dense matrix"""
random_state = check_random_state(0)
X = random_state.randn(100, 2)

t = time.time()
D_sparse = kneighbors_graph(X, n_neighbors=100, mode="distance", include_self=True)
print(f"kneighbors_graph: {time.time()-t}")

t = time.time()
D = pairwise_distances(X)
print(f"pairwise: {time.time()-t}")

assert sp.issparse(D_sparse)
assert_almost_equal(D_sparse.A, D)

tsne = TSNE(
metric="precomputed", random_state=0, init="random", learning_rate="auto"
)
t = time.time()
Xt_dense = tsne.fit_transform(D)
print(f"dense: {time.time()-t}")


for fmt in ["csr", "lil"]:
t = time.time()
Xt_sparse = tsne.fit_transform(D_sparse.asformat(fmt))
assert_almost_equal(Xt_dense, Xt_sparse)
print(f"sparse {fmt}: {time.time()-t}")


print("running test")
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
source .github/scripts/activate_components.sh
cd .ci
python run_tsne.py
py-spy record -o ../profile.svg --native -- python run_tsne.py
py-spy record -o ../profile.svg -- python run_tsne.py
- name: Archive flamegraph
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions daal4py/sklearn/_n_jobs_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def get_suggested_n_threads(n_cpus):
del n_threads_map["openblas"]
# remove default values equal to n_cpus as uninformative
for backend in list(n_threads_map.keys()):
print(n_threads_map)
if n_threads_map[backend] == n_cpus:
del n_threads_map[backend]
if len(n_threads_map) > 0:
Expand Down

0 comments on commit 9564498

Please sign in to comment.