Skip to content

Commit 9111ce5

Browse files
expose strategy param for calibration curve reiinakano#118
1 parent ccb9969 commit 9111ce5

File tree

3 files changed

+70
-15
lines changed

3 files changed

+70
-15
lines changed

CONTRIBUTING.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,49 @@ Fixing a bug you found in Scikit-plot? Suggesting a feature? Adding your own plo
66

77
2. **Fork the repository**. If you're contributing code, clone the forked repository into your local machine.
88

9+
- If you are a first-time contributor:
10+
- Go to github and click the “fork” button to create your own copy of the project.
11+
- Clone the project to your local computer:
12+
```bash
13+
git clone --recurse-submodules https://github.com/your-username/scikit-plot.git
14+
```
15+
- Now, `git remote -v` will show two remote repositories named:
16+
- upstream, which refers to the scikit-plot repository
17+
- origin, which refers to your personal fork
18+
- Pull the latest changes from upstream, including tags:
19+
```bash
20+
git checkout main
21+
git pull upstream main --tags
22+
```
23+
- Initialize submodules:
24+
```bash
25+
git submodule update --init
26+
```
927
3. **Run the tests** to make sure they pass on your machine. Simply run `pytest` at the root folder and make sure all tests pass.
1028

1129
4. **Create a new branch**. Please do not commit directly to the master branch. Create your own branch and place your additions there.
1230

