Skip to content

Commit f2214c8

Browse files
committed
Passed winbuilder tests.
1 parent dad876d commit f2214c8

File tree

4 files changed

+96
-104
lines changed

4 files changed

+96
-104
lines changed

cran-comments.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
## Test environments
2+
23
* local OS X install, R 3.4.1
34
* ubuntu 14.04.5 (on travis-ci), R 3.4.1
45
* win-builder (devel and release)
56

67
## R CMD check results
8+
79
There were no ERRORs or WARNINGs.
810

911
There was 1 NOTE: "New submission"

vignettes/Basics.R

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ library(mosaicModel)
66
library(randomForest)
77
library(caret)
88
library(splines)
9+
theme_update(legend.position = "top")
910
knitr::opts_chunk$set(fig.align = "center", fig.show = "hold", out.width = "45%")
1011

1112
## ----fuel_intro, fig.cap = "A simple display of the `mtcars` data used in the example."----
@@ -17,12 +18,12 @@ fuel_mod_1 <- lm(mpg ~ hp * transmission, data = mtcars)
1718
fuel_mod_2 <- lm(mpg ~ ns(hp, 2) * transmission, data = mtcars)
1819

1920
## ----out.width = "30%"---------------------------------------------------
20-
mod_plot(fuel_mod_1) %>% gf_theme(legend.position = "top")
21-
mod_plot(fuel_mod_2) %>% gf_theme(legend.position = "top")
21+
mod_plot(fuel_mod_1)
22+
mod_plot(fuel_mod_2)
2223

2324
## ------------------------------------------------------------------------
24-
gf_point(Sepal.Length ~ Petal.Length, color = ~ Species, data = iris) %>%
25-
gf_theme(legend.position = "top")
25+
theme_update(legend.position = "top")
26+
gf_point(Sepal.Length ~ Petal.Length, color = ~ Species, data = iris)
2627

2728
## ------------------------------------------------------------------------
2829
library(randomForest)
@@ -31,16 +32,14 @@ library(caret)
3132
iris_mod_2 <- knn3(Species ~., data = iris, k = 15)
3233

3334
## ------------------------------------------------------------------------
34-
mod_plot(iris_mod_1) %>% gf_theme(legend.position = "top")
35+
mod_plot(iris_mod_1)
3536

3637
## ----out.width = "80%", fig.width = 8, fig.height = 8--------------------
37-
mod_plot(iris_mod_2, class_level = "setosa") %>%
38-
gf_theme(legend.position = "top")
38+
mod_plot(iris_mod_2, class_level = "setosa")
3939

4040
## ----fig.out="40%", fig.keep = "hold"------------------------------------
41-
mod_plot(iris_mod_2, ~ Petal.Length + Petal.Width) %>% gf_theme(legend.position = "top")
42-
mod_plot(iris_mod_2, ~ Petal.Length + Petal.Width + Sepal.Width) %>%
43-
gf_theme(legend.position = "top")
41+
mod_plot(iris_mod_2, ~ Petal.Length + Petal.Width)
42+
mod_plot(iris_mod_2, ~ Petal.Length + Petal.Width + Sepal.Width)
4443

4544
## ------------------------------------------------------------------------
4645
mod_eval(fuel_mod_1, transmission = "manual", hp = 200)
@@ -84,8 +83,7 @@ ensemble_fuel_1 <- mod_ensemble(fuel_mod_1, nreps = 10)
8483
ensemble_iris_1 <- mod_ensemble(iris_mod_1, nreps = 10)
8584

8685
## ------------------------------------------------------------------------
87-
mod_plot(ensemble_fuel_1) %>%
88-
gf_theme(legend.position = "top")
86+
mod_plot(ensemble_fuel_1)
8987
mod_effect(ensemble_iris_1, ~ Petal.Length)
9088
mod_eval(ensemble_iris_1, nlevels = 1)
9189

@@ -126,13 +124,12 @@ predict(my_mod) %>% str()
126124
mosaicModel:::mod_eval_fun.lda
127125

128126
## ----error = TRUE--------------------------------------------------------
129-
mod_eval_fun.lda(my_mod, data = iris[c(30, 80, 120),])
127+
mod_eval_fun(my_mod, data = iris[c(30, 80, 120),])
130128

131129
## ------------------------------------------------------------------------
132130
mod_effect(my_mod, ~ Petal.Length, bootstrap = 10,
133131
class_level = "virginica")
134132

135133
## ------------------------------------------------------------------------
136-
mod_plot(my_mod, bootstrap = 10, class_level = "virginica") %>%
137-
gf_theme(legend.position = "top")
134+
mod_plot(my_mod, bootstrap = 10, class_level = "virginica")
138135

