8000 Merge pull request #5288 from jnothman/bicluster-example-speed · scikit-learn/scikit-learn@b9284a7 · GitHub
[go: up one dir, main page]

Skip to content
Sign in

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b9284a7

Browse files
committed
Merge pull request #5288 from jnothman/bicluster-example-speed
[MRG] Bicluster example speed
2 parents 770d089 + a24b932 commit b9284a7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

examples/bicluster/bicluster_newsgroups.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,11 @@ def bicluster_ncut(i):
132132
return sys.float_info.max
133133
row_complement = np.nonzero(np.logical_not(cocluster.rows_[i]))[0]
134134
col_complement = np.nonzero(np.logical_not(cocluster.columns_[i]))[0]
135-
weight = X[rows[:, np.newaxis], cols].sum()
136-
cut = (X[row_complement[:, np.newaxis], cols].sum() +
137-
X[rows[:, np.newaxis], col_complement].sum())
135+
# Note: the following is identical to X[rows[:, np.newaxis], cols].sum() but
136+
# much faster in scipy <= 0.16
137+
weight = X[rows][:, cols].sum()
138+
cut = (X[row_complement][:, cols].sum() +
139+
X[rows][:, col_complement].sum())
138140
return cut / weight
139141

140142

0 commit comments

Comments
 (0)
0