13-
5. **Write your code**. Please follow PEP8 coding standards. Also, if you're adding a function, you must [write a docstring using the Google format](http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) detailing the API of your function. Take a look at the docstrings of the other Scikit-plot functions to get an idea of what the docstring of yours should look like.
31+
- Develop your contribution:
32+
- Create a branch for the feature you want to work on. Since the branch name will appear in the merge message, use a sensible name such as 'linspace-speedups':
33+
```bash
34+
git checkout -b linspace-speedups
35+
```
36+
5. **Write your code**. Please follow PEP8 coding standards. Also, if you're adding a function, you must currently [write a docstring using the Google format](http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) detailing the API of your function or In Feature [NumPy docstring standard](https://numpy.org/devdocs/dev/howto-docs.html#howto-document). Take a look at the docstrings of the other Scikit-plot functions to get an idea of what the docstring of yours should look like.
37+
38+
- Commit locally as you progress (`git add` and `git commit`) Use a properly formatted commit message, write tests that fail before your change and pass afterward, run all the tests locally. Be sure to document any changed behavior in docstrings, keeping to the NumPy docstring [standard](https://numpy.org/devdocs/dev/howto-docs.html#howto-document).
1439
1540
6. **Write/modify the corresponding unit tests**. After adding in your code and the corresponding unit tests, run `pytest` again to make sure they pass.
1641
17-
7. **Submit a pull request**. After submitting a PR, if all tests pass, your code will be reviewed and merged promptly.
42+
7. **Submit a pull request**. After submitting a PR (pull requests), if all tests pass, your code will be reviewed and merged promptly.
43+
44+
- To submit your contribution:
45+
- Push your changes back to your fork on GitHub:
46+
```bash
47+
git push origin linspace-speedups
48+
```
49+
- Go to GitHub. The new branch will show up with a green Pull Request button. Make sure the title and message are clear, concise, and self- explanatory. Then click the button to submit it.
50+
51+
- If your commit introduces a new feature or changes functionality, post on the mailing list to explain your changes. For bug fixes, documentation updates, etc., this is generally not necessary, though if you do not get any reaction, do feel free to ask for review.
52+
- Review process:
1853
1954
Thank you for taking the time to make Scikit-plot better!

scikitplot/metrics.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -906,11 +906,11 @@ def plot_silhouette(X, cluster_labels, title='Silhouette Analysis',
906906
return ax
907907

908908

909-
def plot_calibration_curve(y_true, probas_list, clf_names=None, n_bins=10,
909+
def plot_calibration_curve(y_true, probas_list, clf_names=None, n_bins=10,
910910
title='Calibration plots (Reliability Curves)',
911911
ax=None, figsize=None, cmap='nipy_spectral',
912912
title_fontsize="large", text_fontsize="medium",
913-
pos_label=None):
913+
pos_label=None, strategy="uniform",):
914914
"""Plots calibration curves for a set of classifier probability estimates.
915915
916916
Plotting the calibration curves of a classifier is useful for determining
@@ -964,6 +964,12 @@ def plot_calibration_curve(y_true, probas_list, clf_names=None, n_bins=10,
964964
If `y_true` contains string labels or labels other than {0, 1} or {-1, 1},
965965
you must specify this parameter explicitly.
966966
967+
strategy (str, optional): Strategy used to define the widths of the bins.
968+
uniform
969+
The bins have identical widths.
970+
quantile
971+
The bins have the same number of samples and depend on `y_prob`.
972+
967973
Returns:
968974
:class:`matplotlib.axes.Axes`: The axes on which the plot was drawn.
969975
@@ -1033,9 +1039,10 @@ def plot_calibration_curve(y_true, probas_list, clf_names=None, n_bins=10,
10331039

10341040
probas = (probas - probas.min()) / (probas.max() - probas.min())
10351041

1036-
fraction_of_positives, mean_predicted_value = \
1037-
calibration_curve(y_true, probas, n_bins=n_bins, pos_label=pos_label)
1038-
1042+
fraction_of_positives, mean_predicted_value = calibration_curve(
1043+
y_true, probas, n_bins=n_bins,
1044+
pos_label=pos_label, strategy=strategy
1045+
)
10391046
color = plt.cm.get_cmap(cmap)(float(i) / len(probas_list))
10401047

10411048
ax.plot(mean_predicted_value, fraction_of_positives, 's-',

setup.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,43 @@ def get_version(rel_path):
5454
long_description=README,
5555
version=VERSION,
5656
url='https://github.com/reiinakano/scikit-plot',
57+
download_url='https://github.com/reiinakano/scikit-plot?tab=readme-ov-file#installation',
58+
project_urls={
59+
'Documentation': 'https://github.com/reiinakano/scikit-plot',
60+
'Source Code': 'https://github.com/reiinakano/scikit-plot',
61+
'Bug Tracker': 'https://github.com/reiinakano/scikit-plot/issues',
62+
'Forum': '',
63+
'Donate': '',
64+
},
5765
author='Reiichiro Nakano',
5866
author_email='reiichiro.s.nakano@gmail.com',
5967
license='MIT License',
6068
install_requires=[
6169
'matplotlib>=1.4.0',
62-
'scikit-learn>=0.18',
70+
'scikit-learn>=0.21',
6371
'scipy>=0.9',
6472
'joblib>=0.10'
6573
],
6674
# Supported Python versions
6775
# python_requires=">=2.7",
6876
classifiers = [
77+
'Development Status :: 1 - Planning',
78+
'Intended Audience :: Developers',
79+
'Intended Audience :: Science/Research',
80+
'License :: OSI Approved :: MIT License',
81+
'Natural Language :: English',
82+
'Operating System :: OS Independent',
6983
'Programming Language :: Python',
7084
'Programming Language :: Python :: 2',
71-
'Programming Language :: Python :: 2.7',
85+
'Programming Language :: Python :: 2.5',
7286
'Programming Language :: Python :: 3',
7387
'Programming Language :: Python :: 3.5',
74-
'Programming Language :: Python :: 3.6',
75-
'Operating System :: OS Independent',
76-
'Intended Audience :: Science/Research',
77-
'Intended Audience :: Developers',
88+
'Programming Language :: Python :: 3.10',
89+
'Programming Language :: Python :: 3.14',
90+
'Topic :: Communications :: Email',
91+
'Topic :: Documentation :: Sphinx',
7892
'Topic :: Scientific/Engineering :: Visualization',
79-
'License :: OSI Approved :: MIT License',
80-
'Natural Language :: English',
93+
'Topic :: Utilities',
8194
],
8295
packages=['scikitplot'],
8396
include_package_data=True,

0 commit comments

Comments
 (0)