Skip to content

Instantly share code, notes, and snippets.

@taroyabuki
Last active May 20, 2021 17:39
Show Gist options
  • Save taroyabuki/ecb0da01ab85e0a0524383b97d17ae0f to your computer and use it in GitHub Desktop.
Save taroyabuki/ecb0da01ab85e0a0524383b97d17ae0f to your computer and use it in GitHub Desktop.
(ad hoc)『解釈可能な機械学習/Interpretable Machine Learning』日本語訳のPDF版を作る.(要Docker)
# usage:
# wget https://gist.githubusercontent.com/taroyabuki/ecb0da01ab85e0a0524383b97d17ae0f/raw/dc962ef5e8b13bfc2aa7b1bcea2edba7918cfd10/makepdf.sh
# docker run -it -e ROOT=TRUE -v $(pwd):/home/rstudio/work rocker/verse bash /home/rstudio/work/makepdf.sh
cd /home/rstudio/work
git clone -b japanese https://github.com/hacarus/interpretable-ml-book-ja.git
cd interpretable-ml-book-ja
Rscript -e 'install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/"); pak::pkg_install(c("R.utils","tm","mlr","mlbench","partykit","randomForest","gridExtra","jpeg","caret","e1071","svglite","mmpf","numDeriv","DT","xgboost","pre","gridExtra","OneR","RWeka","iml","jtools","Cairo","viridis","interactions","rjson","png","yaImpute","arules","party","magick"));'
Rscript scripts/prepare_data.R
cd manuscript
make 11-references.Rmd
#make html
#make epub
tlmgr update --self
tlmgr install luatexja haranoaji
cat << EOS >> _output.yml
bookdown::pdf_book:
latex_engine: lualatex
extra_dependencies: ["luatexja-preset"]
EOS
sed -i -e 's/fontsize: 12pt/fontsize: 10pt/' index.Rmd
sed -i -e 's/m\^2\^/$m\^2$/' 05.9-agnostic-shapley.Rmd
make pdf
sed -i -e 's/\\\[\\begin{align\*}/\\begin{align\*}/' interpretable-ml.tex
sed -i -e 's/\\end{align\*}\\]/\\end{align\*}/' interpretable-ml.tex
sed -i -e 's/Bau & Zhou/Bau \\\& Zhou/' interpretable-ml.tex
sed -i -e 's/includegraphics\[width=[0-9\.]*in\]/includegraphics[width=\\textwidth]/' interpretable-ml.tex
sed -i -e 's/includegraphics\[width=[0-9]*px\]/includegraphics[width=\\textwidth]/' interpretable-ml.tex
sed -i -e 's/\\textbackslash begin\\{figure\\}/\\begin{figure}/' interpretable-ml.tex
sed -i -e 's/\\textbackslash end\\{figure\\}/\\end{figure}/' interpretable-ml.tex
sed -i -e 's/\\textbackslash caption\\{\(.*\)\\}/\\caption{\1}/' interpretable-ml.tex
lualatex interpretable-ml
cp interpretable-ml.pdf /home/rstudio/work/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment