Skip to content

Commit

Permalink
Rename perfect into optimal (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
J535D165 authored Sep 28, 2024
1 parent a552978 commit be66b05
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ with open_state("example.asreview") as s:
![Recall with absolute
axes](https://github.com/asreview/asreview-insights/blob/main/docs/example_absolute_axes.png)

#### Example: Adjusting the Random and Perfect curves
#### Example: Adjusting the random and optimal recalls

By default, each plot will have a curve representing perfect performance, and a
By default, each plot will have a curve representing optimal performance, and a
curve representing random sampling performance. Both curves can be removed from
the graph.

Expand All @@ -380,7 +380,7 @@ from asreviewcontrib.insights.plot import plot_recall
with open_state("example.asreview") as s:

fig, ax = plt.subplots()
plot_recall(ax, s, show_random=False, show_perfect=False)
plot_recall(ax, s, show_random=False, show_optimal=False)

fig.savefig("example_without_curves.png")
```
Expand Down
22 changes: 11 additions & 11 deletions asreviewcontrib/insights/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def plot_recall(
x_absolute=False,
y_absolute=False,
show_random=True,
show_perfect=True,
show_optimal=True,
show_legend=True,
legend_values=None,
legend_kwargs=None,
Expand All @@ -35,8 +35,8 @@ def plot_recall(
If False, the fraction of all included records found is on the y-axis.
show_random: bool
Show the random curve in the plot.
show_perfect: bool
Show the perfect curve in the plot.
show_optimal: bool
Show the optimal recall in the plot.
show_legend: bool
If state_obj contains multiple states, show a legend in the plot.
legend_values: list[str]
Expand Down Expand Up @@ -64,7 +64,7 @@ def plot_recall(
x_absolute=x_absolute,
y_absolute=y_absolute,
show_random=show_random,
show_perfect=show_perfect,
show_optimal=show_optimal,
show_legend=show_legend,
legend_values=legend_values,
legend_kwargs=legend_kwargs,
Expand Down Expand Up @@ -241,7 +241,7 @@ def _plot_recall(
x_absolute=False,
y_absolute=False,
show_random=True,
show_perfect=True,
show_optimal=True,
show_legend=True,
legend_values=None,
legend_kwargs=None,
Expand All @@ -265,8 +265,8 @@ def _plot_recall(
if show_random:
ax = _add_random_curve(ax, labels, x_absolute, y_absolute)

if show_perfect:
ax = _add_perfect_curve(ax, labels, x_absolute, y_absolute)
if show_optimal:
ax = _add_optimal_recall(ax, labels, x_absolute, y_absolute)

if show_legend:
if legend_kwargs is None:
Expand Down Expand Up @@ -406,13 +406,13 @@ def _add_random_curve(ax, labels, x_absolute, y_absolute):
return ax


def _add_perfect_curve(ax, labels, x_absolute, y_absolute):
"""Add a perfect curve to a plot using step-wise increments.
def _add_optimal_recall(ax, labels, x_absolute, y_absolute):
"""Add a optimal recall to a plot using step-wise increments.
Returns
-------
plt.axes.Axes
Axes with perfect curve added.
Axes with optimal recall added.
"""
# get total amount of positive labels
if isinstance(labels[0], list):
Expand All @@ -434,7 +434,7 @@ def _add_perfect_curve(ax, labels, x_absolute, y_absolute):
else np.arange(0, n_pos_docs + 1) / n_pos_docs
)

# Plot the stepwise perfect curve
# Plot the stepwise optimal recall
ax.step(x, y, color="grey", where="post")

return ax
Expand Down
2 changes: 1 addition & 1 deletion docs/example_multiple_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
plot_recall(ax, s2)

# Set the labels for the legend. Both plots add the recall line, the random
# curve, and the perfect curve. Hence the recall lines are the 0th and 3nd line.
# curve, and the optimal recall. Hence the recall lines are the 0th and 3nd line.
ax.lines[0].set_label("Naive Bayes")
ax.lines[3].set_label("Logistic")
ax.legend()
Expand Down
2 changes: 1 addition & 1 deletion docs/example_without_curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

with open_state("tests/asreview_files/sim_van_de_schoot_2017_logistic.asreview") as s:
fig, ax = plt.subplots()
plot_recall(ax, s, show_random=False, show_perfect=False)
plot_recall(ax, s, show_random=False, show_optimal=False)

fig.savefig("docs/example_without_curves.png")

0 comments on commit be66b05

Please sign in to comment.