diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml
index 8de8eeb9d..5f574be11 100644
--- a/.github/workflows/pkgdown.yaml
+++ b/.github/workflows/pkgdown.yaml
@@ -53,6 +53,21 @@ jobs:
pak::pkg_install("C50")
shell: Rscript {0}
+ - name: Install Miniconda
+ run: |
+ Rscript -e "pak::pkg_install('rstudio/reticulate')"
+ Rscript -e "reticulate::install_miniconda()"
+
+ - name: Find Miniconda on macOS
+ if: runner.os == 'macOS'
+ run: echo "options(reticulate.conda_binary = reticulate:::miniconda_conda())" >> .Rprofile
+
+ - name: Install TensorFlow
+ run: |
+ reticulate::conda_create('r-reticulate', packages = c('python==3.6.9'))
+ tensorflow::install_tensorflow(version='1.14.0')
+ shell: Rscript {0}
+
- name: Install package
run: R CMD INSTALL .
diff --git a/_pkgdown.yml b/_pkgdown.yml
index c11cdc617..389881c49 100644
--- a/_pkgdown.yml
+++ b/_pkgdown.yml
@@ -10,7 +10,7 @@ template:
# https://github.com/tidyverse/tidytemplate for css
development:
- mode: auto
+ mode: release
figures:
@@ -90,6 +90,8 @@ navbar:
href: https://www.tidymodels.org/learn/develop/models/
- text: Evaluating submodels with the same model object
href: articles/articles/Submodels.html
+ - text: Fitting and Predicting with parsnip
+ href: articles/articles/Examples.html
- text: News
href: news/index.html
- text: Reference
diff --git a/man/details_multinom_reg_glmnet.Rd b/man/details_multinom_reg_glmnet.Rd
index b64927e87..31aec956c 100644
--- a/man/details_multinom_reg_glmnet.Rd
+++ b/man/details_multinom_reg_glmnet.Rd
@@ -57,6 +57,13 @@ variance of one. By default, \code{\link[glmnet:glmnet]{glmnet::glmnet()}} uses
the argument \code{standardize = TRUE} to center and scale the data.
}
+\subsection{Examples}{
+
+The “Fitting and Predicting with parsnip” article contains
+\href{https://parsnip.tidymodels.org/articles/articles/Examples.html#multinom-reg-glmnet}{examples}
+for \code{multinom_reg()} with the \code{"glmnet"} engine.
+}
+
\subsection{References}{
\itemize{
\item Hastie, T, R Tibshirani, and M Wainwright. 2015. \emph{Statistical
diff --git a/man/details_nearest_neighbor_kknn.Rd b/man/details_nearest_neighbor_kknn.Rd
index fa34905e1..83190ac1d 100644
--- a/man/details_nearest_neighbor_kknn.Rd
+++ b/man/details_nearest_neighbor_kknn.Rd
@@ -82,6 +82,13 @@ center and scale each so that each predictor has mean zero and a
variance of one.
}
+\subsection{Examples}{
+
+The “Fitting and Predicting with parsnip” article contains
+\href{https://parsnip.tidymodels.org/articles/articles/Examples.html#nearest-neighbor-kknn}{examples}
+for \code{nearest_neighbor()} with the \code{"kknn"} engine.
+}
+
\subsection{References}{
\itemize{
\item Hechenbichler K. and Schliep K.P. (2004) \href{https://epub.ub.uni-muenchen.de/1769/}{Weighted k-Nearest-Neighbor Techniques and Ordinal Classification}, Discussion
diff --git a/man/details_rand_forest_randomForest.Rd b/man/details_rand_forest_randomForest.Rd
index 09dea5f2f..5a6fd3592 100644
--- a/man/details_rand_forest_randomForest.Rd
+++ b/man/details_rand_forest_randomForest.Rd
@@ -88,6 +88,13 @@ Categorical predictors can be partitioned into groups of factor levels
are not required for this model.
}
+\subsection{Examples}{
+
+The “Fitting and Predicting with parsnip” article contains
+\href{https://parsnip.tidymodels.org/articles/articles/Examples.html#rand-forest-randomForest}{examples}
+for \code{rand_forest()} with the \code{"randomForest"} engine.
+}
+
\subsection{References}{
\itemize{
\item Kuhn, M, and K Johnson. 2013. \emph{Applied Predictive Modeling}.
diff --git a/man/details_rand_forest_ranger.Rd b/man/details_rand_forest_ranger.Rd
index 4910b9965..942892007 100644
--- a/man/details_rand_forest_ranger.Rd
+++ b/man/details_rand_forest_ranger.Rd
@@ -105,6 +105,13 @@ these values can fall outside of \verb{[0, 1]} and will be coerced to be in
this range.
}
+\subsection{Examples}{
+
+The “Fitting and Predicting with parsnip” article contains
+\href{https://parsnip.tidymodels.org/articles/articles/Examples.html#rand-forest-ranger}{examples}
+for \code{rand_forest()} with the \code{"ranger"} engine.
+}
+
\subsection{References}{
\itemize{
\item Kuhn, M, and K Johnson. 2013. \emph{Applied Predictive Modeling}.
diff --git a/man/details_svm_linear_LiblineaR.Rd b/man/details_svm_linear_LiblineaR.Rd
index 6491729f8..bbc377764 100644
--- a/man/details_svm_linear_LiblineaR.Rd
+++ b/man/details_svm_linear_LiblineaR.Rd
@@ -85,6 +85,13 @@ center and scale each so that each predictor has mean zero and a
variance of one.
}
+\subsection{Examples}{
+
+The “Fitting and Predicting with parsnip” article contains
+\href{https://parsnip.tidymodels.org/articles/articles/Examples.html#svm-linear-LiblineaR}{examples}
+for \code{svm_linear()} with the \code{"LiblineaR"} engine.
+}
+
\subsection{References}{
\itemize{
\item Kuhn, M, and K Johnson. 2013. \emph{Applied Predictive Modeling}.
diff --git a/man/details_svm_linear_kernlab.Rd b/man/details_svm_linear_kernlab.Rd
index fede1ccff..94c6e198b 100644
--- a/man/details_svm_linear_kernlab.Rd
+++ b/man/details_svm_linear_kernlab.Rd
@@ -82,6 +82,13 @@ center and scale each so that each predictor has mean zero and a
variance of one.
}
+\subsection{Examples}{
+
+The “Fitting and Predicting with parsnip” article contains
+\href{https://parsnip.tidymodels.org/articles/articles/Examples.html#svm-linear-kernlab}{examples}
+for \code{svm_linear()} with the \code{"kernlab"} engine.
+}
+
\subsection{References}{
\itemize{
\item Lin, HT, and R Weng. \href{https://www.csie.ntu.edu.tw/~cjlin/papers/plattprob.pdf}{“A Note on Platt’s Probabilistic Outputs for Support Vector Machines”}
diff --git a/man/details_svm_poly_kernlab.Rd b/man/details_svm_poly_kernlab.Rd
index 996e74a08..0108f8ff4 100644
--- a/man/details_svm_poly_kernlab.Rd
+++ b/man/details_svm_poly_kernlab.Rd
@@ -94,6 +94,13 @@ center and scale each so that each predictor has mean zero and a
variance of one.
}
+\subsection{Examples}{
+
+The “Fitting and Predicting with parsnip” article contains
+\href{https://parsnip.tidymodels.org/articles/articles/Examples.html#svm-poly-kernlab}{examples}
+for \code{svm_poly()} with the \code{"kernlab"} engine.
+}
+
\subsection{References}{
\itemize{
\item Lin, HT, and R Weng. \href{https://www.csie.ntu.edu.tw/~cjlin/papers/plattprob.pdf}{“A Note on Platt’s Probabilistic Outputs for Support Vector Machines”}
diff --git a/man/details_svm_rbf_kernlab.Rd b/man/details_svm_rbf_kernlab.Rd
index 8417a7d9b..87aa5e5e4 100644
--- a/man/details_svm_rbf_kernlab.Rd
+++ b/man/details_svm_rbf_kernlab.Rd
@@ -94,6 +94,13 @@ center and scale each so that each predictor has mean zero and a
variance of one.
}
+\subsection{Examples}{
+
+The “Fitting and Predicting with parsnip” article contains
+\href{https://parsnip.tidymodels.org/articles/articles/Examples.html#svm-rbf-kernlab}{examples}
+for \code{svm_rbf()} with the \code{"kernlab"} engine.
+}
+
\subsection{References}{
\itemize{
\item Lin, HT, and R Weng. \href{https://www.csie.ntu.edu.tw/~cjlin/papers/plattprob.pdf}{“A Note on Platt’s Probabilistic Outputs for Support Vector Machines”}
diff --git a/man/rmd/boost_tree_C5.0.Rmd b/man/rmd/boost_tree_C5.0.Rmd
index cf43aa369..b7cbfa25c 100644
--- a/man/rmd/boost_tree_C5.0.Rmd
+++ b/man/rmd/boost_tree_C5.0.Rmd
@@ -58,6 +58,10 @@ boost_tree(trees = integer(), min_n = integer(), sample_size = numeric()) %>%
By default, early stopping is used. To use the complete set of boosting iterations, pass `earlyStopping = FALSE` to [set_engine()]. Also, it is unlikely that early stopping will occur if `sample_size = 1`.
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#boost-tree-C5.0) for `boost_tree()` with the `"C5.0"` engine.
+
## References
- Kuhn, M, and K Johnson. 2013. *Applied Predictive Modeling*. Springer.
diff --git a/man/rmd/boost_tree_xgboost.Rmd b/man/rmd/boost_tree_xgboost.Rmd
index 1f56cfcc3..178c7c1ad 100644
--- a/man/rmd/boost_tree_xgboost.Rmd
+++ b/man/rmd/boost_tree_xgboost.Rmd
@@ -93,6 +93,10 @@ If the model specification has `early_stop >= trees`, `early_stop` is converted
parsnip chooses the objective function based on the characteristics of the outcome. To use a different loss, pass the `objective` argument to [set_engine()].
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#boost-tree-xgboost) for `boost_tree()` with the `"xgboost"` engine.
+
## References
- [XGBoost: A Scalable Tree Boosting System](https://arxiv.org/abs/1603.02754)
diff --git a/man/rmd/decision_tree_C5.0.Rmd b/man/rmd/decision_tree_C5.0.Rmd
index 7147fde64..8ca1b6edb 100644
--- a/man/rmd/decision_tree_C5.0.Rmd
+++ b/man/rmd/decision_tree_C5.0.Rmd
@@ -50,6 +50,10 @@ decision_tree(min_n = integer()) %>%
```{r child = "template-tree-split-factors.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#decision-tree-C5.0) for `decision_tree()` with the `"C5.0"` engine.
+
## References
- Kuhn, M, and K Johnson. 2013. *Applied Predictive Modeling*. Springer.
diff --git a/man/rmd/decision_tree_rpart.Rmd b/man/rmd/decision_tree_rpart.Rmd
index 94f302a3a..3de385dad 100644
--- a/man/rmd/decision_tree_rpart.Rmd
+++ b/man/rmd/decision_tree_rpart.Rmd
@@ -58,6 +58,10 @@ decision_tree(tree_depth = integer(1), min_n = integer(1), cost_complexity = dou
```{r child = "template-tree-split-factors.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#decision-tree-rpart) for `decision_tree()` with the `"rpart"` engine.
+
## References
- Kuhn, M, and K Johnson. 2013. *Applied Predictive Modeling*. Springer.
diff --git a/man/rmd/linear_reg_glmnet.Rmd b/man/rmd/linear_reg_glmnet.Rmd
index 4949319c3..f15d1eab5 100644
--- a/man/rmd/linear_reg_glmnet.Rmd
+++ b/man/rmd/linear_reg_glmnet.Rmd
@@ -54,6 +54,10 @@ linear_reg(penalty = double(1), mixture = double(1)) %>%
```
By default, [glmnet::glmnet()] uses the argument `standardize = TRUE` to center and scale the data.
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#linear-reg-glmnet) for `linear_reg()` with the `"glmnet"` engine.
+
## References
- Hastie, T, R Tibshirani, and M Wainwright. 2015. _Statistical Learning with Sparsity_. CRC Press.
diff --git a/man/rmd/linear_reg_keras.Rmd b/man/rmd/linear_reg_keras.Rmd
index b2ac2d3a6..4d7ab6742 100644
--- a/man/rmd/linear_reg_keras.Rmd
+++ b/man/rmd/linear_reg_keras.Rmd
@@ -53,6 +53,9 @@ linear_reg(penalty = double(1)) %>%
```{r child = "template-same-scale.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#linear-reg-keras) for `linear_reg()` with the `"keras"` engine.
## References
diff --git a/man/rmd/linear_reg_lm.Rmd b/man/rmd/linear_reg_lm.Rmd
index dd61b16d2..9d90608c7 100644
--- a/man/rmd/linear_reg_lm.Rmd
+++ b/man/rmd/linear_reg_lm.Rmd
@@ -20,6 +20,10 @@ linear_reg() %>%
```{r child = "template-makes-dummies.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#linear-reg-lm) for `linear_reg()` with the `"lm"` engine.
+
## References
- Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer.
diff --git a/man/rmd/linear_reg_stan.Rmd b/man/rmd/linear_reg_stan.Rmd
index 3b064e303..2ad553e91 100644
--- a/man/rmd/linear_reg_stan.Rmd
+++ b/man/rmd/linear_reg_stan.Rmd
@@ -39,6 +39,10 @@ Note that the `refresh` default prevents logging of the estimation process. Chan
For prediction, the `"stan"` engine can compute posterior intervals analogous to confidence and prediction intervals. In these instances, the units are the original outcome and when `std_error = TRUE`, the standard deviation of the posterior distribution (or posterior predictive distribution as appropriate) is returned.
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#linear-reg-stan) for `linear_reg()` with the `"stan"` engine.
+
## References
- McElreath, R. 2020 _Statistical Rethinking_. CRC Press.
diff --git a/man/rmd/logistic_reg_LiblineaR.Rmd b/man/rmd/logistic_reg_LiblineaR.Rmd
index fd888d517..5332ee1d4 100644
--- a/man/rmd/logistic_reg_LiblineaR.Rmd
+++ b/man/rmd/logistic_reg_LiblineaR.Rmd
@@ -53,6 +53,10 @@ logistic_reg(penalty = double(1), mixture = double(1)) %>%
```{r child = "template-same-scale.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#logistic-reg-LiblineaR) for `logistic_reg()` with the `"LiblineaR"` engine.
+
## References
- Hastie, T, R Tibshirani, and M Wainwright. 2015. _Statistical Learning with Sparsity_. CRC Press.
diff --git a/man/rmd/logistic_reg_glm.Rmd b/man/rmd/logistic_reg_glm.Rmd
index 7cd4ccf5f..cafeaba6f 100644
--- a/man/rmd/logistic_reg_glm.Rmd
+++ b/man/rmd/logistic_reg_glm.Rmd
@@ -20,6 +20,10 @@ logistic_reg() %>%
```{r child = "template-makes-dummies.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#logistic-reg-glm) for `logistic_reg()` with the `"glm"` engine.
+
## References
- Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer.
diff --git a/man/rmd/logistic_reg_glmnet.Rmd b/man/rmd/logistic_reg_glmnet.Rmd
index 0835bed75..2f27623ee 100644
--- a/man/rmd/logistic_reg_glmnet.Rmd
+++ b/man/rmd/logistic_reg_glmnet.Rmd
@@ -54,6 +54,10 @@ logistic_reg(penalty = double(1), mixture = double(1)) %>%
```
By default, [glmnet::glmnet()] uses the argument `standardize = TRUE` to center and scale the data.
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#logistic-reg-glmnet) for `logistic_reg()` with the `"glmnet"` engine.
+
## References
- Hastie, T, R Tibshirani, and M Wainwright. 2015. _Statistical Learning with Sparsity_. CRC Press.
diff --git a/man/rmd/logistic_reg_keras.Rmd b/man/rmd/logistic_reg_keras.Rmd
index 4818f800e..69172d1dd 100644
--- a/man/rmd/logistic_reg_keras.Rmd
+++ b/man/rmd/logistic_reg_keras.Rmd
@@ -53,6 +53,9 @@ logistic_reg(penalty = double(1)) %>%
```{r child = "template-same-scale.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#logistic-reg-keras) for `logistic_reg()` with the `"keras"` engine.
## References
diff --git a/man/rmd/logistic_reg_stan.Rmd b/man/rmd/logistic_reg_stan.Rmd
index cab623bfd..7160fb896 100644
--- a/man/rmd/logistic_reg_stan.Rmd
+++ b/man/rmd/logistic_reg_stan.Rmd
@@ -39,6 +39,10 @@ Note that the `refresh` default prevents logging of the estimation process. Chan
For prediction, the `"stan"` engine can compute posterior intervals analogous to confidence and prediction intervals. In these instances, the units are the original outcome and when `std_error = TRUE`, the standard deviation of the posterior distribution (or posterior predictive distribution as appropriate) is returned.
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#logistic-reg-stan) for `logistic_reg()` with the `"stan"` engine.
+
## References
- McElreath, R. 2020 _Statistical Rethinking_. CRC Press.
diff --git a/man/rmd/mars_earth.Rmd b/man/rmd/mars_earth.Rmd
index 9e730d326..39dc42f5f 100644
--- a/man/rmd/mars_earth.Rmd
+++ b/man/rmd/mars_earth.Rmd
@@ -61,6 +61,10 @@ An alternate method for using MARs for categorical outcomes can be found in [dis
```{r child = "template-makes-dummies.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#mars-earth) for `mars()` with the `"earth"` engine.
+
## References
- Friedman, J. 1991. "Multivariate Adaptive Regression Splines." _The Annals of Statistics_, vol. 19, no. 1, pp. 1-67.
diff --git a/man/rmd/mlp_keras.Rmd b/man/rmd/mlp_keras.Rmd
index bc980e7b9..e237af08f 100644
--- a/man/rmd/mlp_keras.Rmd
+++ b/man/rmd/mlp_keras.Rmd
@@ -72,6 +72,10 @@ mlp(
```{r child = "template-same-scale.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#mlp-keras) for `mlp()` with the `"keras"` engine.
+
## References
- Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer.
diff --git a/man/rmd/mlp_nnet.Rmd b/man/rmd/mlp_nnet.Rmd
index b4568dfed..3486f4921 100644
--- a/man/rmd/mlp_nnet.Rmd
+++ b/man/rmd/mlp_nnet.Rmd
@@ -73,6 +73,10 @@ mlp(
```{r child = "template-same-scale.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#mlp-nnet) for `mlp()` with the `"nnet"` engine.
+
## References
- Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer.
diff --git a/man/rmd/multinom_reg_glmnet.Rmd b/man/rmd/multinom_reg_glmnet.Rmd
index 339983ad9..998121d07 100644
--- a/man/rmd/multinom_reg_glmnet.Rmd
+++ b/man/rmd/multinom_reg_glmnet.Rmd
@@ -54,6 +54,10 @@ multinom_reg(penalty = double(1), mixture = double(1)) %>%
```
By default, [glmnet::glmnet()] uses the argument `standardize = TRUE` to center and scale the data.
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#multinom-reg-glmnet) for `multinom_reg()` with the `"glmnet"` engine.
+
## References
- Hastie, T, R Tibshirani, and M Wainwright. 2015. _Statistical Learning with Sparsity_. CRC Press.
diff --git a/man/rmd/multinom_reg_keras.Rmd b/man/rmd/multinom_reg_keras.Rmd
index 354b9fc36..3475f4409 100644
--- a/man/rmd/multinom_reg_keras.Rmd
+++ b/man/rmd/multinom_reg_keras.Rmd
@@ -53,6 +53,9 @@ multinom_reg(penalty = double(1)) %>%
```{r child = "template-same-scale.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#multinom-reg-keras) for `multinom_reg()` with the `"keras"` engine.
## References
diff --git a/man/rmd/multinom_reg_nnet.Rmd b/man/rmd/multinom_reg_nnet.Rmd
index 107262d88..9cd571b76 100644
--- a/man/rmd/multinom_reg_nnet.Rmd
+++ b/man/rmd/multinom_reg_nnet.Rmd
@@ -51,6 +51,10 @@ multinom_reg(penalty = double(1)) %>%
```{r child = "template-same-scale.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#multinom-reg-nnet) for `multinom_reg()` with the `"nnet"` engine.
+
## References
- Luraschi, J, K Kuo, and E Ruiz. 2019. _Mastering nnet with R_. O'Reilly Media
diff --git a/man/rmd/nearest_neighbor_kknn.Rmd b/man/rmd/nearest_neighbor_kknn.Rmd
index 4c9927966..838c92474 100644
--- a/man/rmd/nearest_neighbor_kknn.Rmd
+++ b/man/rmd/nearest_neighbor_kknn.Rmd
@@ -69,6 +69,10 @@ nearest_neighbor(
```{r child = "template-same-scale.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#nearest-neighbor-kknn) for `nearest_neighbor()` with the `"kknn"` engine.
+
## References
- Hechenbichler K. and Schliep K.P. (2004) [Weighted k-Nearest-Neighbor Techniques and Ordinal Classification](https://epub.ub.uni-muenchen.de/1769/), Discussion Paper 399, SFB 386, Ludwig-Maximilians University Munich
diff --git a/man/rmd/rand_forest_randomForest.Rmd b/man/rmd/rand_forest_randomForest.Rmd
index fe0f9ef8c..676395004 100644
--- a/man/rmd/rand_forest_randomForest.Rmd
+++ b/man/rmd/rand_forest_randomForest.Rmd
@@ -70,6 +70,10 @@ rand_forest(
```{r child = "template-tree-split-factors.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#rand-forest-randomForest) for `rand_forest()` with the `"randomForest"` engine.
+
## References
- Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer.
diff --git a/man/rmd/rand_forest_ranger.Rmd b/man/rmd/rand_forest_ranger.Rmd
index f8ae3f03c..bea7a4835 100644
--- a/man/rmd/rand_forest_ranger.Rmd
+++ b/man/rmd/rand_forest_ranger.Rmd
@@ -78,6 +78,10 @@ By default, parallel processing is turned off. When tuning, it is more efficient
For `ranger` confidence intervals, the intervals are constructed using the form `estimate +/- z * std_error`. For classification probabilities, these values can fall outside of `[0, 1]` and will be coerced to be in this range.
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#rand-forest-ranger) for `rand_forest()` with the `"ranger"` engine.
+
## References
- Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer.
diff --git a/man/rmd/svm_linear_LiblineaR.Rmd b/man/rmd/svm_linear_LiblineaR.Rmd
index f60c4b159..7d68e91df 100644
--- a/man/rmd/svm_linear_LiblineaR.Rmd
+++ b/man/rmd/svm_linear_LiblineaR.Rmd
@@ -70,6 +70,10 @@ Note that the `LiblineaR` engine does not produce class probabilities. When opti
```{r child = "template-same-scale.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#svm-linear-LiblineaR) for `svm_linear()` with the `"LiblineaR"` engine.
+
## References
- Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer.
diff --git a/man/rmd/svm_linear_kernlab.Rmd b/man/rmd/svm_linear_kernlab.Rmd
index 80fd9a8fb..9c7cec545 100644
--- a/man/rmd/svm_linear_kernlab.Rmd
+++ b/man/rmd/svm_linear_kernlab.Rmd
@@ -68,6 +68,10 @@ Note that the `"kernlab"` engine does not naturally estimate class probabilities
```{r child = "template-same-scale.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#svm-linear-kernlab) for `svm_linear()` with the `"kernlab"` engine.
+
## References
- Lin, HT, and R Weng. ["A Note on Platt’s Probabilistic Outputs for Support Vector Machines"](https://www.csie.ntu.edu.tw/~cjlin/papers/plattprob.pdf)
diff --git a/man/rmd/svm_poly_kernlab.Rmd b/man/rmd/svm_poly_kernlab.Rmd
index b543c43f5..179d3f157 100644
--- a/man/rmd/svm_poly_kernlab.Rmd
+++ b/man/rmd/svm_poly_kernlab.Rmd
@@ -72,6 +72,10 @@ Note that the `"kernlab"` engine does not naturally estimate class probabilities
```{r child = "template-same-scale.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#svm-poly-kernlab) for `svm_poly()` with the `"kernlab"` engine.
+
## References
- Lin, HT, and R Weng. ["A Note on Platt’s Probabilistic Outputs for Support Vector Machines"](https://www.csie.ntu.edu.tw/~cjlin/papers/plattprob.pdf)
diff --git a/man/rmd/svm_rbf_kernlab.Rmd b/man/rmd/svm_rbf_kernlab.Rmd
index a01a4f710..b62abaf5f 100644
--- a/man/rmd/svm_rbf_kernlab.Rmd
+++ b/man/rmd/svm_rbf_kernlab.Rmd
@@ -72,6 +72,10 @@ Note that the `"kernlab"` engine does not naturally estimate class probabilities
```{r child = "template-same-scale.Rmd"}
```
+## Examples
+
+The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#svm-rbf-kernlab) for `svm_rbf()` with the `"kernlab"` engine.
+
## References
- Lin, HT, and R Weng. ["A Note on Platt’s Probabilistic Outputs for Support Vector Machines"](https://www.csie.ntu.edu.tw/~cjlin/papers/plattprob.pdf)
diff --git a/vignettes/articles/Examples.Rmd b/vignettes/articles/Examples.Rmd
new file mode 100644
index 000000000..b0dd7ca0b
--- /dev/null
+++ b/vignettes/articles/Examples.Rmd
@@ -0,0 +1,1376 @@
+---
+title: "Fitting and Predicting with parsnip"
+vignette: >
+ %\VignetteEngine{knitr::rmarkdown}
+ %\VignetteIndexEntry{Fitting and Predicting with parsnip}
+output:
+ knitr:::html_vignette
+---
+
+```{r startup, include = FALSE}
+library(utils)
+library(ggplot2)
+theme_set(theme_bw())
+```
+
+These examples show how to *fit* and *predict* with different combinations of model, mode, and engine. As a reminder, in parsnip,
+
+- the **model type** differentiates basic modeling approaches, such as random forests, logistic regression, linear support vector machines, etc.,
+
+- the **mode** denotes in what kind of modeling context it will be used (most commonly, classification or regression), and
+
+- the computational **engine** indicates how the model is fit, such as with a specific R package implementation or even methods outside of R like Keras or Stan.
+
+The following examples use consistent data sets throughout. For regression, we use the Chicago ridership data. For classification, we use an artificial data set for a binary example and the Palmer penguins data for a multiclass example.
+
+
+## `boost_tree()` models
+
+ With the `"xgboost"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ bt_reg_spec <-
+ boost_tree(trees = 15) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("regression") %>%
+ set_engine("xgboost")
+ bt_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ bt_reg_fit <- bt_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ bt_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(bt_reg_fit, Chicago_test)
+ ```
+
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ bt_cls_spec <-
+ boost_tree(trees = 15) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("classification") %>%
+ set_engine("xgboost")
+ bt_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ bt_cls_fit <- bt_cls_spec %>% fit(Class ~ ., data = data_train)
+ bt_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(bt_cls_fit, data_test),
+ predict(bt_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"C5.0"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ bt_cls_spec <-
+ boost_tree(trees = 15) %>%
+ set_mode("classification") %>%
+ set_engine("C5.0")
+ bt_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ bt_cls_fit <- bt_cls_spec %>% fit(Class ~ ., data = data_train)
+ bt_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(bt_cls_fit, data_test),
+ predict(bt_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"rpart"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ dt_reg_spec <-
+ decision_tree(tree_depth = 30) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("regression") %>%
+ set_engine("rpart")
+ dt_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ dt_reg_fit <- dt_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ dt_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(dt_reg_fit, Chicago_test)
+ ```
+
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ dt_cls_spec <-
+ decision_tree(tree_depth = 30) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("classification") %>%
+ set_engine("rpart")
+ dt_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ dt_cls_fit <- dt_cls_spec %>% fit(Class ~ ., data = data_train)
+ dt_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(dt_cls_fit, data_test),
+ predict(dt_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"C5.0"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ dt_cls_spec <-
+ decision_tree(min_n = 2) %>%
+ set_mode("classification") %>%
+ set_engine("C5.0")
+ dt_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ dt_cls_fit <- dt_cls_spec %>% fit(Class ~ ., data = data_train)
+ dt_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(dt_cls_fit, data_test),
+ predict(dt_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"lm"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ linreg_reg_spec <-
+ linear_reg() %>%
+ set_engine("lm")
+ linreg_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ linreg_reg_fit <- linreg_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ linreg_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(linreg_reg_fit, Chicago_test)
+ ```
+
+ With the `"glmnet"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ linreg_reg_spec <-
+ linear_reg(penalty = 0.1) %>%
+ set_engine("glmnet")
+ linreg_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ linreg_reg_fit <- linreg_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ linreg_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(linreg_reg_fit, Chicago_test)
+ ```
+
+ With the `"keras"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ linreg_reg_spec <-
+ linear_reg(penalty = 0.1) %>%
+ set_engine("keras")
+ linreg_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ linreg_reg_fit <- linreg_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ linreg_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(linreg_reg_fit, Chicago_test)
+ ```
+
+ With the `"stan"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ linreg_reg_spec <-
+ linear_reg() %>%
+ set_engine("stan")
+ linreg_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ linreg_reg_fit <- linreg_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ linreg_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(linreg_reg_fit, Chicago_test)
+ ```
+
+ With the `"glm"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ logreg_cls_spec <-
+ logistic_reg() %>%
+ set_engine("glm")
+ logreg_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ logreg_cls_fit <- logreg_cls_spec %>% fit(Class ~ ., data = data_train)
+ logreg_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(logreg_cls_fit, data_test),
+ predict(logreg_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"glmnet"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ logreg_cls_spec <-
+ logistic_reg(penalty = 0.1) %>%
+ set_engine("glmnet")
+ logreg_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ logreg_cls_fit <- logreg_cls_spec %>% fit(Class ~ ., data = data_train)
+ logreg_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(logreg_cls_fit, data_test),
+ predict(logreg_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"keras"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ logreg_cls_spec <-
+ logistic_reg(penalty = 0.1) %>%
+ set_engine("keras")
+ logreg_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ logreg_cls_fit <- logreg_cls_spec %>% fit(Class ~ ., data = data_train)
+ logreg_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(logreg_cls_fit, data_test),
+ predict(logreg_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"LiblineaR"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ logreg_cls_spec <-
+ logistic_reg(penalty = 0.1) %>%
+ set_engine("LiblineaR")
+ logreg_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ logreg_cls_fit <- logreg_cls_spec %>% fit(Class ~ ., data = data_train)
+ logreg_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(logreg_cls_fit, data_test),
+ predict(logreg_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"stan"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ logreg_cls_spec <-
+ logistic_reg() %>%
+ set_engine("stan")
+ logreg_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ logreg_cls_fit <- logreg_cls_spec %>% fit(Class ~ ., data = data_train)
+ logreg_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(logreg_cls_fit, data_test),
+ predict(logreg_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"earth"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ mars_reg_spec <-
+ mars(prod_degree = 1, prune_method = "backward") %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("regression") %>%
+ set_engine("earth")
+ mars_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ mars_reg_fit <- mars_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ mars_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(mars_reg_fit, Chicago_test)
+ ```
+
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ mars_cls_spec <-
+ mars(prod_degree = 1, prune_method = "backward") %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("classification") %>%
+ set_engine("earth")
+ mars_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ mars_cls_fit <- mars_cls_spec %>% fit(Class ~ ., data = data_train)
+ mars_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(mars_cls_fit, data_test),
+ predict(mars_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"nnet"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ mlp_reg_spec <-
+ mlp(penalty = 0, epochs = 100) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("regression") %>%
+ set_engine("nnet")
+ mlp_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ mlp_reg_fit <- mlp_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ mlp_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(mlp_reg_fit, Chicago_test)
+ ```
+
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ mlp_cls_spec <-
+ mlp(penalty = 0, epochs = 100) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("classification") %>%
+ set_engine("nnet")
+ mlp_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ mlp_cls_fit <- mlp_cls_spec %>% fit(Class ~ ., data = data_train)
+ mlp_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(mlp_cls_fit, data_test),
+ predict(mlp_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"keras"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ mlp_reg_spec <-
+ mlp(penalty = 0, epochs = 20) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("regression") %>%
+ set_engine("keras")
+ mlp_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ mlp_reg_fit <- mlp_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ mlp_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(mlp_reg_fit, Chicago_test)
+ ```
+
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ mlp_cls_spec <-
+ mlp(penalty = 0, epochs = 20) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("classification") %>%
+ set_engine("keras")
+ mlp_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ mlp_cls_fit <- mlp_cls_spec %>% fit(Class ~ ., data = data_train)
+ mlp_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(mlp_cls_fit, data_test),
+ predict(mlp_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"glmnet"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-multi-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ mr_cls_spec <-
+ multinom_reg(penalty = 0.1) %>%
+ set_engine("glmnet")
+ mr_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ mr_cls_fit <- mr_cls_spec %>% fit(island ~ ., data = penguins_train)
+ mr_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(mr_cls_fit, penguins_test),
+ predict(mr_cls_fit, penguins_test, type = "prob")
+ )
+ ```
+
+ With the `"keras"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-multi-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ mr_cls_spec <-
+ multinom_reg(penalty = 0.1) %>%
+ set_engine("keras")
+ mr_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ mr_cls_fit <- mr_cls_spec %>% fit(island ~ ., data = penguins_train)
+ mr_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(mr_cls_fit, penguins_test),
+ predict(mr_cls_fit, penguins_test, type = "prob")
+ )
+ ```
+
+ With the `"nnet"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-multi-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ mr_cls_spec <-
+ multinom_reg(penalty = 0.1) %>%
+ set_engine("nnet")
+ mr_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ mr_cls_fit <- mr_cls_spec %>% fit(island ~ ., data = penguins_train)
+ mr_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(mr_cls_fit, penguins_test),
+ predict(mr_cls_fit, penguins_test, type = "prob")
+ )
+ ```
+
+ With the `"kknn"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ knn_reg_spec <-
+ nearest_neighbor(neighbors = 5, weight_func = "triangular") %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("regression") %>%
+ set_engine("kknn")
+ knn_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ knn_reg_fit <- knn_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ knn_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(knn_reg_fit, Chicago_test)
+ ```
+
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ Since there are two classes, we'll use an odd number of neighbors to avoid ties:
+
+ ```{r}
+ knn_cls_spec <-
+ nearest_neighbor(neighbors = 11, weight_func = "triangular") %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("classification") %>%
+ set_engine("kknn")
+ knn_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ knn_cls_fit <- knn_cls_spec %>% fit(Class ~ ., data = data_train)
+ knn_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(knn_cls_fit, data_test),
+ predict(knn_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"ranger"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ rf_reg_spec <-
+ rand_forest(trees = 200, min_n = 5) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("regression") %>%
+ set_engine("ranger")
+ rf_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ rf_reg_fit <- rf_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ rf_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(rf_reg_fit, Chicago_test)
+ ```
+
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ rf_cls_spec <-
+ rand_forest(trees = 200, min_n = 5) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("classification") %>%
+ set_engine("ranger")
+ rf_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ rf_cls_fit <- rf_cls_spec %>% fit(Class ~ ., data = data_train)
+ rf_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(rf_cls_fit, data_test),
+ predict(rf_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"randomForest"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ rf_reg_spec <-
+ rand_forest(trees = 200, min_n = 5) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("regression") %>%
+ set_engine("randomForest")
+ rf_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ rf_reg_fit <- rf_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ rf_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(rf_reg_fit, Chicago_test)
+ ```
+
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ rf_cls_spec <-
+ rand_forest(trees = 200, min_n = 5) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("classification") %>%
+ set_engine("randomForest")
+ rf_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ rf_cls_fit <- rf_cls_spec %>% fit(Class ~ ., data = data_train)
+ rf_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(rf_cls_fit, data_test),
+ predict(rf_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"LiblineaR"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ svm_reg_spec <-
+ svm_linear(cost = 1, margin = 0.1) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("regression") %>%
+ set_engine("LiblineaR")
+ svm_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ svm_reg_fit <- svm_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ svm_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(svm_reg_fit, Chicago_test)
+ ```
+
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ svm_cls_spec <-
+ svm_linear(cost = 1) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("classification") %>%
+ set_engine("LiblineaR")
+ svm_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ svm_cls_fit <- svm_cls_spec %>% fit(Class ~ ., data = data_train)
+ svm_cls_fit
+ ```
+
+ The holdout data can be predicted for hard class predictions.
+
+ ```{r}
+ predict(svm_cls_fit, data_test)
+ ```
+
+ With the `"kernlab"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ svm_reg_spec <-
+ svm_linear(cost = 1, margin = 0.1) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("regression") %>%
+ set_engine("kernlab")
+ svm_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ svm_reg_fit <- svm_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ svm_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(svm_reg_fit, Chicago_test)
+ ```
+
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ svm_cls_spec <-
+ svm_linear(cost = 1) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("classification") %>%
+ set_engine("kernlab")
+ svm_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ svm_cls_fit <- svm_cls_spec %>% fit(Class ~ ., data = data_train)
+ svm_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(svm_cls_fit, data_test),
+ predict(svm_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"kernlab"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ svm_reg_spec <-
+ svm_poly(cost = 1, margin = 0.1) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("regression") %>%
+ set_engine("kernlab")
+ svm_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ svm_reg_fit <- svm_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ svm_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(svm_reg_fit, Chicago_test)
+ ```
+
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ svm_cls_spec <-
+ svm_poly(cost = 1) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("classification") %>%
+ set_engine("kernlab")
+ svm_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ svm_cls_fit <- svm_cls_spec %>% fit(Class ~ ., data = data_train)
+ svm_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(svm_cls_fit, data_test),
+ predict(svm_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+ With the `"kernlab"` engine
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-reg-chicago.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ svm_reg_spec <-
+ svm_rbf(cost = 1, margin = 0.1) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("regression") %>%
+ set_engine("kernlab")
+ svm_reg_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ svm_reg_fit <- svm_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
+ svm_reg_fit
+ ```
+
+ The holdout data can be predicted:
+
+ ```{r}
+ predict(svm_reg_fit, Chicago_test)
+ ```
+
+
+ ```{r echo=FALSE}
+ knitr::spin_child("template-cls-two-class.R")
+ ```
+
+ We can define the model with specific parameters:
+
+ ```{r}
+ svm_cls_spec <-
+ svm_rbf(cost = 1) %>%
+ # This model can be used for classification or regression, so set mode
+ set_mode("classification") %>%
+ set_engine("kernlab")
+ svm_cls_spec
+ ```
+
+ Now we create the model fit object:
+
+ ```{r}
+ set.seed(1)
+ svm_cls_fit <- svm_cls_spec %>% fit(Class ~ ., data = data_train)
+ svm_cls_fit
+ ```
+
+ The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
+
+ ```{r}
+ bind_cols(
+ predict(svm_cls_fit, data_test),
+ predict(svm_cls_fit, data_test, type = "prob")
+ )
+ ```
+
+