vignettes/Basics.Rmd

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ library(mosaicModel)
1919
library(randomForest)
2020
library(caret)
2121
library(splines)
22+
theme_update(legend.position = "top")
2223
knitr::opts_chunk$set(fig.align = "center", fig.show = "hold", out.width = "45%")
2324
```
2425

@@ -73,8 +74,8 @@ The second model includes a nonlinear dependence on horsepower. You can think of
7374
For models involving only a very few explanatory variables, a plot of the model can give immediate insight. The `mod_plot` function reduces the work to make such a plot.
7475

7576
```{r out.width = "30%"}
76-
mod_plot(fuel_mod_1) %>% gf_theme(legend.position = "top")
77-
mod_plot(fuel_mod_2) %>% gf_theme(legend.position = "top")
77+
mod_plot(fuel_mod_1)
78+
mod_plot(fuel_mod_2)
7879
```
7980

8081
Two important additional arguments to `mod_plot` are
@@ -89,8 +90,8 @@ Two important additional arguments to `mod_plot` are
8990
The `iris` dataset has four explanatory variables. Here's species shown as a function of two of the variables:
9091

9192
```{r}
92-
gf_point(Sepal.Length ~ Petal.Length, color = ~ Species, data = iris) %>%
93-
gf_theme(legend.position = "top")
93+
theme_update(legend.position = "top")
94+
gf_point(Sepal.Length ~ Petal.Length, color = ~ Species, data = iris)
9495
```
9596
For later comparison to the models that we'll train, note that when the petal length and sepal length are both large, the flowers are almost always *virginica*.
9697

@@ -108,7 +109,7 @@ Notice that the model architectures used to create the two models come from two
108109

109110
Again, we can plot out the form of the function:
110111
```{r}
111-
mod_plot(iris_mod_1) %>% gf_theme(legend.position = "top")
112+
mod_plot(iris_mod_1)
112113
```
113114

114115
Since this is a classifier, the plot of the model function shows the *probability* of one of the output classes. That's *virginica* here. When the petal length is small, say around 1, the flower is very unlikely to be *virginica*. But for large petal lengths, and especially for large petal lengths and large sepal lengths, the flower is almost certain to be *virginica*.
@@ -118,17 +119,15 @@ If your interest is in a class other than *virginica*, you can specify the class
118119
The second iris model has four explanatory variables. This is as many as `mod_plot` will display:
119120

120121
```{r out.width = "80%", fig.width = 8, fig.height = 8}
121-
mod_plot(iris_mod_2, class_level = "setosa") %>%
122-
gf_theme(legend.position = "top")
122+
mod_plot(iris_mod_2, class_level = "setosa")
123123
```
124124
The plot shows that the flower species does not depend on either of the two variables displayed on the x-axis and with color: the sepal width and the sepal length. This is why the line is flat and the colors overlap. But you can easily see a dependence on petal width and, to a very limited extent, on petal length.
125125

126126
The choice of which role in the plot is played by which explanatory variable is up to you. Here the dependence on petal length and width are emphasized by using them for x-position and color:
127127

128128
```{r fig.out="40%", fig.keep = "hold"}
129-
mod_plot(iris_mod_2, ~ Petal.Length + Petal.Width) %>% gf_theme(legend.position = "top")
130-
mod_plot(iris_mod_2, ~ Petal.Length + Petal.Width + Sepal.Width) %>%
131-
gf_theme(legend.position = "top")
129+
mod_plot(iris_mod_2, ~ Petal.Length + Petal.Width)
130+
mod_plot(iris_mod_2, ~ Petal.Length + Petal.Width + Sepal.Width)
132131
```
133132

134133
## Model outputs
@@ -220,8 +219,7 @@ ensemble_iris_1 <- mod_ensemble(iris_mod_1, nreps = 10)
220219
Now you can use other functions from the package, but putting the ensemble in the argument slot for the model, for instance:
221220

222221
```{r}
223-
mod_plot(ensemble_fuel_1) %>%
224-
gf_theme(legend.position = "top")
222+
mod_plot(ensemble_fuel_1)
225223
mod_effect(ensemble_iris_1, ~ Petal.Length)
226224
mod_eval(ensemble_iris_1, nlevels = 1)
227225
```
@@ -338,17 +336,16 @@ mosaicModel:::mod_eval_fun.lda
338336
The arguments to the function are the same as for all the `mod_eval_fun` methods. The body of the function pulls out the `posterior` component, coerces it to a data frame and removes the row names. It isn't always this easy. But once the function is available in your session, you can test it out. (Make sure to give it a data set as inputs to the model)
339337

340338
```{r error = TRUE}
341-
mod_eval_fun.lda(my_mod, data = iris[c(30, 80, 120),])
339+
mod_eval_fun(my_mod, data = iris[c(30, 80, 120),])
342340
```
343341

344-
Now things should work.
342+
Now the high-level functions in `mosaicModel` can work on LDA models.
345343

346344
```{r}
347345
mod_effect(my_mod, ~ Petal.Length, bootstrap = 10,
348346
class_level = "virginica")
349347
```
350348

351349
```{r}
352-
mod_plot(my_mod, bootstrap = 10, class_level = "virginica") %>%
353-
gf_theme(legend.position = "top")
350+
mod_plot(my_mod, bootstrap = 10, class_level = "virginica")
354351
```

0 commit comments

Comments
 (0)