Skip to content

Commit

Permalink
generate pdf version of tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Kotthoff committed Aug 29, 2016
1 parent 268e4cf commit 06c1427
Show file tree
Hide file tree
Showing 61 changed files with 1,173 additions and 1,177 deletions.
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Install dependencies:

### 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`.
* 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")`

Expand Down
24 changes: 12 additions & 12 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, dev = dev, error = FALSE, comment = "#>", collapse = TRUE)
setSeed(f)
knit(
text = lines,
Expand Down Expand Up @@ -116,8 +116,6 @@ 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))

Expand All @@ -126,18 +124,20 @@ 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
25 changes: 25 additions & 0 deletions build-pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python
import os
import re
import sys

os.chdir("docs")
os.system("echo -e '---\ntitle: mlr Tutorial\n---' > ../mlr-tutorial.md")
os.system("for f in `grep -o \"[^']\+\.md\" ../mkdocs.yml`; do (cat \"${f}\"; echo) >> ../mlr-tutorial.md; done")
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 file:
data = file.read()
out = re.sub(r'\(([a-zA-Z0-9_]+\.md)\)', link_fixer, data)
file.seek(0)
file.write(out)
file.truncate()

retval = os.system("pandoc --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
38 changes: 19 additions & 19 deletions devel/html/advanced_tune/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion devel/html/bagging/index.html

Large diffs are not rendered by default.

80 changes: 40 additions & 40 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.

22 changes: 11 additions & 11 deletions devel/html/cost_sensitive_classif/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions devel/html/create_filter/index.html

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions devel/html/feature_selection/index.html

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions devel/html/hyperpar_tuning_effects/index.html

Large diffs are not rendered by default.

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-08-25 19:03:40.119325
Build Date UTC : 2016-08-29 05:12:46.110878
-->
3 changes: 0 additions & 3 deletions devel/html/learner/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,6 @@ <h2 id="modifying-a-learner">Modifying a learner</h2>
Here are some examples.</p>
<pre><code class="r">## Change the ID
surv.lrn = setId(surv.lrn, &quot;CoxModel&quot;)
#&gt; Warning: 'setId' is deprecated.
#&gt; Use 'setLearnerId' instead.
#&gt; See help(&quot;Deprecated&quot;)
surv.lrn
#&gt; Learner CoxModel from package survival
#&gt; Type: surv
Expand Down
6 changes: 3 additions & 3 deletions devel/html/learning_curve/index.html

Large diffs are not rendered by default.

42 changes: 0 additions & 42 deletions devel/html/measures/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -933,20 +933,6 @@ <h3 id="regression">Regression</h3>
<td align="left"></td>
</tr>
<tr>
<td align="left"><strong><a href="http://www.rdocumentation.org/packages/mlr/functions/measures.html">mape</a></strong> <br />Mean absolute percentage error</td>
<td align="center">X</td>
<td align="right">0</td>
<td align="right">Inf</td>
<td align="center">X</td>
<td align="center">X</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="left"><a href="http://www.rdocumentation.org/packages/mlr/functions/aggregations.html">test.mean</a></td>
<td align="left">Defined as the abs(truth_i - response_i)/truth_i. Won't work if any truth value is equal to zero. In this case the output will be NA.</td>
</tr>
<tr>
<td align="left"><strong><a href="http://www.rdocumentation.org/packages/mlr/functions/measures.html">medae</a></strong> <br />Median of absolute errors</td>
<td align="center">X</td>
<td align="right">0</td>
Expand Down Expand Up @@ -989,20 +975,6 @@ <h3 id="regression">Regression</h3>
<td align="left"></td>
</tr>
<tr>
<td align="left"><strong><a href="http://www.rdocumentation.org/packages/mlr/functions/measures.html">rae</a></strong> <br />Relative absolute error</td>
<td align="center">X</td>
<td align="right">0</td>
<td align="right">Inf</td>
<td align="center">X</td>
<td align="center">X</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="left"><a href="http://www.rdocumentation.org/packages/mlr/functions/aggregations.html">test.mean</a></td>
<td align="left">Defined as sum_of_absolute_errors / mean_absolute_deviation. Undefined for single instances and when every truth value is identical. In this case the output will be NA.</td>
</tr>
<tr>
<td align="left"><strong><a href="http://www.rdocumentation.org/packages/mlr/functions/measures.html">rmse</a></strong> <br />Root mean square error</td>
<td align="center">X</td>
<td align="right">0</td>
Expand All @@ -1017,20 +989,6 @@ <h3 id="regression">Regression</h3>
<td align="left">The RMSE is aggregated as sqrt(mean(rmse.vals.on.test.sets^2)). If you don't want that, you could also use <code>test.mean</code>.</td>
</tr>
<tr>
<td align="left"><strong><a href="http://www.rdocumentation.org/packages/mlr/functions/measures.html">rrse</a></strong> <br />Root relative squared error</td>
<td align="center">X</td>
<td align="right">0</td>
<td align="right">Inf</td>
<td align="center">X</td>
<td align="center">X</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="left"><a href="http://www.rdocumentation.org/packages/mlr/functions/aggregations.html">test.mean</a></td>
<td align="left">Defined as sqrt (sum_of_squared_errors / total_sum_of_squares). Undefined for single instances and when every truth value is identical. In this case the output will be NA.</td>
</tr>
<tr>
<td align="left"><strong><a href="http://www.rdocumentation.org/packages/mlr/functions/measures.html">rsq</a></strong> <br />Coefficient of determination</td>
<td align="center"></td>
<td align="right">1</td>
Expand Down
1,552 changes: 776 additions & 776 deletions devel/html/mkdocs/search_index.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions devel/html/multilabel/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -550,13 +550,13 @@ <h2 id="performance">Performance</h2>
#&gt; multilabel.subset01 multilabel.hamloss multilabel.acc
#&gt; 0.8663633 0.2049471 0.4637509
#&gt; multilabel.f1 timepredict
#&gt; 0.5729926 1.4540000
#&gt; 0.5729926 1.0810000

listMeasures(&quot;multilabel&quot;)
#&gt; [1] &quot;multilabel.f1&quot; &quot;multilabel.subset01&quot; &quot;multilabel.tpr&quot;
#&gt; [4] &quot;multilabel.ppv&quot; &quot;multilabel.acc&quot; &quot;timeboth&quot;
#&gt; [7] &quot;timepredict&quot; &quot;multilabel.hamloss&quot; &quot;featperc&quot;
#&gt; [10] &quot;timetrain&quot;
#&gt; [1] &quot;multilabel.ppv&quot; &quot;timepredict&quot; &quot;multilabel.hamloss&quot;
#&gt; [4] &quot;multilabel.f1&quot; &quot;featperc&quot; &quot;multilabel.subset01&quot;
#&gt; [7] &quot;timeboth&quot; &quot;timetrain&quot; &quot;multilabel.tpr&quot;
#&gt; [10] &quot;multilabel.acc&quot;
</code></pre>

<h2 id="resampling">Resampling</h2>
Expand All @@ -573,7 +573,7 @@ <h2 id="resampling">Resampling</h2>
#&gt; multilabel.hamloss.aggr: 0.22
#&gt; multilabel.hamloss.mean: 0.22
#&gt; multilabel.hamloss.sd: 0.01
#&gt; Runtime: 5.76838
#&gt; Runtime: 4.37393

r = resample(learner = lrn.rFerns, task = yeast.task, resampling = rdesc, show.info = FALSE)
r
Expand All @@ -583,7 +583,7 @@ <h2 id="resampling">Resampling</h2>
#&gt; multilabel.hamloss.aggr: 0.47
#&gt; multilabel.hamloss.mean: 0.47
#&gt; multilabel.hamloss.sd: 0.00
#&gt; Runtime: 0.540231
#&gt; Runtime: 0.404812
</code></pre>

<h2 id="binary-performance">Binary performance</h2>
Expand Down
70 changes: 32 additions & 38 deletions devel/html/nested_resampling/index.html

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions devel/html/partial_dependence/index.html

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions devel/html/performance/index.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions devel/html/predict/index.html

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions devel/html/preproc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ <h3 id="creating-the-preprocessing-wrapper">Creating the preprocessing wrapper</
#&gt; mse.aggr: 20.62
#&gt; mse.mean: 20.62
#&gt; mse.sd: 8.53
#&gt; Runtime: 0.132104
#&gt; Runtime: 0.103239

lrn = makeLearner(&quot;regr.nnet&quot;, trace = FALSE, decay = 1e-02)
r = resample(lrn, bh.task, resampling = rdesc, show.info = FALSE)
Expand All @@ -778,7 +778,7 @@ <h3 id="creating-the-preprocessing-wrapper">Creating the preprocessing wrapper</
#&gt; mse.aggr: 55.06
#&gt; mse.mean: 55.06
#&gt; mse.sd: 19.40
#&gt; Runtime: 0.10274
#&gt; Runtime: 0.0779717
</code></pre>

<h3 id="joint-tuning-of-preprocessing-and-learner-parameters">Joint tuning of preprocessing and learner parameters</h3>
Expand Down Expand Up @@ -848,18 +848,18 @@ <h3 id="joint-tuning-of-preprocessing-and-learner-parameters">Joint tuning of pr

as.data.frame(res$opt.path)
#&gt; decay center scale mse.test.mean dob eol error.message exec.time
#&gt; 1 0 TRUE TRUE 49.38128 1 NA &lt;NA&gt; 0.042
#&gt; 2 0.05 TRUE TRUE 20.64761 2 NA &lt;NA&gt; 0.049
#&gt; 3 0.1 TRUE TRUE 22.42986 3 NA &lt;NA&gt; 0.049
#&gt; 4 0 FALSE TRUE 96.25474 4 NA &lt;NA&gt; 0.027
#&gt; 5 0.05 FALSE TRUE 14.84306 5 NA &lt;NA&gt; 0.052
#&gt; 6 0.1 FALSE TRUE 16.65383 6 NA &lt;NA&gt; 0.047
#&gt; 7 0 TRUE FALSE 40.51518 7 NA &lt;NA&gt; 0.050
#&gt; 8 0.05 TRUE FALSE 68.00069 8 NA &lt;NA&gt; 0.047
#&gt; 9 0.1 TRUE FALSE 55.42210 9 NA &lt;NA&gt; 0.050
#&gt; 10 0 FALSE FALSE 96.25474 10 NA &lt;NA&gt; 0.027
#&gt; 11 0.05 FALSE FALSE 56.25758 11 NA &lt;NA&gt; 0.049
#&gt; 12 0.1 FALSE FALSE 42.85529 12 NA &lt;NA&gt; 0.049
#&gt; 1 0 TRUE TRUE 49.38128 1 NA &lt;NA&gt; 0.038
#&gt; 2 0.05 TRUE TRUE 20.64761 2 NA &lt;NA&gt; 0.045
#&gt; 3 0.1 TRUE TRUE 22.42986 3 NA &lt;NA&gt; 0.045
#&gt; 4 0 FALSE TRUE 96.25474 4 NA &lt;NA&gt; 0.023
#&gt; 5 0.05 FALSE TRUE 14.84306 5 NA &lt;NA&gt; 0.049
#&gt; 6 0.1 FALSE TRUE 16.65383 6 NA &lt;NA&gt; 0.043
#&gt; 7 0 TRUE FALSE 40.51518 7 NA &lt;NA&gt; 0.044
#&gt; 8 0.05 TRUE FALSE 68.00069 8 NA &lt;NA&gt; 0.042
#&gt; 9 0.1 TRUE FALSE 55.42210 9 NA &lt;NA&gt; 0.045
#&gt; 10 0 FALSE FALSE 96.25474 10 NA &lt;NA&gt; 0.022
#&gt; 11 0.05 FALSE FALSE 56.25758 11 NA &lt;NA&gt; 0.044
#&gt; 12 0.1 FALSE FALSE 42.85529 12 NA &lt;NA&gt; 0.042
</code></pre>

<h3 id="preprocessing-wrapper-functions">Preprocessing wrapper functions</h3>
Expand Down
6 changes: 3 additions & 3 deletions devel/html/resample/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ <h1 id="resampling">Resampling</h1>
#&gt; cindex.aggr: 0.63
#&gt; cindex.mean: 0.63
#&gt; cindex.sd: 0.05
#&gt; Runtime: 0.0429173
#&gt; Runtime: 0.0281701
## peak a little bit into r
names(r)
#&gt; [1] &quot;learner.id&quot; &quot;task.id&quot; &quot;measures.train&quot; &quot;measures.test&quot;
Expand Down Expand Up @@ -485,10 +485,10 @@ <h1 id="resampling">Resampling</h1>
#&gt; [Resample] subsampling iter: 3
#&gt; [Resample] subsampling iter: 4
#&gt; [Resample] subsampling iter: 5
#&gt; [Resample] Result: dunn.test.mean=0.274,db.test.mean=0.51,timetrain.test.mean=0.0008
#&gt; [Resample] Result: dunn.test.mean=0.274,db.test.mean=0.51,timetrain.test.mean=0.001
r$aggr
#&gt; dunn.test.mean db.test.mean timetrain.test.mean
#&gt; 0.2738893 0.5103655 0.0008000
#&gt; 0.2738893 0.5103655 0.0010000
</code></pre>

<h2 id="stratified-resampling">Stratified resampling</h2>
Expand Down
30 changes: 15 additions & 15 deletions devel/html/roc_analysis/index.html

Large diffs are not rendered by default.

Loading

0 comments on commit 06c1427

Please sign in to comment.