reproducible-research

Loops with captions with knitr

[亡魂溺海] 提交于 2019-11-30 10:02:40
I am wondering if there is an easy way to produce a bunch of tables or graphics with variable captions in knitr . The only way I know is this: (simplified from https://github.com/yihui/knitr-examples/blob/master/075-knit-expand.Rnw ). But it is a drag to collect the output into src and then print it after the loop, because I want to write a function to produce such a loop from an arbitrary dataset. \documentclass{article} \title{Using knit\_expand() for templates} \author{Yihui Xie} \begin{document} \maketitle \tableofcontents <<lm-mtcars, tidy.opts=list(width.cutoff=55)>>= # the template tpl

Logging input and output in Spyder's console

早过忘川 提交于 2019-11-29 16:40:47
I learnt data manipulation and analysis through Stata and I used the log command to record all the commands written and the output generated. Doing so I could reproduce my findings, check previous results and share it with others in pdf or txt. What to use with Python? Is there a difference if I use a Python Jupyter Notebook or Spyder? The way to do what you want is by using the %logstart command, as described here: Log IPython output? Stop using the python interpreter and start storing your commands in a text file before running them. This way you will be able to share, reuse, and revise your

Logging input and output in Spyder's console

ε祈祈猫儿з 提交于 2019-11-28 10:23:32
问题 I learnt data manipulation and analysis through Stata and I used the log command to record all the commands written and the output generated. Doing so I could reproduce my findings, check previous results and share it with others in pdf or txt. What to use with Python? Is there a difference if I use a Python Jupyter Notebook or Spyder? 回答1: The way to do what you want is by using the %logstart command, as described here: Log IPython output? 回答2: Stop using the python interpreter and start

knitr - Python engine cache option not working

北慕城南 提交于 2019-11-28 04:42:29
问题 yihui gives an example of using the cache option for the different engines https://github.com/yihui/knitr-examples/blob/master/023-engine-python.Rmd I can't seem to get it to work for python. The following works ```{r,engine='python',cache=TRUE} x=10 print x ``` But this doesn't work ```{r,engine='python',cache=TRUE} x = 10 ``` ```{r,engine='python',cache=TRUE} print x ``` Anyone have an idea? 回答1: The chunk option cache doesn't save all the variables defined in the block for languages other

Fully reproducible parallel models using caret

半腔热情 提交于 2019-11-27 02:51:32
When I run 2 random forests in caret, I get the exact same results if I set a random seed: library(caret) library(doParallel) set.seed(42) myControl <- trainControl(method='cv', index=createFolds(iris$Species)) set.seed(42) model1 <- train(Species~., iris, method='rf', trControl=myControl) set.seed(42) model2 <- train(Species~., iris, method='rf', trControl=myControl) > all.equal(predict(model1, type='prob'), predict(model2, type='prob')) [1] TRUE However, if I register a parallel back-end to speed up the modeling, I get a different result each time I run the model: cl <- makeCluster

Example of using dput()

﹥>﹥吖頭↗ 提交于 2019-11-26 17:53:41
Being a new user here , my questions are not being fully answered due to not being reproducible. I read the thread relating to producing reproducible code but to avail. Specifically lost on how to use the dput() function. Could someone provide a step by step on how to use the dput() using the iris df for eg it would be very helpful. Using the iris dataset, which is handily included into R , we can see how dput() works: data(iris) head(iris) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 1.3 0.2 setosa 4 4.6 3.1 1.5 0.2

Reproducible results in Tensorflow with tf.set_random_seed

情到浓时终转凉″ 提交于 2019-11-26 09:51:52
问题 I am trying to generate N sets of independent random numbers. I have a simple code that shows the problem for 3 sets of 10 random numbers. I notice that even though I use the tf.set_random_seed to set the seed, the results of different runs do not look alike. Any help or comments are greatly appreciated. (py3p6) bash-3.2$ cat test.py import tensorflow as tf for i in range(3): tf.set_random_seed(1234) generate = tf.random_uniform((10,), 0, 10) with tf.Session() as sess: b = sess.run(generate)

Example of using dput()

ε祈祈猫儿з 提交于 2019-11-26 02:15:01
问题 Being a new user here , my questions are not being fully answered due to not being reproducible. I read the thread relating to producing reproducible code but to avail. Specifically lost on how to use the dput() function. Could someone provide a step by step on how to use the dput() using the iris df for eg it would be very helpful. 回答1: Using the iris dataset, which is handily included into R , we can see how dput() works: data(iris) head(iris) Sepal.Length Sepal.Width Petal.Length Petal