Skip to content

Commit d4d5f8c

Browse files
MAINT consistent use of print(__doc__) in examples (#21307)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
1 parent 6e7fc0e commit d4d5f8c

File tree

271 files changed

+247
-355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

271 files changed

+247
-355
lines changed

examples/applications/plot_cyclical_feature_engineering.py

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
`extrapolation="periodic"` option.
1313
1414
"""
15+
1516
# %%
1617
# Data exploration on the Bike Sharing Demand dataset
1718
# ---------------------------------------------------

examples/applications/plot_digits_denoising.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
"Learning to find pre-images."
1919
Advances in neural information processing systems 16 (2004): 449-456.
2020
<https://papers.nips.cc/paper/2003/file/ac1ad983e08ad3304a97e147f522747e-Paper.pdf>`_
21-
"""
2221
23-
print(__doc__)
22+
"""
2423

2524
# Authors: Guillaume Lemaitre <guillaume.lemaitre@inria.fr>
2625
# Licence: BSD 3 clause

examples/applications/plot_face_recognition.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
================== ============ ======= ========== =======
2828
2929
"""
30+
3031
from time import time
3132
import logging
3233
import matplotlib.pyplot as plt
@@ -40,8 +41,6 @@
4041
from sklearn.svm import SVC
4142

4243

43-
print(__doc__)
44-
4544
# Display progress logs on stdout
4645
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(message)s")
4746

examples/applications/plot_model_complexity_influence.py

-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
3333
"""
3434

35-
print(__doc__)
36-
3735
# Authors: Eustache Diemert <eustache@diemert.fr>
3836
# Maria Telenczuk <https://github.com/maikia>
3937
# Guillaume Lemaitre <g.lemaitre58@gmail.com>

examples/applications/plot_out_of_core_classification.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
HashingVectorizer that will project each example into the same feature space.
1212
This is especially useful in the case of text classification where new
1313
features (words) may appear in each batch.
14+
1415
"""
1516

1617
# Authors: Eustache Diemert <eustache@diemert.fr>

examples/applications/plot_outlier_detection_wine.py

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
example, none of these could be applied that easily.
3434
3535
"""
36-
print(__doc__)
3736

3837
# Author: Virgile Fritsch <virgile.fritsch@inria.fr>
3938
# License: BSD 3 clause

examples/applications/plot_species_distribution_modeling.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<http://rob.schapire.net/papers/ecolmod.pdf>`_
3434
S. J. Phillips, R. P. Anderson, R. E. Schapire - Ecological Modelling,
3535
190:231-259, 2006.
36+
3637
"""
3738

3839
# Authors: Peter Prettenhofer <peter.prettenhofer@gmail.com>
@@ -58,8 +59,6 @@
5859
except ImportError:
5960
basemap = False
6061

61-
print(__doc__)
62-
6362

6463
def construct_grids(batch):
6564
"""Construct the map grid from the batch object

examples/applications/plot_stock_market.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
is to position the labels minimizing overlap. For this we use an
5959
heuristic based on the direction of the nearest neighbor along each
6060
axis.
61+
6162
"""
6263

6364
# Author: Gael Varoquaux gael.varoquaux@normalesup.org
@@ -73,8 +74,6 @@
7374

7475
from sklearn import cluster, covariance, manifold
7576

76-
print(__doc__)
77-
7877

7978
# #############################################################################
8079
# Retrieve the data from Internet

examples/applications/plot_tomography_l1_reconstruction.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ class :class:`~sklearn.linear_model.Lasso`, that uses the coordinate descent
3333
reconstructed image, contrary to the L1 penalization. Note in particular
3434
the circular artifact separating the pixels in the corners, that have
3535
contributed to fewer projections than the central disk.
36-
"""
3736
38-
print(__doc__)
37+
"""
3938

4039
# Author: Emmanuelle Gouillart <emmanuelle.gouillart@nsup.org>
4140
# License: BSD 3 clause

examples/applications/svm_gui.py

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
1515
"""
1616

17-
print(__doc__)
18-
1917
# Author: Peter Prettenhoer <peter.prettenhofer@gmail.com>
2018
#
2119
# License: BSD 3 clause

examples/applications/wikipedia_principal_eigenvector.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
2828
The graph data is fetched from the DBpedia dumps. DBpedia is an extraction
2929
of the latent structured data of the Wikipedia content.
30+
3031
"""
3132

3233
# Author: Olivier Grisel <olivier.grisel@ensta.org>
@@ -46,8 +47,6 @@
4647
from urllib.request import urlopen
4748

4849

49-
print(__doc__)
50-
5150
# #############################################################################
5251
# Where to download the data, if not already on disk
5352
redirects_url = "http://downloads.dbpedia.org/3.5.1/en/redirects_en.nt.bz2"

examples/bicluster/plot_bicluster_newsgroups.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
achieve a better V-measure than clusters found by MiniBatchKMeans.
2323
2424
"""
25+
2526
from collections import defaultdict
2627
import operator
2728
from time import time
@@ -34,8 +35,6 @@
3435
from sklearn.feature_extraction.text import TfidfVectorizer
3536
from sklearn.metrics.cluster import v_measure_score
3637

37-
print(__doc__)
38-
3938

4039
def number_normalizer(tokens):
4140
"""Map all numeric tokens to a placeholder.

examples/bicluster/plot_spectral_biclustering.py

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
representation of the checkerboard structure.
1616
1717
"""
18-
print(__doc__)
1918

2019
# Author: Kemal Eren <kemal@kemaleren.com>
2120
# License: BSD 3 clause

examples/bicluster/plot_spectral_coclustering.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
the biclusters.
1515
1616
"""
17-
print(__doc__)
1817

1918
# Author: Kemal Eren <kemal@kemaleren.com>
2019
# License: BSD 3 clause

examples/calibration/plot_calibration.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
to the expected 0.5 for most of the samples belonging to the middle
2121
cluster with heterogeneous labels. This results in a significantly improved
2222
Brier score.
23+
2324
"""
24-
print(__doc__)
2525

2626
# Author: Mathieu Blondel <mathieu@mblondel.org>
2727
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>

examples/calibration/plot_calibration_curve.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
visualize how well calibrated the predicted probabilities are using calibration
1010
curves, also known as reliability diagrams. Calibration of an uncalibrated
1111
classifier will also be demonstrated.
12+
1213
"""
13-
print(__doc__)
14-
# %%
1514

15+
# %%
1616
# Author: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
1717
# Jan Hendrik Metzen <jhm@informatik.uni-bremen.de>
1818
# License: BSD 3 clause.

examples/calibration/plot_calibration_multiclass.py

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
classifier to the probability vectors predicted by the same classifier after
1111
sigmoid calibration on a hold-out validation set. Colors indicate the true
1212
class of an instance (red: class 1, green: class 2, blue: class 3).
13+
1314
"""
1415

1516
# %%

examples/calibration/plot_compare_calibration.py

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
models: :ref:`Logistic_regression`, :ref:`gaussian_naive_bayes`,
1414
:ref:`Random Forest Classifier <forest>` and :ref:`Linear SVM
1515
<svm_classification>`.
16+
1617
"""
1718

1819
# %%

examples/classification/plot_classification_probability.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
The logistic regression with One-Vs-Rest is not a multiclass classifier out of
1515
the box. As a result it has more trouble in separating class 2 and 3 than the
1616
other estimators.
17+
1718
"""
18-
print(__doc__)
1919

2020
# Author: Alexandre Gramfort <alexandre.gramfort@inria.fr>
2121
# License: BSD 3 clause

examples/classification/plot_classifier_comparison.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
The plots show training points in solid colors and testing points
1818
semi-transparent. The lower right shows the classification accuracy on the test
1919
set.
20-
"""
21-
print(__doc__)
2220
21+
"""
2322

2423
# Code source: Gaël Varoquaux
2524
# Andreas Müller

examples/classification/plot_digits_classification.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
66
This example shows how scikit-learn can be used to recognize images of
77
hand-written digits, from 0-9.
8-
"""
98
10-
print(__doc__)
9+
"""
1110

1211
# Author: Gael Varoquaux <gael dot varoquaux at normalesup dot org>
1312
# License: BSD 3 clause

examples/classification/plot_lda.py

+2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
66
This example illustrates how the Ledoit-Wolf and Oracle Shrinkage
77
Approximating (OAS) estimators of covariance can improve classification.
8+
89
"""
10+
911
import numpy as np
1012
import matplotlib.pyplot as plt
1113

examples/classification/plot_lda_qda.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
the double standard deviation for each class. With LDA, the
99
standard deviation is the same for all the classes, while each
1010
class has its own standard deviation with QDA.
11+
1112
"""
12-
print(__doc__)
1313

1414
from scipy import linalg
1515
import numpy as np

examples/cluster/plot_adjusted_for_chance_measures.py

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
value of k on various overlapping sub-samples of the dataset.
2121
2222
"""
23-
print(__doc__)
2423

2524
# Author: Olivier Grisel <olivier.grisel@ensta.org>
2625
# License: BSD 3 clause

examples/cluster/plot_affinity_propagation.py

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
Between Data Points", Science Feb. 2007
99
1010
"""
11-
print(__doc__)
1211

1312
from sklearn.cluster import AffinityPropagation
1413
from sklearn import metrics

examples/cluster/plot_agglomerative_clustering.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
(try decreasing the number of neighbors in kneighbors_graph) and with
2121
complete linkage. In particular, having a very small number of neighbors in
2222
the graph, imposes a geometry that is close to that of single linkage,
23-
which is well known to have this percolation instability. """
23+
which is well known to have this percolation instability.
24+
25+
"""
26+
2427
# Authors: Gael Varoquaux, Nelle Varoquaux
2528
# License: BSD 3 clause
2629

examples/cluster/plot_agglomerative_clustering_metrics.py

+2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
distance, the separation is good and the waveform classes are recovered.
3232
Finally, the cosine distance does not separate at all waveform 1 and 2,
3333
thus the clustering puts them in the same cluster.
34+
3435
"""
36+
3537
# Author: Gael Varoquaux
3638
# License: BSD 3-Clause or CC-0
3739

examples/cluster/plot_agglomerative_dendrogram.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
=========================================
77
This example plots the corresponding dendrogram of a hierarchical clustering
88
using AgglomerativeClustering and the dendrogram method available in scipy.
9+
910
"""
1011

1112
import numpy as np

examples/cluster/plot_birch_vs_minibatchkmeans.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
samples to a set of 158 clusters. This can be viewed as a preprocessing
1212
step before the final (global) clustering step that further reduces these
1313
158 clusters to 100 clusters.
14+
1415
"""
1516

1617
# Authors: Manoj Kumar <manojkumarsivaraj334@gmail.com
1718
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
1819
# License: BSD 3 clause
1920

20-
print(__doc__)
21-
2221
from itertools import cycle
2322
from time import time
2423
import numpy as np

examples/cluster/plot_cluster_comparison.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
While these examples give some intuition about the
2222
algorithms, this intuition might not apply to very high
2323
dimensional data.
24+
2425
"""
25-
print(__doc__)
2626

2727
import time
2828
import warnings

examples/cluster/plot_cluster_iris.py

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
and finally the ground truth.
1515
1616
"""
17-
print(__doc__)
18-
1917

2018
# Code source: Gaël Varoquaux
2119
# Modified for documentation by Jaques Grobler

examples/cluster/plot_coin_segmentation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
using a kmeans algorithm
1717
* whereas 'discrete' will iteratively search for the closest partition
1818
space to the embedding space.
19+
1920
"""
20-
print(__doc__)
2121

2222
# Author: Gael Varoquaux <gael.varoquaux@normalesup.org>, Brian Cheung
2323
# License: BSD 3 clause

examples/cluster/plot_coin_ward_segmentation.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
Compute the segmentation of a 2D image with Ward hierarchical
77
clustering. The clustering is spatially constrained in order
88
for each segmented region to be in one piece.
9+
910
"""
1011

1112
# Author : Vincent Michel, 2010
1213
# Alexandre Gramfort, 2011
1314
# License: BSD 3 clause
1415

15-
print(__doc__)
16-
1716
import time as time
1817

1918
import numpy as np

examples/cluster/plot_color_quantization.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
1818
For comparison, a quantized image using a random codebook (colors picked up
1919
randomly) is also shown.
20+
2021
"""
22+
2123
# Authors: Robert Layton <robertlayton@gmail.com>
2224
# Olivier Grisel <olivier.grisel@ensta.org>
2325
# Mathieu Blondel <mathieu@mblondel.org>
2426
#
2527
# License: BSD 3 clause
2628

27-
print(__doc__)
2829
import numpy as np
2930
import matplotlib.pyplot as plt
3031
from sklearn.cluster import KMeans

examples/cluster/plot_dbscan.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
Finds core samples of high density and expands clusters from them.
88
99
"""
10-
print(__doc__)
1110

1211
import numpy as np
1312

examples/cluster/plot_dict_face_patches.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
partial-fit. This is because the number of patches that they represent
1919
has become too low, and it is better to choose a random new
2020
cluster.
21+
2122
"""
22-
print(__doc__)
2323

2424
import time
2525

0 commit comments

Comments
 (0)