Skip to content

Commit 04ccce5

Browse files
authored
DOC fixes some documentation glitches (#876)
1 parent 67d2122 commit 04ccce5

11 files changed

+30
-17
lines changed

build_tools/circle/build_doc.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ make_args="SPHINXOPTS=-T $make_args" # show full traceback on exception
7878
# Installing required system packages to support the rendering of math
7979
# notation in the HTML documentation and to optimize the image files
8080
sudo -E apt-get -yq update --allow-releaseinfo-change
81+
sudo -E apt-get -yq remove texlive-binaries --purge
8182
sudo -E apt-get -yq --no-install-suggests --no-install-recommends \
82-
install dvipng gsfonts ccache zip optipng
83+
install dvipng texlive-latex-base texlive-latex-extra \
84+
texlive-latex-recommended texlive-fonts-recommended \
85+
latexmk gsfonts ccache zip optipng
8386

8487
# deactivate circleci virtualenv and setup a miniconda env instead
8588
if [[ `type -t deactivate` ]]; then

examples/api/plot_sampling_strategy_usage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
ros = RandomOverSampler(sampling_strategy=sampling_strategy)
113113
X_res, y_res = ros.fit_resample(X, y)
114114
y_res.value_counts().plot.pie(autopct=autopct, ax=axs[1])
115-
axs[1].set_title("Over-sampling")
115+
_ = axs[1].set_title("Over-sampling")
116116

117117
# %% [markdown]
118118
# With **cleaning method**, the number of samples in each class will not be
@@ -122,7 +122,7 @@
122122
from imblearn.under_sampling import TomekLinks
123123

124124
sampling_strategy = "not minority"
125-
tl = TomekLinks(sampling_strategy)
125+
tl = TomekLinks(sampling_strategy=sampling_strategy)
126126
X_res, y_res = tl.fit_resample(X, y)
127127
ax = y_res.value_counts().plot.pie(autopct=autopct)
128128
_ = ax.set_title("Cleaning")
@@ -149,7 +149,7 @@
149149
ros = RandomOverSampler(sampling_strategy=sampling_strategy)
150150
X_res, y_res = ros.fit_resample(X, y)
151151
y_res.value_counts().plot.pie(autopct=autopct, ax=axs[1])
152-
axs[1].set_title("Under-sampling")
152+
_ = axs[1].set_title("Under-sampling")
153153

154154
# %% [markdown]
155155
# `sampling_strategy` as a `list`

examples/applications/plot_over_sampling_benchmark_lfw.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
george_bush_id = 1871 # Photos of George W. Bush
3838
bill_clinton_id = 531 # Photos of Bill Clinton
3939
classes = [george_bush_id, bill_clinton_id]
40-
classes_name = np.array(["B. Clinton", "G.W. Bush"], dtype=np.object)
40+
classes_name = np.array(["B. Clinton", "G.W. Bush"], dtype=object)
4141

4242
# %%
4343
mask_photos = np.isin(data.target, classes)
@@ -49,12 +49,14 @@
4949
# We can check the ratio between the two classes.
5050

5151
# %%
52+
import matplotlib.pyplot as plt
5253
import pandas as pd
5354

5455
class_distribution = pd.Series(y).value_counts(normalize=True)
5556
ax = class_distribution.plot.barh()
5657
ax.set_title("Class distribution")
5758
pos_label = class_distribution.idxmin()
59+
plt.tight_layout()
5860
print(f"The positive label considered as the minority class is {pos_label}")
5961

6062
# %% [markdown]
@@ -96,7 +98,6 @@
9698
# cross-validation.
9799

98100
# %%
99-
import matplotlib.pyplot as plt
100101
from sklearn.metrics import RocCurveDisplay, roc_curve, auc
101102

102103
disp = []
@@ -139,10 +140,11 @@
139140
d.plot(ax=ax, linestyle="--")
140141
ax.plot([0, 1], [0, 1], linestyle="--", color="k")
141142
ax.axis("square")
142-
fig.suptitle("Comparison of over-sampling methods with a 3NN classifier")
143+
fig.suptitle("Comparison of over-sampling methods \nwith a 3NN classifier")
143144
ax.set_xlim([0, 1])
144145
ax.set_ylim([0, 1])
145146
sns.despine(offset=10, ax=ax)
147+
plt.tight_layout()
146148
plt.show()
147149

148150
# %% [markdown]

examples/applications/plot_topic_classication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
print(f"Training class distributions summary: {Counter(y_train)}")
5050
print(f"Test class distributions summary: {Counter(y_test)}")
5151

52-
# % [markdown]
52+
# %% [markdown]
5353
# The usual scikit-learn pipeline
5454
# -------------------------------
5555
#

examples/combine/plot_comparison_combine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
# %%
4848
_, ax = plt.subplots(figsize=(6, 6))
49-
ax.scatter(X[:, 0], X[:, 1], c=y, alpha=0.8, edgecolor="k")
49+
_ = ax.scatter(X[:, 0], X[:, 1], c=y, alpha=0.8, edgecolor="k")
5050

5151
# %% [markdown]
5252
# The following function will be used to plot the sample space after resampling

examples/datasets/plot_make_imbalance.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
# original dataset.
3030

3131
# %%
32+
import matplotlib.pyplot as plt
3233
import pandas as pd
3334
from sklearn.datasets import make_moons
3435

@@ -42,6 +43,7 @@
4243
colorbar=False,
4344
)
4445
sns.despine(ax=ax, offset=10)
46+
plt.tight_layout()
4547

