Skip to content

DOC Update plot_permutation_test_for_classification.py#17385

Merged
ogrisel merged 16 commits intoscikit-learn:masterfrom
lucyleeow:plot_perm
Jul 31, 2020
Merged

DOC Update plot_permutation_test_for_classification.py#17385
ogrisel merged 16 commits intoscikit-learn:masterfrom
lucyleeow:plot_perm

Conversation

@lucyleeow
Copy link
Copy Markdown
Member

Reference Issues/PRs

What does this implement/fix? Explain your changes.

  • use notebook style alternating code and text blocks
  • amend example to use calculate score with both structured and unstructured data
  • Expand explanations

Any other comments?

@lucyleeow lucyleeow changed the title WIP DOC Update plot_permutation_test_for_classification.py DOC Update plot_permutation_test_for_classification.py May 29, 2020
Copy link
Copy Markdown
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @lucyleeow !

#
# Next, we calculate the
# :func:`~sklearn.model_selection.permutation_test_score` using the original
# iris dataset, which has strong structure, and
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe:

Suggested change
# iris dataset, which has strong structure, and
# iris dataset, which strongly predict the labels, and

# iris dataset, which has strong structure, and
# the randomly generated features and iris labels, which should have
# no dependency between features and labels. The
# :class:`~sklearn.svm.svc` classifier and :ref:`accuracy_score` are used.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# :class:`~sklearn.svm.svc` classifier and :ref:`accuracy_score` are used.
# :class:`~sklearn.svm.SVC` classifier and :ref:`accuracy_score` are used.

# distribution by calculating the accuracy of the classifier
# on 1000 different permutations of the dataset, where features
# remain the same but labels undergo different permutations. This is the
# distribution for the null hypothesis that there is no dependency between
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# distribution for the null hypothesis that there is no dependency between
# distribution for the null hypothesis which states there is no dependency between

plt.legend()
plt.xlabel('Score')
score_iris, perm_scores_iris, pvalue_iris = permutation_test_score(
clf, X, y, scoring="accuracy", cv=cv, n_permutations=1000, n_jobs=1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default is 1:

Suggested change
clf, X, y, scoring="accuracy", cv=cv, n_permutations=1000, n_jobs=1)
clf, X, y, scoring="accuracy", cv=cv, n_permutations=1000)

clf, X, y, scoring="accuracy", cv=cv, n_permutations=1000, n_jobs=1)

score_rand, perm_scores_rand, pvalue_rand = permutation_test_score(
clf, X_rand, y, scoring="accuracy", cv=cv, n_permutations=1000, n_jobs=1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
clf, X_rand, y, scoring="accuracy", cv=cv, n_permutations=1000, n_jobs=1)
clf, X_rand, y, scoring="accuracy", cv=cv, n_permutations=1000)

@lucyleeow
Copy link
Copy Markdown
Member Author

Thanks for the review @thomasjpfan! Amended.

Copy link
Copy Markdown
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Just little improvements to be considered.

@lucyleeow
Copy link
Copy Markdown
Member Author

Thanks @glemaitre! Just let me know what you think we should do to avoid the text output from matplotlib: #17385 (comment)

@lucyleeow
Copy link
Copy Markdown
Member Author

ping @glemaitre, changes made.

Copy link
Copy Markdown
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ogrisel ogrisel merged commit e087f8a into scikit-learn:master Jul 31, 2020
@lucyleeow lucyleeow deleted the plot_perm branch July 31, 2020 20:10
jayzed82 pushed a commit to jayzed82/scikit-learn that referenced this pull request Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants