Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate pdf version of tutorial #58

Merged
merged 7 commits into from
Sep 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ addons:
- g++-4.9
- gfortran-4.9
- libgmp-dev
- pandoc

before_install:
- mkdir $HOME/bin
Expand All @@ -38,7 +39,7 @@ install:
- Rscript r_packs_install.R

script:
- ./build || ./build || ./build || ./build
- ./build

after_success:
- git checkout gh-pages
Expand All @@ -48,6 +49,7 @@ after_success:
- echo "https://$GH_TOKEN:@github.com" >> .git/credentials
- git config push.default matching
- git add devel
- git add mlr-tutorial.pdf
- git commit -a -m "update auto-generated tutorial pages [ci skip]"
- git push

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ Install dependencies:
* Add the new section to the pages configuration in `mkdocs.yml`.

### Include images
If you want to include an additional image in file `pic.png`:
* Put this file in subfolder `images/`.
* Add a symlink in directory `custom_theme/img/`: `pic.png -> ../../images/pic.png`.
* When including the image in the R markdown link to `img/pic.png`:
If you want to include an additional image in file `pic.png`:
* Put this file in subfolder `img/`.
* Add a symlink in directory `custom_theme/img/`: `pic.png -> ../../img/pic.png`.
* When including the image in the R markdown link to `img/pic.png`:
`![alt text](img/pic.png "Image Title")`

### Commit your changes
Expand Down
26 changes: 13 additions & 13 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ setSeed = function(x, algo = "crc32") {
}

