@@ -16,6 +16,7 @@ kernelspec:
1616:tags: [remove-cell]
1717from chapter_preamble import *
1818from IPython.display import HTML
19+ from IPython.display import Image
1920from sklearn.metrics.pairwise import euclidean_distances
2021import numpy as np
2122import plotly.express as px
@@ -281,6 +282,7 @@ perimeter and concavity variables. Recall that the default palette in `altair`
281282is colorblind-friendly, so we can stick with that here.
282283
283284``` {code-cell} ipython3
285+ :tags: ["remove-output"]
284286perim_concav = alt.Chart(cancer).mark_circle().encode(
285287 x=alt.X("Perimeter").title("Perimeter (standardized)"),
286288 y=alt.Y("Concavity").title("Concavity (standardized)"),
@@ -289,12 +291,16 @@ perim_concav = alt.Chart(cancer).mark_circle().encode(
289291perim_concav
290292```
291293
292- ``` {figure} data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
294+ ``` {code-cell} ipython3
295+ :tags: ["remove-cell"]
296+ glue("fig:05-scatter", perim_concav)
297+ ```
298+
299+ :::{glue: figure } fig:05-scatter
293300:name: fig:05-scatter
294- :figclass: caption-hack
295301
296302Scatter plot of concavity versus perimeter colored by diagnosis label.
297- ```
303+ :::
298304
299305+++
300306
@@ -855,7 +861,11 @@ for neighbor_df in neighbor_df_list:
855861# tight layout
856862fig.update_layout(margin=dict(l=0, r=0, b=0, t=1), template="plotly_white")
857863
858- glue("fig:05-more", fig)
864+ # if HTML, use the plotly 3d image; if PDF, use static image
865+ if "BOOK_BUILD_TYPE" in os.environ and os.environ["BOOK_BUILD_TYPE"] == "PDF":
866+ glue("fig:05-more", Image("img/classification1/plot3d_knn_classification.png"))
867+ else:
868+ glue("fig:05-more", fig)
859869```
860870
861871``` {figure} data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
@@ -1432,6 +1442,7 @@ The new imbalanced data is shown in {numref}`fig:05-unbalanced`,
14321442and we print the counts of the classes using the ` value_counts ` function.
14331443
14341444``` {code-cell} ipython3
1445+ :tags: ["remove-output"]
14351446rare_cancer = pd.concat((
14361447 cancer[cancer["Class"] == "Benign"],
14371448 cancer[cancer["Class"] == "Malignant"].head(3)
@@ -1445,12 +1456,16 @@ rare_plot = alt.Chart(rare_cancer).mark_circle().encode(
14451456rare_plot
14461457```
14471458
1448- ``` {figure} data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
1459+ ``` {code-cell} ipython3
1460+ :tags: ["remove-cell"]
1461+ glue("fig:05-unbalanced", rare_plot)
1462+ ```
1463+
1464+ :::{glue: figure } fig:05-unbalanced
14491465:name: fig:05-unbalanced
1450- :figclass: caption-hack
14511466
14521467Imbalanced data.
1453- ```
1468+ :::
14541469
14551470``` {code-cell} ipython3
14561471rare_cancer["Class"].value_counts()
@@ -1947,16 +1962,15 @@ unscaled_plot + prediction_plot
19471962```
19481963
19491964``` {code-cell} ipython3
1950- :tags: [remove-input ]
1965+ :tags: [remove-cell ]
19511966glue("fig:05-workflow-plot", (unscaled_plot + prediction_plot))
19521967```
19531968
1954- ``` { figure} data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
1969+ :::{glue : figure } fig:05-workflow-plot
19551970:name: fig:05-workflow-plot
1956- :figclass: caption-hack
19571971
19581972Scatter plot of smoothness versus area where background color indicates the decision of the classifier.
1959- ```
1973+ :::
19601974
19611975+++
19621976
@@ -1974,6 +1988,7 @@ found in {numref}`Chapter %s <move-to-your-own-machine>`. This will ensure that
19741988and guidance that the worksheets provide will function as intended.
19751989
19761990+++
1991+
19771992## References
19781993
19791994``` {bibliography}
0 commit comments