Skip to content

Navigation Menu

Sign in
Appearance settings

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 aac215e

Browse filesBrowse files
committed
Rephrase docstring and avoid unnecessary python lists
# More detailed explanatory text, if necessary. Wrap it to about 72 # characters or so. In some contexts, the first line is treated as the # subject of the commit and the rest of the text as the body. The # blank line separating the summary from the body is critical (unless # you omit the body entirely); various tools like `log`, `shortlog` # and `rebase` can get confused if you run the two together. # Explain the problem that this commit is solving. Focus on why you # are making this change as opposed to how (the code explains that). # Are there side effects or other unintuitive consequences of this # change? Here's the place to explain them. # Further paragraphs come after blank lines. # - Bullet points are okay, too # - Typically a hyphen or asterisk is used for the bullet, preceded # by a single space, with blank lines in between, but conventions # vary here # If you use an issue tracker, put references to them at the bottom, # like this: # Resolves: scikit-learn#123 # See also: scikit-learn#456, scikit-learn#789
1 parent cf0ff36 commit aac215e
Copy full SHA for aac215e

File tree

Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed

‎sklearn/metrics/_ranking.py

Copy file name to clipboardExpand all lines: sklearn/metrics/_ranking.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@ def top_k_accuracy_score(y_true, y_score, *, k=2, normalize=True,
14691469
labels in ``y_true``.
14701470
14711471
k : int, default=2
1472-
Number of guesses allowed to find the correct label.
1472+
Number of most likely outcomes considered to find the correct label.
14731473
14741474
normalize : bool, default=True
14751475
If `True`, return the fraction of correctly classified samples.
@@ -1578,7 +1578,7 @@ def top_k_accuracy_score(y_true, y_score, *, k=2, normalize=True,
15781578
y_pred = (y_score > threshold).astype(np.int)
15791579
hits = y_pred == y_true_encoded
15801580
else:
1581-
hits = [True] * len(y_score)
1581+
hits = np.ones_like(y_score, dtype=np.bool_)
15821582
elif y_type == 'multiclass':
15831583
sorted_pred = np.argsort(y_score, axis=1, kind='mergesort')[:, ::-1]
15841584
hits = (y_true_encoded == sorted_pred[:, :k].T).any(axis=0)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.