# worker function
knitIt = function(f) {
knitIt = function(f, dev) {
messagef("Knitting file '%s' ...", f)
lines = readLines(file.path(src, f))
for (macro in macros)
lines = str_replace_all(lines, macro$pattern, macro$replacement)

cache.path = paste0(file.path("cache", f), .Platform$file.sep)
opts_chunk$set(cache = TRUE, cache.path = cache.path, dev = "svg", error = FALSE, comment = "#>", collapse = TRUE)
opts_chunk$set(cache = TRUE, cache.path = cache.path, fig.path = paste0(file.path("figure", str_replace(f, "\\.Rmd", "")), .Platform$file.sep), dev = dev, error = FALSE, comment = "#>", collapse = TRUE)
setSeed(f)
knit(
text = lines,
Expand Down Expand Up @@ -116,28 +116,28 @@ suppressPackageStartupMessages({

# turn warnings to errors, we don't want to miss them
options(warn = 2L)
# embed images in HTML
opts_knit$set(upload.fun = image_uri)
# number of spaces to indent the code is 2 (for chunks with tidy=TRUE)
opts_chunk$set(tidy.opts=list(indent=2, width.cutoff=80))
opts_chunk$set(tidy.opts = list(indent = 2, width.cutoff = 80))

# create output directory
if (!isDirectory("docs"))
dir.create("docs")

# do lapply for now. with mclapply it seems unclear how to stop best on error. this was 100% broken before
dummy = lapply(list.files(src, pattern = "\\.Rmd$"), knitIt)

# build docs with mkdocs
ok = system3("mkdocs", "build")
dummy = lapply(list.files(src, pattern = "\\.Rmd$"), knitIt, "pdf")
message("Building PDF version...")
ok = system3("./build-pdf.py")
if (ok$exit.code == 0L) {
message("Build successfull!")
# embed images in HTML
opts_knit$set(upload.fun = image_uri)
message("Building HTML version...")
dummy = lapply(list.files(src, pattern = "\\.Rmd$"), knitIt, "svg")
ok = system3("mkdocs", "build")
message("Build successful!")
message("Now zip everything!")
setwd("devel/html/")
suppressAll(zip("../mlr_tutorial.zip", files = "."))
setwd("../")
# clean up
unlink("figure", recursive = TRUE)
setwd("../../")
exit(0L)
}

Expand Down
64 changes: 64 additions & 0 deletions build-pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import sys

os.chdir("docs")
with open(os.path.join("..", "mlr-tutorial.md"), "w") as fd:
fd.write("""
---
title: mlr Tutorial
title-meta: mlr Tutorial
author:
- Julia Schiffner
- Bernd Bischl
- Michel Lang
- Jakob Richter
- Zachary M. Jones
- Philipp Probst
- Florian Pfisterer
- Mason Gallo
- Dominik Kirchhoff
- Tobias Kühn
- Lars Kotthoff
---
""")
with open(os.path.join("..", "mkdocs.yml"), "r") as fd2:
line = fd2.readline()
while line:
if('Appendix' in line):
break
elif('.md' in line):
m = re.search("[^']+\.md", line)
fname = m.group(0)
with open(fname, "r") as fd3:
for lin in fd3:
if fname != "index.md":
lin = re.sub(r'^(#+ [A-Za-z0-9])', '#\g<1>', lin)
fd.write(lin)
fd.write("\n")
if('index.md' in line):
fd.write("\n\n# Basics\n\n")
if('visualization.md' in line):
fd.write("\n\n# Advanced\n\n")
if('hyperpar_tuning_effects.md' in line):
fd.write("\n\n# Extend\n\n")
line = fd2.readline()
os.chdir("..")

def link_fixer(match):
file = match.group(1)
with open(os.path.join("docs", file), 'r') as fd:
return "(" + re.sub(' ', '-', re.sub(' ', '', fd.readline().rstrip(), 1)).lower() + ")"

with open('mlr-tutorial.md', 'r+') as fd:
data = fd.read()
out = re.sub(r'\(([a-zA-Z0-9_]+\.md)\)', link_fixer, data)
fd.seek(0)
fd.write(out)
fd.truncate()

retval = os.system("pandoc --number-sections --latex-engine=xelatex --variable colorlinks=\"true\" --listings -H latex-setup.tex --toc -f markdown+grid_tables+table_captions-implicit_figures -o mlr-tutorial.pdf mlr-tutorial.md")
if retval != 0:
sys.exit(1)
2 changes: 1 addition & 1 deletion custom_theme/img/mlrLogo_white_88x40.png
2 changes: 1 addition & 1 deletion custom_theme/img/nested_resampling.png
2 changes: 1 addition & 1 deletion custom_theme/img/resampling.png
Binary file added devel/html/__pycache__/__init__.cpython-35.pyc
Binary file not shown.
36 changes: 18 additions & 18 deletions devel/html/advanced_tune/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,12 @@ <h2 id="iterated-f-racing-for-mixed-spaces-and-dependencies">Iterated F-Racing f
#&gt; 5 -10.079158 polydot NA 5 0.06 1 NA
#&gt; 6 -10.643475 vanilladot NA NA 0.36 1 NA
#&gt; error.message exec.time
#&gt; 1 &lt;NA&gt; 0.039
#&gt; 2 &lt;NA&gt; 0.025
#&gt; 3 &lt;NA&gt; 0.024
#&gt; 4 &lt;NA&gt; 0.041
#&gt; 5 &lt;NA&gt; 0.040
#&gt; 6 &lt;NA&gt; 0.038
#&gt; 1 &lt;NA&gt; 0.049
#&gt; 2 &lt;NA&gt; 0.024
#&gt; 3 &lt;NA&gt; 0.025
#&gt; 4 &lt;NA&gt; 0.025
#&gt; 5 &lt;NA&gt; 0.024
#&gt; 6 &lt;NA&gt; 0.024
</code></pre>

<p>See how we made the kernel parameters like <code>sigma</code> and <code>degree</code> dependent on the <code>kernel</code>
Expand Down Expand Up @@ -435,12 +435,12 @@ <h2 id="tuning-across-whole-model-spaces-with-modelmultiplexer">Tuning across wh
#&gt; 5 classif.ksvm -1.884101 NA
#&gt; 6 classif.ksvm 4.388728 NA
#&gt; mmce.test.mean dob eol error.message exec.time
#&gt; 1 0.6466667 1 NA &lt;NA&gt; 0.042
#&gt; 2 0.1400000 1 NA &lt;NA&gt; 0.042
#&gt; 3 0.0400000 1 NA &lt;NA&gt; 0.059
#&gt; 4 0.0400000 1 NA &lt;NA&gt; 0.034
#&gt; 5 0.0400000 1 NA &lt;NA&gt; 0.042
#&gt; 6 0.3333333 1 NA &lt;NA&gt; 0.042
#&gt; 1 0.6466667 1 NA &lt;NA&gt; 0.047
#&gt; 2 0.1400000 1 NA &lt;NA&gt; 0.044
#&gt; 3 0.0400000 1 NA &lt;NA&gt; 0.063
#&gt; 4 0.0400000 1 NA &lt;NA&gt; 0.036
#&gt; 5 0.0400000 1 NA &lt;NA&gt; 0.043
#&gt; 6 0.3333333 1 NA &lt;NA&gt; 0.044
</code></pre>

<h2 id="multi-criteria-evaluation-and-optimization">Multi-criteria evaluation and optimization</h2>
Expand Down Expand Up @@ -473,12 +473,12 @@ <h2 id="multi-criteria-evaluation-and-optimization">Multi-criteria evaluation an
#&gt; 5 5.203364e+00 2.781734e-03 0.1515152 0.1621622 5 NA
#&gt; 6 5.638243e-04 7.956946e+02 1.0000000 0.0000000 6 NA
#&gt; error.message exec.time
#&gt; 1 &lt;NA&gt; 0.067
#&gt; 2 &lt;NA&gt; 0.069
#&gt; 3 &lt;NA&gt; 0.069
#&gt; 4 &lt;NA&gt; 0.071
#&gt; 5 &lt;NA&gt; 0.067
#&gt; 6 &lt;NA&gt; 0.064
#&gt; 1 &lt;NA&gt; 0.042
#&gt; 2 &lt;NA&gt; 0.043
#&gt; 3 &lt;NA&gt; 0.043
#&gt; 4 &lt;NA&gt; 0.044
#&gt; 5 &lt;NA&gt; 0.042
#&gt; 6 &lt;NA&gt; 0.043
</code></pre>

<p>The results can be visualized with function <a href="http://www.rdocumentation.org/packages/mlr/functions/plotTuneMultiCritResult.html">plotTuneMultiCritResult</a>.
Expand Down
84 changes: 41 additions & 43 deletions devel/html/benchmark_experiments/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions devel/html/classifier_calibration/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion devel/html/configureMlr/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ <h2 id="example-handling-errors-in-a-learning-method">Example: Handling errors i
<pre><code class="r">## This call gives an error caused by the low number of observations in class &quot;virginica&quot;
train(&quot;classif.qda&quot;, task = iris.task, subset = 1:104)
#&gt; Error in qda.default(x, grouping, ...): some group is too small for 'qda'
#&gt; Timing stopped at: 0.004 0 0.004
#&gt; Timing stopped at: 0.003 0 0.003

## Get a warning instead of an error
configureMlr(on.learner.error = &quot;warn&quot;)
Expand Down
18 changes: 9 additions & 9 deletions devel/html/cost_sensitive_classif/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion devel/html/create_filter/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ <h2 id="filter-objects">Filter objects</h2>
#&gt; y = FSelector::rank.correlation(getTaskFormula(task), data = getTaskData(task))
#&gt; setNames(y[[&quot;attr_importance&quot;]], getTaskFeatureNames(task))
#&gt; }
#&gt; &lt;bytecode: 0x9c89308&gt;
#&gt; &lt;bytecode: 0x8000410&gt;
#&gt; &lt;environment: namespace:mlr&gt;
</code></pre>

Expand Down
8 changes: 4 additions & 4 deletions devel/html/create_measure/index.html

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions devel/html/feature_selection/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -499,19 +499,19 @@ <h3 id="tuning-the-size-of-the-feature-subset">Tuning the size of the feature su
#&gt; With control class: TuneControlGrid
#&gt; Imputation value: Inf
#&gt; [Tune-x] 1: fw.perc=0.2
#&gt; [Tune-y] 1: mse.test.mean=40.6; time: 0.0 min; memory: 131Mb use, 645Mb max
#&gt; [Tune-y] 1: mse.test.mean=40.6; time: 0.0 min; memory: 131Mb use, 623Mb max
#&gt; [Tune-x] 2: fw.perc=0.25
#&gt; [Tune-y] 2: mse.test.mean=40.6; time: 0.0 min; memory: 131Mb use, 645Mb max
#&gt; [Tune-y] 2: mse.test.mean=40.6; time: 0.0 min; memory: 131Mb use, 623Mb max
#&gt; [Tune-x] 3: fw.perc=0.3
#&gt; [Tune-y] 3: mse.test.mean=37.1; time: 0.0 min; memory: 131Mb use, 645Mb max
#&gt; [Tune-y] 3: mse.test.mean=37.1; time: 0.0 min; memory: 131Mb use, 623Mb max
#&gt; [Tune-x] 4: fw.perc=0.35
#&gt; [Tune-y] 4: mse.test.mean=35.8; time: 0.0 min; memory: 131Mb use, 645Mb max
#&gt; [Tune-y] 4: mse.test.mean=35.8; time: 0.0 min; memory: 131Mb use, 623Mb max
#&gt; [Tune-x] 5: fw.perc=0.4
#&gt; [Tune-y] 5: mse.test.mean=35.8; time: 0.0 min; memory: 131Mb use, 645Mb max
#&gt; [Tune-y] 5: mse.test.mean=35.8; time: 0.0 min; memory: 131Mb use, 623Mb max
#&gt; [Tune-x] 6: fw.perc=0.45
#&gt; [Tune-y] 6: mse.test.mean=27.4; time: 0.0 min; memory: 131Mb use, 645Mb max
#&gt; [Tune-y] 6: mse.test.mean=27.4; time: 0.0 min; memory: 131Mb use, 623Mb max
#&gt; [Tune-x] 7: fw.perc=0.5
#&gt; [Tune-y] 7: mse.test.mean=27.4; time: 0.0 min; memory: 131Mb use, 645Mb max
#&gt; [Tune-y] 7: mse.test.mean=27.4; time: 0.0 min; memory: 131Mb use, 623Mb max
#&gt; [Tune] Result: fw.perc=0.5 : mse.test.mean=27.4
res
#&gt; Tune result:
Expand All @@ -522,13 +522,13 @@ <h3 id="tuning-the-size-of-the-feature-subset">Tuning the size of the feature su
<p>The performance of all percentage values visited during tuning is:</p>
<pre><code class="r">as.data.frame(res$opt.path)
#&gt; fw.perc mse.test.mean dob eol error.message exec.time
#&gt; 1 0.2 40.59578 1 NA &lt;NA&gt; 0.199
#&gt; 2 0.25 40.59578 2 NA &lt;NA&gt; 0.194
#&gt; 3 0.3 37.05592 3 NA &lt;NA&gt; 0.193
#&gt; 4 0.35 35.83712 4 NA &lt;NA&gt; 0.194
#&gt; 5 0.4 35.83712 5 NA &lt;NA&gt; 0.195
#&gt; 6 0.45 27.39955 6 NA &lt;NA&gt; 0.190
#&gt; 7 0.5 27.39955 7 NA &lt;NA&gt; 0.192
#&gt; 1 0.2 40.59578 1 NA &lt;NA&gt; 0.240
#&gt; 2 0.25 40.59578 2 NA &lt;NA&gt; 0.267
#&gt; 3 0.3 37.05592 3 NA &lt;NA&gt; 0.271
#&gt; 4 0.35 35.83712 4 NA &lt;NA&gt; 0.314
#&gt; 5 0.4 35.83712 5 NA &lt;NA&gt; 0.278
#&gt; 6 0.45 27.39955 6 NA &lt;NA&gt; 0.229
#&gt; 7 0.5 27.39955 7 NA &lt;NA&gt; 0.237
</code></pre>

<p>The optimal percentage and the corresponding performance can be accessed as follows:</p>
Expand Down Expand Up @@ -571,12 +571,12 @@ <h3 id="tuning-the-size-of-the-feature-subset">Tuning the size of the feature su
#&gt; Points on front: 13
head(as.data.frame(res$opt.path))
#&gt; fw.threshold fpr.test.mean fnr.test.mean dob eol error.message exec.time
#&gt; 1 0.4892321 0.3092818 0.2639033 1 NA &lt;NA&gt; 1.914
#&gt; 2 0.2481696 0.2045499 0.2319697 2 NA &lt;NA&gt; 1.937
#&gt; 3 0.7691875 0.5128000 0.3459740 3 NA &lt;NA&gt; 1.824
#&gt; 4 0.1470133 0.2045499 0.2319697 4 NA &lt;NA&gt; 1.922
#&gt; 5 0.5958241 0.5028216 0.5239538 5 NA &lt;NA&gt; 1.816
#&gt; 6 0.6892421 0.6323959 0.4480808 6 NA &lt;NA&gt; 1.826
#&gt; 1 0.4892321 0.3092818 0.2639033 1 NA &lt;NA&gt; 2.991
#&gt; 2 0.2481696 0.2045499 0.2319697 2 NA &lt;NA&gt; 2.778
#&gt; 3 0.7691875 0.5128000 0.3459740 3 NA &lt;NA&gt; 2.035
#&gt; 4 0.1470133 0.2045499 0.2319697 4 NA &lt;NA&gt; 2.023
#&gt; 5 0.5958241 0.5028216 0.5239538 5 NA &lt;NA&gt; 1.835
#&gt; 6 0.6892421 0.6323959 0.4480808 6 NA &lt;NA&gt; 2.022
</code></pre>

<p>The results can be visualized with function <a href="http://www.rdocumentation.org/packages/mlr/functions/plotTuneMultiCritResult.html">plotTuneMultiCritResult</a>.
Expand Down
40 changes: 20 additions & 20 deletions devel/html/hyperpar_tuning_effects/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -414,14 +414,14 @@ <h2 id="generating-hyperparameter-tuning-data">Generating hyperparameter tuning
#&gt; Measures: acc.test.mean,mmce.test.mean
#&gt; Optimizer: TuneControlRandom
#&gt; Nested CV Used: FALSE
#&gt; Snapshot of data:
#&gt; Snapshot of $data:
#&gt; C acc.test.mean mmce.test.mean iteration exec.time
#&gt; 1 0.3770897 0.7695312 0.2304688 1 0.074
#&gt; 1 0.3770897 0.7695312 0.2304688 1 0.065
#&gt; 2 3.4829323 0.7526042 0.2473958 2 0.065
#&gt; 3 2.2050176 0.7630208 0.2369792 3 0.066
#&gt; 4 24.9285221 0.7070312 0.2929688 4 0.073
#&gt; 5 0.2092395 0.7539062 0.2460938 5 0.067
#&gt; 6 0.1495099 0.7395833 0.2604167 6 0.068
#&gt; 3 2.2050176 0.7630208 0.2369792 3 0.064
#&gt; 4 24.9285221 0.7070312 0.2929688 4 0.074
#&gt; 5 0.2092395 0.7539062 0.2460938 5 0.066
#&gt; 6 0.1495099 0.7395833 0.2604167 6 0.066
</code></pre>

<p>As a reminder from the <a href="../resample/index.html">resampling</a> tutorial, if we wanted to generate data on
Expand All @@ -440,7 +440,7 @@ <h2 id="generating-hyperparameter-tuning-data">Generating hyperparameter tuning
#&gt; Measures: acc.test.mean,acc.train.mean,mmce.test.mean,mmce.train.mean
#&gt; Optimizer: TuneControlRandom
#&gt; Nested CV Used: FALSE
#&gt; Snapshot of data:
#&gt; Snapshot of $data:
#&gt; C acc.test.mean acc.train.mean mmce.test.mean mmce.train.mean
#&gt; 1 0.03518875 0.6510417 0.6510417 0.3489583 0.3489583
#&gt; 2 0.17104229 0.7356771 0.7721354 0.2643229 0.2278646
Expand All @@ -449,12 +449,12 @@ <h2 id="generating-hyperparameter-tuning-data">Generating hyperparameter tuning
#&gt; 5 1.28168692 0.7500000 0.8476562 0.2500000 0.1523438
#&gt; 6 7.36607693 0.7239583 0.8932292 0.2760417 0.1067708
#&gt; iteration exec.time
#&gt; 1 1 0.093
#&gt; 2 2 0.094
#&gt; 3 3 0.091
#&gt; 4 4 0.092
#&gt; 5 5 0.089
#&gt; 6 6 0.091
#&gt; 1 1 0.092
#&gt; 2 2 0.089
#&gt; 3 3 0.088
#&gt; 4 4 0.089
#&gt; 5 5 0.090
#&gt; 6 6 0.088
</code></pre>

<p>In the example below, we perform grid search on the <code>C</code> parameter for SVM on the Pima Indians
Expand All @@ -476,14 +476,14 @@ <h2 id="generating-hyperparameter-tuning-data">Generating hyperparameter tuning
#&gt; Measures: acc.test.mean,mmce.test.mean
#&gt; Optimizer: TuneControlGrid
#&gt; Nested CV Used: TRUE
#&gt; Snapshot of data:
#&gt; Snapshot of $data:
#&gt; C acc.test.mean mmce.test.mean iteration exec.time
#&gt; 1 -5.0000000 0.6640625 0.3359375 1 0.049
#&gt; 2 -3.8888889 0.6640625 0.3359375 2 0.049
#&gt; 3 -2.7777778 0.6822917 0.3177083 3 0.049
#&gt; 4 -1.6666667 0.7473958 0.2526042 4 0.049
#&gt; 5 -0.5555556 0.7708333 0.2291667 5 0.050
#&gt; 6 0.5555556 0.7682292 0.2317708 6 0.050
#&gt; 1 -5.0000000 0.6640625 0.3359375 1 0.087
#&gt; 2 -3.8888889 0.6640625 0.3359375 2 0.086
#&gt; 3 -2.7777778 0.6822917 0.3177083 3 0.085
#&gt; 4 -1.6666667 0.7473958 0.2526042 4 0.087
#&gt; 5 -0.5555556 0.7708333 0.2291667 5 0.084
#&gt; 6 0.5555556 0.7682292 0.2317708 6 0.085
#&gt; nested_cv_run
#&gt; 1 1
#&gt; 2 1
Expand Down
2 changes: 1 addition & 1 deletion devel/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -437,5 +437,5 @@ <h4 class="modal-title" id="exampleModalLabel">Search</h4>

<!--
MkDocs version : 0.15.3
Build Date UTC : 2016-09-15 10:44:20.978412
Build Date UTC : 2016-08-30 12:32:08.083858
-->
Loading