Skip to content

Commit 56e8b7c

Browse files
authored
Merge pull request #248 from hfrick/vignette-scratch
update vignette "Making a parsnip model from scratch"
2 parents f4d1fb3 + fb6535a commit 56e8b7c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

R/aaa_models.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ check_interface_val <- function(x) {
304304
#' @param original A single character string for the argument name that
305305
#' underlying model function uses.
306306
#' @param value A list that conforms to the `fit_obj` or `pred_obj` description
307-
#' above, depending on context.
307+
#' below, depending on context.
308308
#' @param pre,post Optional functions for pre- and post-processing of prediction
309309
#' results.
310310
#' @param ... Optional arguments that should be passed into the `args` slot for

vignettes/articles/Scratch.Rmd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ Before proceeding, it helps to to review how `parsnip` categorizes models:
4848

4949
* Within a model type is the _mode_. This relates to the modeling goal. Currently the two modes in the package are "regression" and "classification". Some models have methods for both models (e.g. nearest neighbors) while others are specific to a single mode (e.g. logistic regression).
5050

51-
* The computation _engine_ is a combination of the estimation method and the implementation. For example, for linear regression, one model is `"lm"` and this uses ordinary least squares analysis using the `lm` package. Another engine is `"stan"` which uses the Stan infrastructure to estimate parameters using Bayes rule.
51+
* The computation _engine_ is a combination of the estimation method and the implementation. For example, for linear regression, one engine is `"lm"` and this uses ordinary least squares analysis using the `lm` package. Another engine is `"stan"` which uses the Stan infrastructure to estimate parameters using Bayes rule.
5252

5353
When adding a model into `parsnip`, the user has to specific which modes and engines are used. The package also enables users to add a new mode or engine to an existing model.
5454

5555
## The General Process
5656

5757
`parsnip` stores information about the models in an internal environment object. The environment can be accessed via the function `get_model_env()`. The package includes a variety of functions that can get or set the different aspects of the models.
5858

59-
If you are adding a new model form your own package, you can use these functions to add new entries into the model environment.
59+
If you are adding a new model from your own package, you can use these functions to add new entries into the model environment.
6060

6161
## Step 1. Register the Model, Modes, and Arguments.
6262

@@ -103,7 +103,7 @@ set_model_arg(
103103
show_model_info("mixture_da")
104104
```
105105

106-
## Step 3. Create the model function
106+
## Step 2. Create the model function
107107

108108
This is a fairly simple function that can follow a basic template. The main arguments to our function will be:
109109

@@ -146,7 +146,7 @@ Now that `parsnip` knows about the model, mode, and engine, we can give it the i
146146

147147
* `func` is the package and name of the function that will be called. If you are using a locally defined function, only `fun` is required.
148148

149-
* `defaults` is an optional list of arguments to the fit function that the user can change, but whose defaults can be set here. This isn't needed in this case, but is describe later in this document.
149+
* `defaults` is an optional list of arguments to the fit function that the user can change, but whose defaults can be set here. This isn't needed in this case, but is described later in this document.
150150

151151
For the first engine:
152152

@@ -165,7 +165,7 @@ set_fit(
165165
show_model_info("mixture_da")
166166
```
167167

168-
## Step 3. Add Modules for Prediction
168+
## Step 4. Add Modules for Prediction
169169

170170
Similar to the fitting module, we specify the code for making different types of predictions. To make hard class predictions, the `class` object contains the details. The elements of the list are:
171171

@@ -413,7 +413,7 @@ This would **not** include making dummy variables and `model.matrix` stuff. `par
413413

414414
### Why would I postprocess my predictions?
415415

416-
What comes back from some R functions make be somewhat... arcane or problematic. As an example, for `xgboost`, if you fit a multiclass boosted tree, you might expect the class probabilities to come back as a matrix (narrator: they don't). If you have four classes and make predictions on three samples, you get a vector of 12 probability values. You need to convert these to a rectangular data set.
416+
What comes back from some R functions may be somewhat... arcane or problematic. As an example, for `xgboost`, if you fit a multiclass boosted tree, you might expect the class probabilities to come back as a matrix (narrator: they don't). If you have four classes and make predictions on three samples, you get a vector of 12 probability values. You need to convert these to a rectangular data set.
417417

418418
Another example is the predict method for `ranger`, which encapsulates the actual predictions in a more complex object structure.
419419

0 commit comments

Comments
 (0)