-
-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
177 changed files
with
4,405 additions
and
559 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Yellowbrick PR Linting | ||
|
||
on: | ||
# Trigger on pull request always (note the trailing colon) | ||
pull_request: | ||
|
||
jobs: | ||
# Run pre-commit checks on the files changed | ||
linting: | ||
runs-on: ubuntu-latest | ||
name: Linting | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pre-commit | ||
pre-commit install | ||
- name: Run Checks | ||
run: | | ||
pre-commit run --from-ref origin/${{ github.base_ref }} --to-ref HEAD --show-diff-on-failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.2.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- repo: https://github.com/psf/black | ||
rev: 22.6.0 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 5.0.4 | ||
hooks: | ||
- id: flake8 | ||
- repo: https://github.com/pre-commit/pygrep-hooks | ||
rev: v1.9.0 | ||
hooks: | ||
- id: rst-backticks | ||
- id: rst-directive-colons | ||
- id: rst-inline-touching-normal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
.. -*- mode: rst -*- | ||
Feature Dropping Curve | ||
============================= | ||
|
||
================= ===================== | ||
Visualizer :class:`~yellowbrick.model_selection.dropping_curve.DroppingCurve` | ||
Quick Method :func:`~yellowbrick.model_selection.dropping_curve.dropping_curve` | ||
Models Classification, Regression, Clustering | ||
Workflow Model Selection | ||
================= ===================== | ||
|
||
A feature dropping curve (FDC) shows the relationship between the score and the number of features used. | ||
This visualizer randomly drops input features, showing how the estimator benefits from additional features of the same type. | ||
For example, how many air quality sensors are needed across a city to accurately predict city-wide pollution levels? | ||
|
||
Feature dropping curves helpfully complement :doc:`rfecv` (RFECV). | ||
In the air quality sensor example, RFECV finds which sensors to keep in the specific city. | ||
Feature dropping curves estimate how many sensors a similar-sized city might need to track pollution levels. | ||
|
||
Feature dropping curves are common in the field of neural decoding, where they are called `neuron dropping curves <https://dx.doi.org/10.3389%2Ffnsys.2014.00102>`_ (`example <https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8293867/figure/F3/>`_, panels C and H). | ||
Neural decoding research often quantifies how performance scales with neuron (or electrode) count. | ||
Because neurons do not correspond directly between participants, we use random neuron subsets to simulate what performance to expect when recording from other participants. | ||
|
||
To show how this works in practice, consider an image classification example using `handwritten digits <https://archive.ics.uci.edu/ml/datasets/Optical+Recognition+of+Handwritten+Digits>`_. | ||
|
||
.. plot:: | ||
:context: close-figs | ||
:alt: Dropping Curve on the digits dataset | ||
|
||
from sklearn.svm import SVC | ||
from sklearn.datasets import load_digits | ||
|
||
from yellowbrick.model_selection import DroppingCurve | ||
|
||
# Load dataset | ||
X, y = load_digits(return_X_y=True) | ||
|
||
# Initialize visualizer with estimator | ||
visualizer = DroppingCurve(SVC()) | ||
|
||
# Fit the data to the visualizer | ||
visualizer.fit(X, y) | ||
# Finalize and render the figure | ||
visualizer.show() | ||
|
||
This figure shows an input feature dropping curve. | ||
Since the features are informative, the accuracy increases with more larger feature subsets. | ||
The shaded area represents the variability of cross-validation, one standard deviation above and below the mean accuracy score drawn by the curve. | ||
|
||
The visualization can be interpreted as the performance if we knew some image pixels were corrupted. | ||
As an alternative interpretation, the dropping curve roughly estimates the accuracy if the image resolution was downsampled. | ||
|
||
Quick Method | ||
------------ | ||
The same functionality can be achieved with the associated quick method ``dropping_curve``. This method will build the ``DroppingCurve`` with the associated arguments, fit it, then (optionally) immediately show the visualization. | ||
|
||
.. plot:: | ||
:context: close-figs | ||
:alt: Dropping Curve Quick Method on the digits dataset | ||
|
||
from sklearn.svm import SVC | ||
from sklearn.datasets import load_digits | ||
|
||
from yellowbrick.model_selection import dropping_curve | ||
|
||
# Load dataset | ||
X, y = load_digits(return_X_y=True) | ||
|
||
dropping_curve(SVC(), X, y) | ||
|
||
|
||
API Reference | ||
------------- | ||
|
||
.. automodule:: yellowbrick.model_selection.dropping_curve | ||
:members: DroppingCurve, dropping_curve | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
.. -*- mode: rst -*- | ||
Word Correlation Plot | ||
===================== | ||
|
||
Word correlation illustrates the extent to which words or phrases co-appear across the documents in a corpus. This can be useful for understanding the relationships between known text features in a corpus with many documents. ``WordCorrelationPlot`` allows for the visualization of the document occurrence correlations between select words in a corpus. For a number of features n, the plot renders an n x n heatmap containing correlation values. | ||
|
||
The correlation values are computed using the `phi coefficient <https://en.wikipedia.org/wiki/Phi_coefficient>`_ metric, which is a measure of the association between two binary variables. A value close to 1 or -1 indicates that the occurrences of the two features are highly positively or negatively correlated, while a value close to 0 indicates no relationship between the two features. | ||
|
||
================= ============================== | ||
Visualizer :class:`~yellowbrick.text.correlation.WordCorrelationPlot` | ||
Quick Method :func:`~yellowbrick.text.correlation.word_correlation()` | ||
Models Text Modeling | ||
Workflow Feature Engineering | ||
================= ============================== | ||
|
||
.. plot:: | ||
:context: close-figs | ||
:alt: Word Correlation Plot | ||
|
||
from yellowbrick.datasets import load_hobbies | ||
from yellowbrick.text.correlation import WordCorrelationPlot | ||
|
||
# Load the text corpus | ||
corpus = load_hobbies() | ||
|
||
# Create the list of words to plot | ||
words = ["Tatsumi Kimishima", "Nintendo", "game", "play", "man", "woman"] | ||
|
||
# Instantiate the visualizer and draw the plot | ||
viz = WordCorrelationPlot(words) | ||
viz.fit(corpus.data) | ||
viz.show() | ||
|
||
|
||
Quick Method | ||
------------ | ||
|
||
The same functionality above can be achieved with the associated quick method `word_correlation`. This method will build the Word Correlation Plot object with the associated arguments, fit it, then (optionally) immediately show the visualization. | ||
|
||
.. plot:: | ||
:context: close-figs | ||
:alt: Word Correlation Plot | ||
|
||
from yellowbrick.datasets import load_hobbies | ||
from yellowbrick.text.correlation import word_correlation | ||
|
||
# Load the text corpus | ||
corpus = load_hobbies() | ||
|
||
# Create the list of words to plot | ||
words = ["Game", "player", "score", "oil"] | ||
|
||
# Draw the plot | ||
word_correlation(words, corpus.data) | ||
|
||
API Reference | ||
------------- | ||
|
||
.. automodule:: yellowbrick.text.correlation | ||
:members: WordCorrelationPlot, word_correlation | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.