4648
# %% [markdown]
4749
# Make a dataset imbalanced
@@ -61,7 +63,6 @@ def ratio_func(y, multiplier, minority_class):
6163

6264

6365
# %%
64-
import matplotlib.pyplot as plt
6566
from imblearn.datasets import make_imbalance
6667

6768
fig, axs = plt.subplots(nrows=2, ncols=3, figsize=(15, 10))

examples/evaluation/plot_classification_report.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515

1616
from sklearn import datasets
17+
from sklearn.preprocessing import StandardScaler
1718
from sklearn.svm import LinearSVC
1819
from sklearn.model_selection import train_test_split
1920

@@ -40,7 +41,9 @@
4041
)
4142

4243
pipeline = pl.make_pipeline(
43-
os.SMOTE(random_state=RANDOM_STATE), LinearSVC(random_state=RANDOM_STATE)
44+
StandardScaler(),
45+
os.SMOTE(random_state=RANDOM_STATE),
46+
LinearSVC(max_iter=10_000, random_state=RANDOM_STATE),
4447
)
4548

4649
# Split the data

examples/evaluation/plot_metrics.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@
5252

5353
# %%
5454
from imblearn.pipeline import make_pipeline
55+
from sklearn.preprocessing import StandardScaler
5556
from imblearn.over_sampling import SMOTE
5657
from sklearn.svm import LinearSVC
5758

5859
model = make_pipeline(
59-
SMOTE(random_state=RANDOM_STATE), LinearSVC(random_state=RANDOM_STATE)
60+
StandardScaler(),
61+
SMOTE(random_state=RANDOM_STATE),
62+
LinearSVC(max_iter=10_000, random_state=RANDOM_STATE),
6063
)
6164

6265
# %% [markdown]

examples/model_selection/plot_validation_curve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,5 @@
118118
ax.set_xlim([1, 10])
119119
ax.set_ylim([0.4, 0.8])
120120
ax.legend(loc="lower right")
121-
121+
plt.tight_layout()
122122
plt.show()

examples/under-sampling/plot_comparison_under_sampling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ def plot_decision_function(X, y, clf, ax, title=None):
266266
for ax, sampler in zip(axs, samplers):
267267
model = make_pipeline(sampler, clf).fit(X, y)
268268
plot_decision_function(
269-
X, y, clf, ax[0], title=f"Decision function for {sampler.__class__.__name__}"
269+
X, y, clf, ax[0], title=f"Decision function for \n{sampler.__class__.__name__}"
270270
)
271271
plot_resampling(
272-
X, y, sampler, ax[1], title=f"Resampling using {sampler.__class__.__name__}"
272+
X, y, sampler, ax[1], title=f"Resampling using \n{sampler.__class__.__name__}"
273273
)
274274
fig.tight_layout()
275275

0 commit comments

Comments
 (0)