Skip to content

Commit

Permalink
Check if package fdm2id is available in vignette; add package to Sugg…
Browse files Browse the repository at this point in the history
…ests in DESCRIPTION
  • Loading branch information
merliseclyde committed Apr 27, 2023
1 parent ef22dfb commit 4555a90
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ BugReports: https://github.com/merliseclyde/bark/issues
Suggests:
BART,
e1071,
fdm2id,
rmarkdown,
knitr,
roxygen2,
Expand Down
12 changes: 8 additions & 4 deletions vignettes/bark.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ We will compare {r bark} to two other popular methods, {r BART} and {r SVM} that
```{r}
bart.available = suppressMessages(require(BART))
svm.available = suppressMessages(require(e1071))
io.available = suppressMessages(require(fdm2id))
```

### SVM
Expand Down Expand Up @@ -216,7 +217,8 @@ io.testdata = ionosphere[-train,]

### BARK

```{r io-bark, evaluate=FALSE}
```{r io-bark}
if (io.available) {
set.seed(42)
io.bark <- bark(V35 ~ ., data= io.traindata,
testdata = io.testdata,
Expand All @@ -228,11 +230,13 @@ io.bark <- bark(V35 ~ ., data= io.traindata,
keepevery = 100,
printevery = 10^10)
mean((io.bark$yhat.test.mean > 0) != io.testdata[, y.loc])
}
```


### BART
```{r bart-io}
if (bart.available) {
if (bart.available & io.available) {
io.bart = pbart(x.train = as.matrix(io.traindata[, -y.loc]),
y.train = io.traindata[, y.loc]);
pred.bart = predict(io.bart, io.testdata[, -y.loc]);
Expand All @@ -242,7 +246,7 @@ if (bart.available) {

### SVM
```{r svm-io}
if (svm.available) {
if (svm.available & io.available) {
io.svm = svm(V35 ~ ., data=io.traindata, type="C")
pred.svm = predict(io.svm, io.testdata)
mean(pred.svm != io.testdata[, y.loc])
Expand Down

0 comments on commit 4555a90

Please sign in to comment.