Title: | Model Menu for Radiant: Business Analytics using R and Shiny |
---|---|
Description: | The Radiant Model menu includes interfaces for linear and logistic regression, naive Bayes, neural networks, classification and regression trees, model evaluation, collaborative filtering, decision analysis, and simulation. The application extends the functionality in 'radiant.data'. |
Authors: | Vincent Nijs [aut, cre] |
Maintainer: | Vincent Nijs <[email protected]> |
License: | AGPL-3 | file LICENSE |
Version: | 1.6.7 |
Built: | 2024-10-11 05:19:30 UTC |
Source: | https://github.com/radiant-rstats/radiant.model |
Convenience function used in "simulater"
.as_int(x, dataset = list())
.as_int(x, dataset = list())
x |
Character vector to be converted to integer |
dataset |
Data list |
An integer vector
Convenience function used in "simulater"
.as_num(x, dataset = list())
.as_num(x, dataset = list())
x |
Character vector to be converted to an numeric value |
dataset |
Data list |
An numeric vector
Area Under the RO Curve (AUC)
auc(pred, rvar, lev)
auc(pred, rvar, lev)
pred |
Prediction or predictor |
rvar |
Response variable |
lev |
The level in the response variable defined as success |
See https://radiant-rstats.github.io/docs/model/evalbin.html for an example in Radiant
AUC statistic
evalbin
to calculate results
summary.evalbin
to summarize results
plot.evalbin
to plot results
auc(runif(20000), dvd$buy, "yes") auc(ifelse(dvd$buy == "yes", 1, 0), dvd$buy, "yes")
auc(runif(20000), dvd$buy, "yes") auc(ifelse(dvd$buy == "yes", 1, 0), dvd$buy, "yes")
Catalog sales for men's and women's apparel
data(catalog)
data(catalog)
A data frame with 200 rows and 5 variables
Description provided in attr(catalog, "description")
Confidence interval for robust estimators
confint_robust(object, level = 0.95, dist = "norm", vcov = NULL, ...)
confint_robust(object, level = 0.95, dist = "norm", vcov = NULL, ...)
object |
A fitted model object |
level |
The confidence level required |
dist |
Distribution to use ("norm" or "t") |
vcov |
Covariance matrix generated by, e.g., sandwich::vcovHC |
... |
Additional argument(s) for methods |
Wrapper for confint with robust standard errors. See https://stackoverflow.com/questions/3817182/vcovhc-and-confidence-interval/3820125#3820125
Confusion matrix
confusion( dataset, pred, rvar, lev = "", cost = 1, margin = 2, scale = 1, train = "All", data_filter = "", arr = "", rows = NULL, envir = parent.frame(), ... )
confusion( dataset, pred, rvar, lev = "", cost = 1, margin = 2, scale = 1, train = "All", data_filter = "", arr = "", rows = NULL, envir = parent.frame(), ... )
dataset |
Dataset |
pred |
Predictions or predictors |
rvar |
Response variable |
lev |
The level in the response variable defined as success |
cost |
Cost for each connection (e.g., email or mailing) |
margin |
Margin on each customer purchase |
scale |
Scaling factor to apply to calculations |
train |
Use data from training ("Training"), test ("Test"), both ("Both"), or all data ("All") to evaluate model evalbin |
data_filter |
Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000") |
arr |
Expression to arrange (sort) the data on (e.g., "color, desc(price)") |
rows |
Rows to select from the specified dataset |
envir |
Environment to extract data from |
... |
further arguments passed to or from other methods |
Confusion matrix and additional metrics to evaluate binary classification models. See https://radiant-rstats.github.io/docs/model/evalbin.html for an example in Radiant
A list of results
summary.confusion
to summarize results
plot.confusion
to plot results
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% confusion(c("pred1", "pred2"), "buy") %>% str()
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% confusion(c("pred1", "pred2"), "buy") %>% str()
Collaborative Filtering
crs( dataset, id, prod, pred, rate, data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
crs( dataset, id, prod, pred, rate, data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
dataset |
Dataset |
id |
String with name of the variable containing user ids |
prod |
String with name of the variable with product ids |
pred |
Products to predict for |
rate |
String with name of the variable with product ratings |
data_filter |
Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "training == 1") |
arr |
Expression to arrange (sort) the data on (e.g., "color, desc(price)") |
rows |
Rows to select from the specified dataset |
envir |
Environment to extract data from |
See https://radiant-rstats.github.io/docs/model/crs.html for an example in Radiant
A data.frame with the original data and a new column with predicted ratings
summary.crs
to summarize results
plot.crs
to plot results if the actual ratings are available
crs(ratings, id = "Users", prod = "Movies", pred = c("M6", "M7", "M8", "M9", "M10"), rate = "Ratings", data_filter = "training == 1" ) %>% str()
crs(ratings, id = "Users", prod = "Movies", pred = c("M6", "M7", "M8", "M9", "M10"), rate = "Ratings", data_filter = "training == 1" ) %>% str()
Classification and regression trees based on the rpart package
crtree( dataset, rvar, evar, type = "", lev = "", wts = "None", minsplit = 2, minbucket = round(minsplit/3), cp = 0.001, pcp = NA, nodes = NA, K = 10, seed = 1234, split = "gini", prior = NA, adjprob = TRUE, cost = NA, margin = NA, check = "", data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
crtree( dataset, rvar, evar, type = "", lev = "", wts = "None", minsplit = 2, minbucket = round(minsplit/3), cp = 0.001, pcp = NA, nodes = NA, K = 10, seed = 1234, split = "gini", prior = NA, adjprob = TRUE, cost = NA, margin = NA, check = "", data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
dataset |
Dataset |
rvar |
The response variable in the model |
evar |
Explanatory variables in the model |
type |
Model type (i.e., "classification" or "regression") |
lev |
The level in the response variable defined as _success_ |
wts |
Weights to use in estimation |
minsplit |
The minimum number of observations that must exist in a node in order for a split to be attempted. |
minbucket |
the minimum number of observations in any terminal <leaf> node. If only one of minbucket or minsplit is specified, the code either sets minsplit to minbucket*3 or minbucket to minsplit/3, as appropriate. |
cp |
Minimum proportion of root node deviance required for split (default = 0.001) |
pcp |
Complexity parameter to use for pruning |
nodes |
Maximum size of tree in number of nodes to return |
K |
Number of folds use in cross-validation |
seed |
Random seed used for cross-validation |
split |
Splitting criterion to use (i.e., "gini" or "information") |
prior |
Adjust the initial probability for the selected level (e.g., set to .5 in unbalanced samples) |
adjprob |
Setting a prior will rescale the predicted probabilities. Set adjprob to TRUE to adjust the probabilities back to their original scale after estimation |
cost |
Cost for each treatment (e.g., mailing) |
margin |
Margin associated with a successful treatment (e.g., a purchase) |
check |
Optional estimation parameters (e.g., "standardize") |
data_filter |
Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000") |
arr |
Expression to arrange (sort) the data on (e.g., "color, desc(price)") |
rows |
Rows to select from the specified dataset |
envir |
Environment to extract data from |
See https://radiant-rstats.github.io/docs/model/crtree.html for an example in Radiant
A list with all variables defined in crtree as an object of class tree
summary.crtree
to summarize results
plot.crtree
to plot results
predict.crtree
for prediction
crtree(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% summary() result <- crtree(titanic, "survived", c("pclass", "sex")) %>% summary() result <- crtree(diamonds, "price", c("carat", "clarity"), type = "regression") %>% str()
crtree(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% summary() result <- crtree(titanic, "survived", c("pclass", "sex")) %>% summary() result <- crtree(diamonds, "price", c("carat", "clarity"), type = "regression") %>% str()
Cross-validation for Classification and Regression Trees
cv.crtree( object, K = 5, repeats = 1, cp, pcp = seq(0, 0.01, length.out = 11), seed = 1234, trace = TRUE, fun, ... )
cv.crtree( object, K = 5, repeats = 1, cp, pcp = seq(0, 0.01, length.out = 11), seed = 1234, trace = TRUE, fun, ... )
object |
Object of type "rpart" or "crtree" to use as a starting point for cross validation |
K |
Number of cross validation passes to use |
repeats |
Number of times to repeat the K cross-validation steps |
cp |
Complexity parameter used when building the (e.g., 0.0001) |
pcp |
Complexity parameter to use for pruning |
seed |
Random seed to use as the starting point |
trace |
Print progress |
fun |
Function to use for model evaluation (e.g., auc for classification or RMSE for regression) |
... |
Additional arguments to be passed to 'fun' |
See https://radiant-rstats.github.io/docs/model/crtree.html for an example in Radiant
A data.frame sorted by the mean, sd, min, and max of the performance metric
crtree
to generate an initial model that can be passed to cv.crtree
Rsq
to calculate an R-squared measure for a regression
RMSE
to calculate the Root Mean Squared Error for a regression
MAE
to calculate the Mean Absolute Error for a regression
auc
to calculate the area under the ROC curve for classification
profit
to calculate profits for classification at a cost/margin threshold
## Not run: result <- crtree(dvd, "buy", c("coupon", "purch", "last")) cv.crtree(result, cp = 0.0001, pcp = seq(0, 0.01, length.out = 11)) cv.crtree(result, cp = 0.0001, pcp = c(0, 0.001, 0.002), fun = profit, cost = 1, margin = 5) result <- crtree(diamonds, "price", c("carat", "color", "clarity"), type = "regression", cp = 0.001) cv.crtree(result, cp = 0.001, pcp = seq(0, 0.01, length.out = 11), fun = MAE) ## End(Not run)
## Not run: result <- crtree(dvd, "buy", c("coupon", "purch", "last")) cv.crtree(result, cp = 0.0001, pcp = seq(0, 0.01, length.out = 11)) cv.crtree(result, cp = 0.0001, pcp = c(0, 0.001, 0.002), fun = profit, cost = 1, margin = 5) result <- crtree(diamonds, "price", c("carat", "color", "clarity"), type = "regression", cp = 0.001) cv.crtree(result, cp = 0.001, pcp = seq(0, 0.01, length.out = 11), fun = MAE) ## End(Not run)
Cross-validation for Gradient Boosted Trees
cv.gbt( object, K = 5, repeats = 1, params = list(), nrounds = 500, early_stopping_rounds = 10, nthread = 12, train = NULL, type = "classification", trace = TRUE, seed = 1234, maximize = NULL, fun, ... )
cv.gbt( object, K = 5, repeats = 1, params = list(), nrounds = 500, early_stopping_rounds = 10, nthread = 12, train = NULL, type = "classification", trace = TRUE, seed = 1234, maximize = NULL, fun, ... )
object |
Object of type "gbt" or "ranger" |
K |
Number of cross validation passes to use (aka nfold) |
repeats |
Repeated cross validation |
params |
List of parameters (see XGBoost documentation) |
nrounds |
Number of trees to create |
early_stopping_rounds |
Early stopping rule |
nthread |
Number of parallel threads to use. Defaults to 12 if available |
train |
An optional xgb.DMatrix object containing the original training data. Not needed when using Radiant's gbt function |
type |
Model type ("classification" or "regression") |
trace |
Print progress |
seed |
Random seed to use as the starting point |
maximize |
When a custom function is used, xgb.cv requires the user indicate if the function output should be maximized (TRUE) or minimized (FALSE) |
fun |
Function to use for model evaluation (i.e., auc for classification and RMSE for regression) |
... |
Additional arguments to be passed to 'fun' |
See https://radiant-rstats.github.io/docs/model/gbt.html for an example in Radiant
A data.frame sorted by the mean of the performance metric
gbt
to generate an initial model that can be passed to cv.gbt
Rsq
to calculate an R-squared measure for a regression
RMSE
to calculate the Root Mean Squared Error for a regression
MAE
to calculate the Mean Absolute Error for a regression
auc
to calculate the area under the ROC curve for classification
profit
to calculate profits for classification at a cost/margin threshold
## Not run: result <- gbt(dvd, "buy", c("coupon", "purch", "last")) cv.gbt(result, params = list(max_depth = 1:6)) cv.gbt(result, params = list(max_depth = 1:6), fun = "logloss") cv.gbt( result, params = list(learning_rate = seq(0.1, 1.0, 0.1)), maximize = TRUE, fun = profit, cost = 1, margin = 5 ) result <- gbt(diamonds, "price", c("carat", "color", "clarity"), type = "regression") cv.gbt(result, params = list(max_depth = 1:2, min_child_weight = 1:2)) cv.gbt(result, params = list(learning_rate = seq(0.1, 0.5, 0.1)), fun = Rsq, maximize = TRUE) cv.gbt(result, params = list(learning_rate = seq(0.1, 0.5, 0.1)), fun = MAE, maximize = FALSE) ## End(Not run)
## Not run: result <- gbt(dvd, "buy", c("coupon", "purch", "last")) cv.gbt(result, params = list(max_depth = 1:6)) cv.gbt(result, params = list(max_depth = 1:6), fun = "logloss") cv.gbt( result, params = list(learning_rate = seq(0.1, 1.0, 0.1)), maximize = TRUE, fun = profit, cost = 1, margin = 5 ) result <- gbt(diamonds, "price", c("carat", "color", "clarity"), type = "regression") cv.gbt(result, params = list(max_depth = 1:2, min_child_weight = 1:2)) cv.gbt(result, params = list(learning_rate = seq(0.1, 0.5, 0.1)), fun = Rsq, maximize = TRUE) cv.gbt(result, params = list(learning_rate = seq(0.1, 0.5, 0.1)), fun = MAE, maximize = FALSE) ## End(Not run)
Cross-validation for a Neural Network
cv.nn( object, K = 5, repeats = 1, decay = seq(0, 1, 0.2), size = 1:5, seed = 1234, trace = TRUE, fun, ... )
cv.nn( object, K = 5, repeats = 1, decay = seq(0, 1, 0.2), size = 1:5, seed = 1234, trace = TRUE, fun, ... )
object |
Object of type "nn" or "nnet" |
K |
Number of cross validation passes to use |
repeats |
Repeated cross validation |
decay |
Parameter decay |
size |
Number of units (nodes) in the hidden layer |
seed |
Random seed to use as the starting point |
trace |
Print progress |
fun |
Function to use for model evaluation (i.e., auc for classification and RMSE for regression) |
... |
Additional arguments to be passed to 'fun' |
See https://radiant-rstats.github.io/docs/model/nn.html for an example in Radiant
A data.frame sorted by the mean of the performance metric
nn
to generate an initial model that can be passed to cv.nn
Rsq
to calculate an R-squared measure for a regression
RMSE
to calculate the Root Mean Squared Error for a regression
MAE
to calculate the Mean Absolute Error for a regression
auc
to calculate the area under the ROC curve for classification
profit
to calculate profits for classification at a cost/margin threshold
## Not run: result <- nn(dvd, "buy", c("coupon", "purch", "last")) cv.nn(result, decay = seq(0, 1, .5), size = 1:2) cv.nn(result, decay = seq(0, 1, .5), size = 1:2, fun = profit, cost = 1, margin = 5) result <- nn(diamonds, "price", c("carat", "color", "clarity"), type = "regression") cv.nn(result, decay = seq(0, 1, .5), size = 1:2) cv.nn(result, decay = seq(0, 1, .5), size = 1:2, fun = Rsq) ## End(Not run)
## Not run: result <- nn(dvd, "buy", c("coupon", "purch", "last")) cv.nn(result, decay = seq(0, 1, .5), size = 1:2) cv.nn(result, decay = seq(0, 1, .5), size = 1:2, fun = profit, cost = 1, margin = 5) result <- nn(diamonds, "price", c("carat", "color", "clarity"), type = "regression") cv.nn(result, decay = seq(0, 1, .5), size = 1:2) cv.nn(result, decay = seq(0, 1, .5), size = 1:2, fun = Rsq) ## End(Not run)
Cross-validation for a Random Forest
cv.rforest( object, K = 5, repeats = 1, mtry = 1:5, num.trees = NULL, min.node.size = 1, sample.fraction = NA, trace = TRUE, seed = 1234, fun, ... )
cv.rforest( object, K = 5, repeats = 1, mtry = 1:5, num.trees = NULL, min.node.size = 1, sample.fraction = NA, trace = TRUE, seed = 1234, fun, ... )
object |
Object of type "rforest" or "ranger" |
K |
Number of cross validation passes to use |
repeats |
Repeated cross validation |
mtry |
Number of variables to possibly split at in each node. Default is the (rounded down) square root of the number variables |
num.trees |
Number of trees to create |
min.node.size |
Minimal node size |
sample.fraction |
Fraction of observations to sample. Default is 1 for sampling with replacement and 0.632 for sampling without replacement |
trace |
Print progress |
seed |
Random seed to use as the starting point |
fun |
Function to use for model evaluation (i.e., auc for classification and RMSE for regression) |
... |
Additional arguments to be passed to 'fun' |
See https://radiant-rstats.github.io/docs/model/rforest.html for an example in Radiant
A data.frame sorted by the mean of the performance metric
rforest
to generate an initial model that can be passed to cv.rforest
Rsq
to calculate an R-squared measure for a regression
RMSE
to calculate the Root Mean Squared Error for a regression
MAE
to calculate the Mean Absolute Error for a regression
auc
to calculate the area under the ROC curve for classification
profit
to calculate profits for classification at a cost/margin threshold
## Not run: result <- rforest(dvd, "buy", c("coupon", "purch", "last")) cv.rforest( result, mtry = 1:3, min.node.size = seq(1, 10, 5), num.trees = c(100, 200), sample.fraction = 0.632 ) result <- rforest(titanic, "survived", c("pclass", "sex"), max.depth = 1) cv.rforest(result, mtry = 1:3, min.node.size = seq(1, 10, 5)) cv.rforest(result, mtry = 1:3, num.trees = c(100, 200), fun = profit, cost = 1, margin = 5) result <- rforest(diamonds, "price", c("carat", "color", "clarity"), type = "regression") cv.rforest(result, mtry = 1:3, min.node.size = 1) cv.rforest(result, mtry = 1:3, min.node.size = 1, fun = Rsq) ## End(Not run)
## Not run: result <- rforest(dvd, "buy", c("coupon", "purch", "last")) cv.rforest( result, mtry = 1:3, min.node.size = seq(1, 10, 5), num.trees = c(100, 200), sample.fraction = 0.632 ) result <- rforest(titanic, "survived", c("pclass", "sex"), max.depth = 1) cv.rforest(result, mtry = 1:3, min.node.size = seq(1, 10, 5)) cv.rforest(result, mtry = 1:3, num.trees = c(100, 200), fun = profit, cost = 1, margin = 5) result <- rforest(diamonds, "price", c("carat", "color", "clarity"), type = "regression") cv.rforest(result, mtry = 1:3, min.node.size = 1) cv.rforest(result, mtry = 1:3, min.node.size = 1, fun = Rsq) ## End(Not run)
Direct marketing data
data(direct_marketing)
data(direct_marketing)
A data frame with 1,000 rows and 12 variables
Description provided in attr(direct_marketing, "description")
Create a decision tree
dtree(yl, opt = "max", base = character(0), envir = parent.frame())
dtree(yl, opt = "max", base = character(0), envir = parent.frame())
yl |
A yaml string or a list (e.g., from yaml::yaml.load_file()) |
opt |
Find the maximum ("max") or minimum ("min") value for each decision node |
base |
List of variable definitions from a base tree used when calling a sub-tree |
envir |
Environment to extract data from |
See https://radiant-rstats.github.io/docs/model/dtree.html for an example in Radiant
A list with the initial tree, the calculated tree, and a data.frame with results (i.e., payoffs, probabilities, etc.)
summary.dtree
to summarize results
plot.dtree
to plot results
sensitivity.dtree
to plot results
yaml::as.yaml(movie_contract) %>% cat() dtree(movie_contract, opt = "max") %>% summary(output = TRUE) dtree(movie_contract)$payoff dtree(movie_contract)$prob dtree(movie_contract)$solution_df
yaml::as.yaml(movie_contract) %>% cat() dtree(movie_contract, opt = "max") %>% summary(output = TRUE) dtree(movie_contract)$payoff dtree(movie_contract)$prob dtree(movie_contract)$solution_df
Parse yaml input for dtree to provide (more) useful error messages
dtree_parser(yl)
dtree_parser(yl)
yl |
A yaml string |
See https://radiant-rstats.github.io/docs/model/dtree.html for an example in Radiant
An updated yaml string or a vector messages to return to the users
dtree
to calculate tree
summary.dtree
to summarize results
plot.dtree
to plot results
Data on DVD sales
data(dvd)
data(dvd)
A data frame with 20,000 rows and 4 variables
Binary purchase response to coupon value. Description provided in attr(dvd,"description")
Evaluate the performance of different (binary) classification models
evalbin( dataset, pred, rvar, lev = "", qnt = 10, cost = 1, margin = 2, scale = 1, train = "All", data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
evalbin( dataset, pred, rvar, lev = "", qnt = 10, cost = 1, margin = 2, scale = 1, train = "All", data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
dataset |
Dataset |
pred |
Predictions or predictors |
rvar |
Response variable |
lev |
The level in the response variable defined as success |
qnt |
Number of bins to create |
cost |
Cost for each connection (e.g., email or mailing) |
margin |
Margin on each customer purchase |
scale |
Scaling factor to apply to calculations |
train |
Use data from training ("Training"), test ("Test"), both ("Both"), or all data ("All") to evaluate model evalbin |
data_filter |
Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000") |
arr |
Expression to arrange (sort) the data on (e.g., "color, desc(price)") |
rows |
Rows to select from the specified dataset |
envir |
Environment to extract data from |
Evaluate different (binary) classification models based on predictions. See https://radiant-rstats.github.io/docs/model/evalbin.html for an example in Radiant
A list of results
summary.evalbin
to summarize results
plot.evalbin
to plot results
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% evalbin(c("pred1", "pred2"), "buy") %>% str()
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% evalbin(c("pred1", "pred2"), "buy") %>% str()
Evaluate the performance of different regression models
evalreg( dataset, pred, rvar, train = "All", data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
evalreg( dataset, pred, rvar, train = "All", data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
dataset |
Dataset |
pred |
Predictions or predictors |
rvar |
Response variable |
train |
Use data from training ("Training"), test ("Test"), both ("Both"), or all data ("All") to evaluate model evalreg |
data_filter |
Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "training == 1") |
arr |
Expression to arrange (sort) the data on (e.g., "color, desc(price)") |
rows |
Rows to select from the specified dataset |
envir |
Environment to extract data from |
Evaluate different regression models based on predictions. See https://radiant-rstats.github.io/docs/model/evalreg.html for an example in Radiant
A list of results
summary.evalreg
to summarize results
plot.evalreg
to plot results
data.frame(price = diamonds$price, pred1 = rnorm(3000), pred2 = diamonds$price) %>% evalreg(pred = c("pred1", "pred2"), "price") %>% str()
data.frame(price = diamonds$price, pred1 = rnorm(3000), pred2 = diamonds$price) %>% evalreg(pred = c("pred1", "pred2"), "price") %>% str()
Find maximum value of a vector
find_max(x, y)
find_max(x, y)
x |
Variable to find the maximum for |
y |
Variable to find the value for at the maximum of var |
Find the value of y at the maximum value of x
Value of val at the maximum of var
find_max(1:10, 21:30)
find_max(1:10, 21:30)
Find minimum value of a vector
find_min(x, y)
find_min(x, y)
x |
Variable to find the minimum for |
y |
Variable to find the value for at the maximum of var |
Find the value of y at the minimum value of x
Value of val at the minimum of var
find_min(1:10, 21:30)
find_min(1:10, 21:30)
Gradient Boosted Trees using XGBoost
gbt( dataset, rvar, evar, type = "classification", lev = "", max_depth = 6, learning_rate = 0.3, min_split_loss = 0, min_child_weight = 1, subsample = 1, nrounds = 100, early_stopping_rounds = 10, nthread = 12, wts = "None", seed = NA, data_filter = "", arr = "", rows = NULL, envir = parent.frame(), ... )
gbt( dataset, rvar, evar, type = "classification", lev = "", max_depth = 6, learning_rate = 0.3, min_split_loss = 0, min_child_weight = 1, subsample = 1, nrounds = 100, early_stopping_rounds = 10, nthread = 12, wts = "None", seed = NA, data_filter = "", arr = "", rows = NULL, envir = parent.frame(), ... )
dataset |
Dataset |
rvar |
The response variable in the model |
evar |
Explanatory variables in the model |
type |
Model type (i.e., "classification" or "regression") |
lev |
Level to use as the first column in prediction output |
max_depth |
Maximum 'depth' of tree |
learning_rate |
Learning rate (eta) |
min_split_loss |
Minimal improvement (gamma) |
min_child_weight |
Minimum number of instances allowed in each node |
subsample |
Subsample ratio of the training instances (0-1) |
nrounds |
Number of trees to create |
early_stopping_rounds |
Early stopping rule |
nthread |
Number of parallel threads to use. Defaults to 12 if available |
wts |
Weights to use in estimation |
seed |
Random seed to use as the starting point |
data_filter |
Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000") |
arr |
Expression to arrange (sort) the data on (e.g., "color, desc(price)") |
rows |
Rows to select from the specified dataset |
envir |
Environment to extract data from |
... |
Further arguments to pass to xgboost |
See https://radiant-rstats.github.io/docs/model/gbt.html for an example in Radiant
A list with all variables defined in gbt as an object of class gbt
summary.gbt
to summarize results
plot.gbt
to plot results
predict.gbt
for prediction
## Not run: gbt(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% summary() gbt(titanic, "survived", c("pclass", "sex")) %>% str() ## End(Not run) gbt( titanic, "survived", c("pclass", "sex"), lev = "Yes", early_stopping_rounds = 0, nthread = 1 ) %>% summary() gbt( titanic, "survived", c("pclass", "sex"), early_stopping_rounds = 0, nthread = 1 ) %>% str() gbt( titanic, "survived", c("pclass", "sex"), eval_metric = paste0("error@", 0.5 / 6), nthread = 1 ) %>% str() gbt( diamonds, "price", c("carat", "clarity"), type = "regression", nthread = 1 ) %>% summary()
## Not run: gbt(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% summary() gbt(titanic, "survived", c("pclass", "sex")) %>% str() ## End(Not run) gbt( titanic, "survived", c("pclass", "sex"), lev = "Yes", early_stopping_rounds = 0, nthread = 1 ) %>% summary() gbt( titanic, "survived", c("pclass", "sex"), early_stopping_rounds = 0, nthread = 1 ) %>% str() gbt( titanic, "survived", c("pclass", "sex"), eval_metric = paste0("error@", 0.5 / 6), nthread = 1 ) %>% str() gbt( diamonds, "price", c("carat", "clarity"), type = "regression", nthread = 1 ) %>% summary()
Houseprices
data(houseprices)
data(houseprices)
A data frame with 128 home sales and 6 variables
Description provided in attr(houseprices, "description")
Ideal data for linear regression
data(ideal)
data(ideal)
A data frame with 1,000 rows and 4 variables
Description provided in attr(ideal, "description")
Kaggle uplift
data(kaggle_uplift)
data(kaggle_uplift)
A data frame with 1,000 rows and 22 variables
Use uplift modeling to quantify the effectiveness of an experimental treatment
Data on ketchup choices
data(ketchup)
data(ketchup)
A data frame with 2,798 rows and 14 variables
Choice behavior for a sample of 300 individuals in a panel of households in Springfield, Missouri (USA). Description provided in attr(ketchup,"description")
Logistic regression
logistic( dataset, rvar, evar, lev = "", int = "", wts = "None", check = "", form, ci_type, data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
logistic( dataset, rvar, evar, lev = "", int = "", wts = "None", check = "", form, ci_type, data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
dataset |
Dataset |
rvar |
The response variable in the model |
evar |
Explanatory variables in the model |
lev |
The level in the response variable defined as _success_ |
int |
Interaction term to include in the model |
wts |
Weights to use in estimation |
check |
Use "standardize" to see standardized coefficient estimates. Use "stepwise-backward" (or "stepwise-forward", or "stepwise-both") to apply step-wise selection of variables in estimation. Add "robust" for robust estimation of standard errors (HC1) |
form |
Optional formula to use instead of rvar, evar, and int |
ci_type |
To use the profile-likelihood (rather than Wald) for confidence intervals use "profile". For datasets with more than 5,000 rows the Wald method will be used, unless "profile" is explicitly set |
data_filter |
Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000") |
arr |
Expression to arrange (sort) the data on (e.g., "color, desc(price)") |
rows |
Rows to select from the specified dataset |
envir |
Environment to extract data from |
See https://radiant-rstats.github.io/docs/model/logistic.html for an example in Radiant
A list with all variables defined in logistic as an object of class logistic
summary.logistic
to summarize the results
plot.logistic
to plot the results
predict.logistic
to generate predictions
plot.model.predict
to plot prediction output
logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% summary() logistic(titanic, "survived", c("pclass", "sex")) %>% str()
logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% summary() logistic(titanic, "survived", c("pclass", "sex")) %>% str()
Mean Absolute Error
MAE(pred, rvar)
MAE(pred, rvar)
pred |
Prediction (vector) |
rvar |
Response (vector) |
Mean Absolute Error
Calculate min and max before standardization
minmax(dataset)
minmax(dataset)
dataset |
Data frame |
Data frame min and max attributes
Multinomial logistic regression
mnl( dataset, rvar, evar, lev = "", int = "", wts = "None", check = "", data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
mnl( dataset, rvar, evar, lev = "", int = "", wts = "None", check = "", data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
dataset |
Dataset |
rvar |
The response variable in the model |
evar |
Explanatory variables in the model |
lev |
The level in the response variable to use as the baseline |
int |
Interaction term to include in the model |
wts |
Weights to use in estimation |
check |
Use "standardize" to see standardized coefficient estimates. Use "stepwise-backward" (or "stepwise-forward", or "stepwise-both") to apply step-wise selection of variables in estimation. |
data_filter |
Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000") |
arr |
Expression to arrange (sort) the data on (e.g., "color, desc(price)") |
rows |
Rows to select from the specified dataset |
envir |
Environment to extract data from |
See https://radiant-rstats.github.io/docs/model/mnl.html for an example in Radiant
A list with all variables defined in mnl as an object of class mnl
summary.mnl
to summarize the results
plot.mnl
to plot the results
predict.mnl
to generate predictions
plot.model.predict
to plot prediction output
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) str(result)
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) str(result)
Movie contract decision tree
data(movie_contract)
data(movie_contract)
A nested list for decision and chance nodes, probabilities and payoffs
Use decision analysis to create a decision tree for an actor facing a contract decision
Naive Bayes using e1071::naiveBayes
nb( dataset, rvar, evar, laplace = 0, data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
nb( dataset, rvar, evar, laplace = 0, data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
dataset |
Dataset |
rvar |
The response variable in the logit (probit) model |
evar |
Explanatory variables in the model |
laplace |
Positive double controlling Laplace smoothing. The default (0) disables Laplace smoothing. |
data_filter |
Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000") |
arr |
Expression to arrange (sort) the data on (e.g., "color, desc(price)") |
rows |
Rows to select from the specified dataset |
envir |
Environment to extract data from |
See https://radiant-rstats.github.io/docs/model/nb.html for an example in Radiant
A list with all variables defined in nb as an object of class nb
summary.nb
to summarize results
plot.nb
to plot results
predict.nb
for prediction
nb(titanic, "survived", c("pclass", "sex", "age")) %>% summary() nb(titanic, "survived", c("pclass", "sex", "age")) %>% str()
nb(titanic, "survived", c("pclass", "sex", "age")) %>% summary() nb(titanic, "survived", c("pclass", "sex", "age")) %>% str()
Neural Networks using nnet
nn( dataset, rvar, evar, type = "classification", lev = "", size = 1, decay = 0.5, wts = "None", seed = NA, check = "standardize", form, data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
nn( dataset, rvar, evar, type = "classification", lev = "", size = 1, decay = 0.5, wts = "None", seed = NA, check = "standardize", form, data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
dataset |
Dataset |
rvar |
The response variable in the model |
evar |
Explanatory variables in the model |
type |
Model type (i.e., "classification" or "regression") |
lev |
The level in the response variable defined as _success_ |
size |
Number of units (nodes) in the hidden layer |
decay |
Parameter decay |
wts |
Weights to use in estimation |
seed |
Random seed to use as the starting point |
check |
Optional estimation parameters ("standardize" is the default) |
form |
Optional formula to use instead of rvar and evar |
data_filter |
Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000") |
arr |
Expression to arrange (sort) the data on (e.g., "color, desc(price)") |
rows |
Rows to select from the specified dataset |
envir |
Environment to extract data from |
See https://radiant-rstats.github.io/docs/model/nn.html for an example in Radiant
A list with all variables defined in nn as an object of class nn
summary.nn
to summarize results
plot.nn
to plot results
predict.nn
for prediction
nn(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% summary() nn(titanic, "survived", c("pclass", "sex")) %>% str() nn(diamonds, "price", c("carat", "clarity"), type = "regression") %>% summary()
nn(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% summary() nn(titanic, "survived", c("pclass", "sex")) %>% str() nn(diamonds, "price", c("carat", "clarity"), type = "regression") %>% summary()
One hot encoding of data.frames
onehot(dataset, all = FALSE, df = FALSE)
onehot(dataset, all = FALSE, df = FALSE)
dataset |
Dataset to endcode |
all |
Extract all factor levels (e.g., for tree-based models) |
df |
Return a data.frame (tibble) |
head(onehot(diamonds, df = TRUE)) head(onehot(diamonds, all = TRUE, df = TRUE))
head(onehot(diamonds, df = TRUE)) head(onehot(diamonds, all = TRUE, df = TRUE))
Create Partial Dependence Plots
pdp_plot( x, plot_list = list(), incl, incl_int, fix = TRUE, hline = TRUE, nr = 20, minq = 0.025, maxq = 0.975 )
pdp_plot( x, plot_list = list(), incl, incl_int, fix = TRUE, hline = TRUE, nr = 20, minq = 0.025, maxq = 0.975 )
x |
Return value from a model |
plot_list |
List used to store plots |
incl |
Which variables to include in PDP plots |
incl_int |
Which interactions to investigate in PDP plots |
fix |
Set the desired limited on yhat or have it calculated automatically. Set to FALSE to have y-axis limits set by ggplot2 for each plot |
hline |
Add a horizontal line at the average of the target variable. When set to FALSE no line is added. When set to a specific number, the horizontal line will be added at that value |
nr |
Number of values to use to generate predictions for a numeric explanatory variable |
minq |
Quantile to use for the minimum value for simulation of numeric variables |
maxq |
Quantile to use for the maximum value for simulation of numeric variables |
Plot method for the confusion matrix
## S3 method for class 'confusion' plot( x, vars = c("kappa", "index", "ROME", "AUC"), scale_y = TRUE, size = 13, ... )
## S3 method for class 'confusion' plot( x, vars = c("kappa", "index", "ROME", "AUC"), scale_y = TRUE, size = 13, ... )
x |
Return value from |
vars |
Measures to plot, i.e., one or more of "TP", "FP", "TN", "FN", "total", "TPR", "TNR", "precision", "accuracy", "kappa", "profit", "index", "ROME", "contact", "AUC" |
scale_y |
Free scale in faceted plot of the confusion matrix (TRUE or FALSE) |
size |
Font size used |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/evalbin.html for an example in Radiant
confusion
to generate results
summary.confusion
to summarize results
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% confusion(c("pred1", "pred2"), "buy") %>% plot()
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% confusion(c("pred1", "pred2"), "buy") %>% plot()
Plot method for the crs function
## S3 method for class 'crs' plot(x, ...)
## S3 method for class 'crs' plot(x, ...)
x |
Return value from |
... |
further arguments passed to or from other methods |
Plot that compares actual to predicted ratings. See https://radiant-rstats.github.io/docs/model/crs.html for an example in Radiant
crs
to generate results
summary.crs
to summarize results
Plot method for the crtree function
## S3 method for class 'crtree' plot( x, plots = "tree", orient = "LR", width = "900px", labs = TRUE, nrobs = Inf, dec = 2, incl = NULL, incl_int = NULL, shiny = FALSE, custom = FALSE, ... )
## S3 method for class 'crtree' plot( x, plots = "tree", orient = "LR", width = "900px", labs = TRUE, nrobs = Inf, dec = 2, incl = NULL, incl_int = NULL, shiny = FALSE, custom = FALSE, ... )
x |
Return value from |
plots |
Plots to produce for the specified rpart tree. "tree" shows a tree diagram. "prune" shows a line graph to evaluate appropriate tree pruning. "imp" shows a variable importance plot |
orient |
Plot orientation for tree: LR for vertical and TD for horizontal |
width |
Plot width in pixels for tree (default is "900px") |
labs |
Use factor labels in plot (TRUE) or revert to default letters used by tree (FALSE) |
nrobs |
Number of data points to show in dashboard scatter plots (-1 for all) |
dec |
Decimal places to round results to |
incl |
Which variables to include in a coefficient plot or PDP plot |
incl_int |
Which interactions to investigate in PDP plots |
shiny |
Did the function call originate inside a shiny app |
custom |
Logical (TRUE, FALSE) to indicate if ggplot object (or list of ggplot objects) should be returned. This option can be used to customize plots (e.g., add a title, change x and y labels, etc.). See examples and https://ggplot2.tidyverse.org for options. |
... |
further arguments passed to or from other methods |
Plot a decision tree using mermaid, permutation plots , prediction plots, or partial dependence plots. For regression trees, a residual dashboard can be plotted. See https://radiant-rstats.github.io/docs/model/crtree.html for an example in Radiant.
crtree
to generate results
summary.crtree
to summarize results
predict.crtree
for prediction
result <- crtree(titanic, "survived", c("pclass", "sex"), lev = "Yes") plot(result) result <- crtree(diamonds, "price", c("carat", "clarity", "cut")) plot(result, plots = "prune") result <- crtree(dvd, "buy", c("coupon", "purch", "last"), cp = .01) plot(result, plots = "imp")
result <- crtree(titanic, "survived", c("pclass", "sex"), lev = "Yes") plot(result) result <- crtree(diamonds, "price", c("carat", "clarity", "cut")) plot(result, plots = "prune") result <- crtree(dvd, "buy", c("coupon", "purch", "last"), cp = .01) plot(result, plots = "imp")
Plot method for the dtree function
## S3 method for class 'dtree' plot( x, symbol = "$", dec = 2, final = FALSE, orient = "LR", width = "900px", ... )
## S3 method for class 'dtree' plot( x, symbol = "$", dec = 2, final = FALSE, orient = "LR", width = "900px", ... )
x |
Return value from |
symbol |
Monetary symbol to use ($ is the default) |
dec |
Decimal places to round results to |
final |
If TRUE plot the decision tree solution, else the initial decision tree |
orient |
Plot orientation: LR for vertical and TD for horizontal |
width |
Plot width in pixels (default is "900px") |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/dtree.html for an example in Radiant
dtree
to generate the result
summary.dtree
to summarize results
sensitivity.dtree
to plot results
dtree(movie_contract, opt = "max") %>% plot() dtree(movie_contract, opt = "max") %>% plot(final = TRUE, orient = "TD")
dtree(movie_contract, opt = "max") %>% plot() dtree(movie_contract, opt = "max") %>% plot(final = TRUE, orient = "TD")
Plot method for the evalbin function
## S3 method for class 'evalbin' plot( x, plots = c("lift", "gains"), size = 13, shiny = FALSE, custom = FALSE, ... )
## S3 method for class 'evalbin' plot( x, plots = c("lift", "gains"), size = 13, shiny = FALSE, custom = FALSE, ... )
x |
Return value from |
plots |
Plots to return |
size |
Font size used |
shiny |
Did the function call originate inside a shiny app |
custom |
Logical (TRUE, FALSE) to indicate if ggplot object (or list of ggplot objects) should be returned. This option can be used to customize plots (e.g., add a title, change x and y labels, etc.). See examples and https://ggplot2.tidyverse.org for options. |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/evalbin.html for an example in Radiant
evalbin
to generate results
summary.evalbin
to summarize results
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% evalbin(c("pred1", "pred2"), "buy") %>% plot()
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% evalbin(c("pred1", "pred2"), "buy") %>% plot()
Plot method for the evalreg function
## S3 method for class 'evalreg' plot(x, vars = c("Rsq", "RMSE", "MAE"), ...)
## S3 method for class 'evalreg' plot(x, vars = c("Rsq", "RMSE", "MAE"), ...)
x |
Return value from |
vars |
Measures to plot, i.e., one or more of "Rsq", "RMSE", "MAE" |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/evalreg.html for an example in Radiant
evalreg
to generate results
summary.evalreg
to summarize results
data.frame(price = diamonds$price, pred1 = rnorm(3000), pred2 = diamonds$price) %>% evalreg(pred = c("pred1", "pred2"), "price") %>% plot()
data.frame(price = diamonds$price, pred1 = rnorm(3000), pred2 = diamonds$price) %>% evalreg(pred = c("pred1", "pred2"), "price") %>% plot()
Plot method for the gbt function
## S3 method for class 'gbt' plot( x, plots = "", nrobs = Inf, incl = NULL, incl_int = NULL, shiny = FALSE, custom = FALSE, ... )
## S3 method for class 'gbt' plot( x, plots = "", nrobs = Inf, incl = NULL, incl_int = NULL, shiny = FALSE, custom = FALSE, ... )
x |
Return value from |
plots |
Plots to produce for the specified Gradient Boosted Tree model. Use "" to avoid showing any plots (default). Options are ... |
nrobs |
Number of data points to show in scatter plots (-1 for all) |
incl |
Which variables to include in a coefficient plot or PDP plot |
incl_int |
Which interactions to investigate in PDP plots |
shiny |
Did the function call originate inside a shiny app |
custom |
Logical (TRUE, FALSE) to indicate if ggplot object (or list of ggplot objects) should be returned. This option can be used to customize plots (e.g., add a title, change x and y labels, etc.). See examples and https://ggplot2.tidyverse.org for options. |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/gbt.html for an example in Radiant
gbt
to generate results
summary.gbt
to summarize results
predict.gbt
for prediction
result <- gbt( titanic, "survived", c("pclass", "sex"), early_stopping_rounds = 0, nthread = 1 ) plot(result)
result <- gbt( titanic, "survived", c("pclass", "sex"), early_stopping_rounds = 0, nthread = 1 ) plot(result)
Plot method for the logistic function
## S3 method for class 'logistic' plot( x, plots = "coef", conf_lev = 0.95, intercept = FALSE, incl = NULL, excl = NULL, incl_int = NULL, nrobs = -1, shiny = FALSE, custom = FALSE, ... )
## S3 method for class 'logistic' plot( x, plots = "coef", conf_lev = 0.95, intercept = FALSE, incl = NULL, excl = NULL, incl_int = NULL, nrobs = -1, shiny = FALSE, custom = FALSE, ... )
x |
Return value from |
plots |
Plots to produce for the specified GLM model. Use "" to avoid showing any plots (default). "dist" shows histograms (or frequency bar plots) of all variables in the model. "scatter" shows scatter plots (or box plots for factors) for the response variable with each explanatory variable. "coef" provides a coefficient plot and "influence" shows (potentially) influential observations |
conf_lev |
Confidence level to use for coefficient and odds confidence intervals (.95 is the default) |
intercept |
Include the intercept in the coefficient plot (TRUE or FALSE). FALSE is the default |
incl |
Which variables to include in a coefficient plot |
excl |
Which variables to exclude in a coefficient plot |
incl_int |
Which interactions to investigate in PDP plots |
nrobs |
Number of data points to show in scatter plots (-1 for all) |
shiny |
Did the function call originate inside a shiny app |
custom |
Logical (TRUE, FALSE) to indicate if ggplot object (or list of ggplot objects) should be returned. This option can be used to customize plots (e.g., add a title, change x and y labels, etc.). See examples and https://ggplot2.tidyverse.org for options. |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/logistic.html for an example in Radiant
logistic
to generate results
plot.logistic
to plot results
predict.logistic
to generate predictions
plot.model.predict
to plot prediction output
result <- logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") plot(result, plots = "coef")
result <- logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") plot(result, plots = "coef")
Plot method for the mnl function
## S3 method for class 'mnl' plot( x, plots = "coef", conf_lev = 0.95, intercept = FALSE, nrobs = -1, shiny = FALSE, custom = FALSE, ... )
## S3 method for class 'mnl' plot( x, plots = "coef", conf_lev = 0.95, intercept = FALSE, nrobs = -1, shiny = FALSE, custom = FALSE, ... )
x |
Return value from |
plots |
Plots to produce for the specified MNL model. Use "" to avoid showing any plots (default). "dist" shows histograms (or frequency bar plots) of all variables in the model. "scatter" shows scatter plots (or box plots for factors) for the response variable with each explanatory variable. "coef" provides a coefficient plot |
conf_lev |
Confidence level to use for coefficient and relative risk ratios (RRRs) intervals (.95 is the default) |
intercept |
Include the intercept in the coefficient plot (TRUE or FALSE). FALSE is the default |
nrobs |
Number of data points to show in scatter plots (-1 for all) |
shiny |
Did the function call originate inside a shiny app |
custom |
Logical (TRUE, FALSE) to indicate if ggplot object (or list of ggplot objects) should be returned. This option can be used to customize plots (e.g., add a title, change x and y labels, etc.). See examples and https://ggplot2.tidyverse.org for options. |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/mnl.html for an example in Radiant
mnl
to generate results
predict.mnl
to generate predictions
plot.model.predict
to plot prediction output
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) plot(result, plots = "coef")
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) plot(result, plots = "coef")
Plot method for mnl.predict function
## S3 method for class 'mnl.predict' plot(x, xvar = "", facet_row = ".", facet_col = ".", color = ".class", ...)
## S3 method for class 'mnl.predict' plot(x, xvar = "", facet_row = ".", facet_col = ".", color = ".class", ...)
x |
Return value from predict function predict.mnl |
xvar |
Variable to display along the X-axis of the plot |
facet_row |
Create vertically arranged subplots for each level of the selected factor variable |
facet_col |
Create horizontally arranged subplots for each level of the selected factor variable |
color |
Adds color to a scatter plot to generate a heat map. For a line plot one line is created for each group and each is assigned a different color |
... |
further arguments passed to or from other methods |
predict.mnl
to generate predictions
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) pred <- predict(result, pred_cmd = "price.heinz28 = seq(3, 5, 0.1)") plot(pred, xvar = "price.heinz28")
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) pred <- predict(result, pred_cmd = "price.heinz28 = seq(3, 5, 0.1)") plot(pred, xvar = "price.heinz28")
Plot method for model.predict functions
## S3 method for class 'model.predict' plot( x, xvar = "", facet_row = ".", facet_col = ".", color = "none", conf_lev = 0.95, ... )
## S3 method for class 'model.predict' plot( x, xvar = "", facet_row = ".", facet_col = ".", color = "none", conf_lev = 0.95, ... )
x |
Return value from predict functions (e.g., predict.regress) |
xvar |
Variable to display along the X-axis of the plot |
facet_row |
Create vertically arranged subplots for each level of the selected factor variable |
facet_col |
Create horizontally arranged subplots for each level of the selected factor variable |
color |
Adds color to a scatter plot to generate a heat map. For a line plot one line is created for each group and each is assigned a different color |
conf_lev |
Confidence level to use for prediction intervals (.95 is the default) |
... |
further arguments passed to or from other methods |
predict.regress
to generate predictions
predict.logistic
to generate predictions
regress(diamonds, "price", c("carat", "clarity")) %>% predict(pred_cmd = "carat = 1:10") %>% plot(xvar = "carat") logistic(titanic, "survived", c("pclass", "sex", "age"), lev = "Yes") %>% predict(pred_cmd = c("pclass = levels(pclass)", "sex = levels(sex)", "age = 0:100")) %>% plot(xvar = "age", color = "sex", facet_col = "pclass")
regress(diamonds, "price", c("carat", "clarity")) %>% predict(pred_cmd = "carat = 1:10") %>% plot(xvar = "carat") logistic(titanic, "survived", c("pclass", "sex", "age"), lev = "Yes") %>% predict(pred_cmd = c("pclass = levels(pclass)", "sex = levels(sex)", "age = 0:100")) %>% plot(xvar = "age", color = "sex", facet_col = "pclass")
Plot method for the nb function
## S3 method for class 'nb' plot(x, plots = "correlations", lev = "All levels", nrobs = 1000, ...)
## S3 method for class 'nb' plot(x, plots = "correlations", lev = "All levels", nrobs = 1000, ...)
x |
Return value from |
plots |
Plots to produce for the specified model. Use "" to avoid showing any plots. Use "vimp" for variable importance or "correlations" to examine conditional independence |
lev |
The level(s) in the response variable used as the basis for plots (defaults to "All levels") |
nrobs |
Number of data points to show in scatter plots (-1 for all) |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/nb.html for an example in Radiant
nb
to generate results
summary.nb
to summarize results
predict.nb
for prediction
result <- nb(titanic, "survived", c("pclass", "sex")) plot(result) result <- nb(titanic, "pclass", c("sex", "age")) plot(result)
result <- nb(titanic, "survived", c("pclass", "sex")) plot(result) result <- nb(titanic, "pclass", c("sex", "age")) plot(result)
Plot method for nb.predict function
## S3 method for class 'nb.predict' plot(x, xvar = "", facet_row = ".", facet_col = ".", color = ".class", ...)
## S3 method for class 'nb.predict' plot(x, xvar = "", facet_row = ".", facet_col = ".", color = ".class", ...)
x |
Return value from predict function predict.nb |
xvar |
Variable to display along the X-axis of the plot |
facet_row |
Create vertically arranged subplots for each level of the selected factor variable |
facet_col |
Create horizontally arranged subplots for each level of the selected factor variable |
color |
Adds color to a scatter plot to generate a heat map. For a line plot one line is created for each group and each is assigned a different color |
... |
further arguments passed to or from other methods |
predict.nb
to generate predictions
result <- nb(titanic, "survived", c("pclass", "sex", "age")) pred <- predict( result, pred_cmd = c("pclass = levels(pclass)", "sex = levels(sex)", "age = seq(0, 100, 20)") ) plot(pred, xvar = "age", facet_col = "sex", facet_row = "pclass") pred <- predict(result, pred_data = titanic) plot(pred, xvar = "age", facet_col = "sex")
result <- nb(titanic, "survived", c("pclass", "sex", "age")) pred <- predict( result, pred_cmd = c("pclass = levels(pclass)", "sex = levels(sex)", "age = seq(0, 100, 20)") ) plot(pred, xvar = "age", facet_col = "sex", facet_row = "pclass") pred <- predict(result, pred_data = titanic) plot(pred, xvar = "age", facet_col = "sex")
Plot method for the nn function
## S3 method for class 'nn' plot( x, plots = "vip", size = 12, pad_x = 0.9, nrobs = -1, incl = NULL, incl_int = NULL, shiny = FALSE, custom = FALSE, ... )
## S3 method for class 'nn' plot( x, plots = "vip", size = 12, pad_x = 0.9, nrobs = -1, incl = NULL, incl_int = NULL, shiny = FALSE, custom = FALSE, ... )
x |
Return value from |
plots |
Plots to produce for the specified Neural Network model. Use "" to avoid showing any plots (default). Options are "olden" or "garson" for importance plots, or "net" to depict the network structure |
size |
Font size used |
pad_x |
Padding for explanatory variable labels in the network plot. Default value is 0.9, smaller numbers (e.g., 0.5) increase the amount of padding |
nrobs |
Number of data points to show in dashboard scatter plots (-1 for all) |
incl |
Which variables to include in a coefficient plot or PDP plot |
incl_int |
Which interactions to investigate in PDP plots |
shiny |
Did the function call originate inside a shiny app |
custom |
Logical (TRUE, FALSE) to indicate if ggplot object (or list of ggplot objects) should be returned. This option can be used to customize plots (e.g., add a title, change x and y labels, etc.). See examples and https://ggplot2.tidyverse.org for options. |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/nn.html for an example in Radiant
nn
to generate results
summary.nn
to summarize results
predict.nn
for prediction
result <- nn(titanic, "survived", c("pclass", "sex"), lev = "Yes") plot(result, plots = "net") plot(result, plots = "olden")
result <- nn(titanic, "survived", c("pclass", "sex"), lev = "Yes") plot(result, plots = "net") plot(result, plots = "olden")
Plot method for the regress function
## S3 method for class 'regress' plot( x, plots = "", lines = "", conf_lev = 0.95, intercept = FALSE, incl = NULL, excl = NULL, incl_int = NULL, nrobs = -1, shiny = FALSE, custom = FALSE, ... )
## S3 method for class 'regress' plot( x, plots = "", lines = "", conf_lev = 0.95, intercept = FALSE, incl = NULL, excl = NULL, incl_int = NULL, nrobs = -1, shiny = FALSE, custom = FALSE, ... )
x |
Return value from |
plots |
Regression plots to produce for the specified regression model. Enter "" to avoid showing any plots (default). "dist" to shows histograms (or frequency bar plots) of all variables in the model. "correlations" for a visual representation of the correlation matrix selected variables. "scatter" to show scatter plots (or box plots for factors) for the response variable with each explanatory variable. "dashboard" for a series of six plots that can be used to evaluate model fit visually. "resid_pred" to plot the explanatory variables against the model residuals. "coef" for a coefficient plot with adjustable confidence intervals and "influence" to show (potentially) influential observations |
lines |
Optional lines to include in the select plot. "line" to include a line through a scatter plot. "loess" to include a polynomial regression fit line. To include both use c("line", "loess") |
conf_lev |
Confidence level used to estimate confidence intervals (.95 is the default) |
intercept |
Include the intercept in the coefficient plot (TRUE, FALSE). FALSE is the default |
incl |
Which variables to include in a coefficient plot or PDP plot |
excl |
Which variables to exclude in a coefficient plot |
incl_int |
Which interactions to investigate in PDP plots |
nrobs |
Number of data points to show in scatter plots (-1 for all) |
shiny |
Did the function call originate inside a shiny app |
custom |
Logical (TRUE, FALSE) to indicate if ggplot object (or list of ggplot objects) should be returned. This option can be used to customize plots (e.g., add a title, change x and y labels, etc.). See examples and https://ggplot2.tidyverse.org for options. |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/regress.html for an example in Radiant
regress
to generate the results
summary.regress
to summarize results
predict.regress
to generate predictions
result <- regress(diamonds, "price", c("carat", "clarity")) plot(result, plots = "coef", conf_lev = .99, intercept = TRUE) ## Not run: plot(result, plots = "dist") plot(result, plots = "scatter", lines = c("line", "loess")) plot(result, plots = "resid_pred", lines = "line") plot(result, plots = "dashboard", lines = c("line", "loess")) ## End(Not run)
result <- regress(diamonds, "price", c("carat", "clarity")) plot(result, plots = "coef", conf_lev = .99, intercept = TRUE) ## Not run: plot(result, plots = "dist") plot(result, plots = "scatter", lines = c("line", "loess")) plot(result, plots = "resid_pred", lines = "line") plot(result, plots = "dashboard", lines = c("line", "loess")) ## End(Not run)
Plot repeated simulation
## S3 method for class 'repeater' plot(x, bins = 20, shiny = FALSE, custom = FALSE, ...)
## S3 method for class 'repeater' plot(x, bins = 20, shiny = FALSE, custom = FALSE, ...)
x |
Return value from |
bins |
Number of bins used for histograms (1 - 50) |
shiny |
Did the function call originate inside a shiny app |
custom |
Logical (TRUE, FALSE) to indicate if ggplot object (or list of ggplot objects) should be returned. This option can be used to customize plots (e.g., add a title, change x and y labels, etc.). See examples and https://ggplot2.tidyverse.org for options. |
... |
further arguments passed to or from other methods |
repeater
to run a repeated simulation
summary.repeater
to summarize results from repeated simulation
Plot method for the rforest function
## S3 method for class 'rforest' plot( x, plots = "", nrobs = Inf, incl = NULL, incl_int = NULL, shiny = FALSE, custom = FALSE, ... )
## S3 method for class 'rforest' plot( x, plots = "", nrobs = Inf, incl = NULL, incl_int = NULL, shiny = FALSE, custom = FALSE, ... )
x |
Return value from |
plots |
Plots to produce for the specified Random Forest model. Use "" to avoid showing any plots (default). Options are ... |
nrobs |
Number of data points to show in dashboard scatter plots (-1 for all) |
incl |
Which variables to include in PDP or Prediction plots |
incl_int |
Which interactions to investigate in PDP or Prediction plots |
shiny |
Did the function call originate inside a shiny app |
custom |
Logical (TRUE, FALSE) to indicate if ggplot object (or list of ggplot objects) should be returned. This option can be used to customize plots (e.g., add a title, change x and y labels, etc.). See examples and https://ggplot2.tidyverse.org for options. |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/rforest.html for an example in Radiant
rforest
to generate results
summary.rforest
to summarize results
predict.rforest
for prediction
result <- rforest(titanic, "survived", c("pclass", "sex"), lev = "Yes")
result <- rforest(titanic, "survived", c("pclass", "sex"), lev = "Yes")
Plot method for rforest.predict function
## S3 method for class 'rforest.predict' plot(x, xvar = "", facet_row = ".", facet_col = ".", color = "none", ...)
## S3 method for class 'rforest.predict' plot(x, xvar = "", facet_row = ".", facet_col = ".", color = "none", ...)
x |
Return value from predict function predict.rforest |
xvar |
Variable to display along the X-axis of the plot |
facet_row |
Create vertically arranged subplots for each level of the selected factor variable |
facet_col |
Create horizontally arranged subplots for each level of the selected factor variable |
color |
Adds color to a scatter plot to generate a heat map. For a line plot one line is created for each group and each is assigned a different color |
... |
further arguments passed to or from other methods |
predict.mnl
to generate predictions
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) pred <- predict(result, pred_cmd = "price.heinz28 = seq(3, 5, 0.1)") plot(pred, xvar = "price.heinz28")
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) pred <- predict(result, pred_cmd = "price.heinz28 = seq(3, 5, 0.1)") plot(pred, xvar = "price.heinz28")
Plot method for the simulater function
## S3 method for class 'simulater' plot(x, bins = 20, shiny = FALSE, custom = FALSE, ...)
## S3 method for class 'simulater' plot(x, bins = 20, shiny = FALSE, custom = FALSE, ...)
x |
Return value from |
bins |
Number of bins used for histograms (1 - 50) |
shiny |
Did the function call originate inside a shiny app |
custom |
Logical (TRUE, FALSE) to indicate if ggplot object (or list of ggplot objects) should be returned. This option can be used to customize plots (e.g., add a title, change x and y labels, etc.). See examples and https://ggplot2.tidyverse.org for options. |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/simulater for an example in Radiant
simulater
to generate the result
summary.simulater
to summarize results
simdat <- simulater( const = "cost 3", norm = "demand 2000 1000", discrete = "price 5 8 .3 .7", form = "profit = demand * (price - cost)", seed = 1234 ) plot(simdat, bins = 25)
simdat <- simulater( const = "cost 3", norm = "demand 2000 1000", discrete = "price 5 8 .3 .7", form = "profit = demand * (price - cost)", seed = 1234 ) plot(simdat, bins = 25)
Plot method for the uplift function
## S3 method for class 'uplift' plot( x, plots = c("inc_uplift", "uplift"), size = 13, shiny = FALSE, custom = FALSE, ... )
## S3 method for class 'uplift' plot( x, plots = c("inc_uplift", "uplift"), size = 13, shiny = FALSE, custom = FALSE, ... )
x |
Return value from |
plots |
Plots to return |
size |
Font size used |
shiny |
Did the function call originate inside a shiny app |
custom |
Logical (TRUE, FALSE) to indicate if ggplot object (or list of ggplot objects) should be returned. This option can be used to customize plots (e.g., add a title, change x and y labels, etc.). See examples and https://ggplot2.tidyverse.org for options. |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/evalbin.html for an example in Radiant
evalbin
to generate results
summary.evalbin
to summarize results
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% evalbin(c("pred1", "pred2"), "buy") %>% plot()
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% evalbin(c("pred1", "pred2"), "buy") %>% plot()
Prediction Plots
pred_plot( x, plot_list = list(), incl, incl_int, fix = TRUE, hline = TRUE, nr = 20, minq = 0.025, maxq = 0.975 )
pred_plot( x, plot_list = list(), incl, incl_int, fix = TRUE, hline = TRUE, nr = 20, minq = 0.025, maxq = 0.975 )
x |
Return value from a model |
plot_list |
List used to store plots |
incl |
Which variables to include in prediction plots |
incl_int |
Which interactions to investigate in prediction plots |
fix |
Set the desired limited on yhat or have it calculated automatically. Set to FALSE to have y-axis limits set by ggplot2 for each plot |
hline |
Add a horizontal line at the average of the target variable. When set to FALSE no line is added. When set to a specific number, the horizontal line will be added at that value |
nr |
Number of values to use to generate predictions for a numeric explanatory variable |
minq |
Quantile to use for the minimum value for simulation of numeric variables |
maxq |
Quantile to use for the maximum value for simulation of numeric variables |
Faster, but less robust, alternative for PDP plots. Variable values not included in the prediction are set to either the mean or the most common value (level)
Predict method for model functions
predict_model( object, pfun, mclass, pred_data = NULL, pred_cmd = "", conf_lev = 0.95, se = FALSE, dec = 3, envir = parent.frame(), ... )
predict_model( object, pfun, mclass, pred_data = NULL, pred_cmd = "", conf_lev = 0.95, se = FALSE, dec = 3, envir = parent.frame(), ... )
object |
Return value from |
pfun |
Function to use for prediction |
mclass |
Model class to attach |
pred_data |
Dataset to use for prediction |
pred_cmd |
Command used to generate data for prediction (e.g., 'carat = 1:10') |
conf_lev |
Confidence level used to estimate confidence intervals (.95 is the default) |
se |
Logical that indicates if prediction standard errors should be calculated (default = FALSE) |
dec |
Number of decimals to show |
envir |
Environment to extract data from |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/regress.html for an example in Radiant
Predict method for the crtree function
## S3 method for class 'crtree' predict( object, pred_data = NULL, pred_cmd = "", conf_lev = 0.95, se = FALSE, dec = 3, envir = parent.frame(), ... )
## S3 method for class 'crtree' predict( object, pred_data = NULL, pred_cmd = "", conf_lev = 0.95, se = FALSE, dec = 3, envir = parent.frame(), ... )
object |
Return value from |
pred_data |
Provide the dataframe to generate predictions (e.g., titanic). The dataset must contain all columns used in the estimation |
pred_cmd |
Generate predictions using a command. For example, ‘pclass = levels(pclass)' would produce predictions for the different levels of factor 'pclass'. To add another variable, create a vector of prediction strings, (e.g., c(’pclass = levels(pclass)', 'age = seq(0,100,20)') |
conf_lev |
Confidence level used to estimate confidence intervals (.95 is the default) |
se |
Logical that indicates if prediction standard errors should be calculated (default = FALSE) |
dec |
Number of decimals to show |
envir |
Environment to extract data from |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/crtree.html for an example in Radiant
crtree
to generate the result
summary.crtree
to summarize results
result <- crtree(titanic, "survived", c("pclass", "sex"), lev = "Yes") predict(result, pred_cmd = "pclass = levels(pclass)") result <- crtree(titanic, "survived", "pclass", lev = "Yes") predict(result, pred_data = titanic) %>% head()
result <- crtree(titanic, "survived", c("pclass", "sex"), lev = "Yes") predict(result, pred_cmd = "pclass = levels(pclass)") result <- crtree(titanic, "survived", "pclass", lev = "Yes") predict(result, pred_data = titanic) %>% head()
Predict method for the gbt function
## S3 method for class 'gbt' predict( object, pred_data = NULL, pred_cmd = "", dec = 3, envir = parent.frame(), ... )
## S3 method for class 'gbt' predict( object, pred_data = NULL, pred_cmd = "", dec = 3, envir = parent.frame(), ... )
object |
Return value from |
pred_data |
Provide the dataframe to generate predictions (e.g., diamonds). The dataset must contain all columns used in the estimation |
pred_cmd |
Generate predictions using a command. For example, ‘pclass = levels(pclass)' would produce predictions for the different levels of factor 'pclass'. To add another variable, create a vector of prediction strings, (e.g., c(’pclass = levels(pclass)', 'age = seq(0,100,20)') |
dec |
Number of decimals to show |
envir |
Environment to extract data from |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/gbt.html for an example in Radiant
gbt
to generate the result
summary.gbt
to summarize results
result <- gbt( titanic, "survived", c("pclass", "sex"), early_stopping_rounds = 2, nthread = 1 ) predict(result, pred_cmd = "pclass = levels(pclass)") result <- gbt(diamonds, "price", "carat:color", type = "regression", nthread = 1) predict(result, pred_cmd = "carat = 1:3") predict(result, pred_data = diamonds) %>% head()
result <- gbt( titanic, "survived", c("pclass", "sex"), early_stopping_rounds = 2, nthread = 1 ) predict(result, pred_cmd = "pclass = levels(pclass)") result <- gbt(diamonds, "price", "carat:color", type = "regression", nthread = 1) predict(result, pred_cmd = "carat = 1:3") predict(result, pred_data = diamonds) %>% head()
Predict method for the logistic function
## S3 method for class 'logistic' predict( object, pred_data = NULL, pred_cmd = "", conf_lev = 0.95, se = TRUE, interval = "confidence", dec = 3, envir = parent.frame(), ... )
## S3 method for class 'logistic' predict( object, pred_data = NULL, pred_cmd = "", conf_lev = 0.95, se = TRUE, interval = "confidence", dec = 3, envir = parent.frame(), ... )
object |
Return value from |
pred_data |
Provide the dataframe to generate predictions (e.g., titanic). The dataset must contain all columns used in the estimation |
pred_cmd |
Generate predictions using a command. For example, ‘pclass = levels(pclass)' would produce predictions for the different levels of factor 'pclass'. To add another variable, create a vector of prediction strings, (e.g., c(’pclass = levels(pclass)', 'age = seq(0,100,20)') |
conf_lev |
Confidence level used to estimate confidence intervals (.95 is the default) |
se |
Logical that indicates if prediction standard errors should be calculated (default = FALSE) |
interval |
Type of interval calculation ("confidence" or "none"). Set to "none" if se is FALSE |
dec |
Number of decimals to show |
envir |
Environment to extract data from |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/logistic.html for an example in Radiant
logistic
to generate the result
summary.logistic
to summarize results
plot.logistic
to plot results
plot.model.predict
to plot prediction output
result <- logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") predict(result, pred_cmd = "pclass = levels(pclass)") logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% predict(pred_cmd = "sex = c('male','female')") logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% predict(pred_data = titanic)
result <- logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") predict(result, pred_cmd = "pclass = levels(pclass)") logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% predict(pred_cmd = "sex = c('male','female')") logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% predict(pred_data = titanic)
Predict method for the mnl function
## S3 method for class 'mnl' predict( object, pred_data = NULL, pred_cmd = "", pred_names = "", dec = 3, envir = parent.frame(), ... )
## S3 method for class 'mnl' predict( object, pred_data = NULL, pred_cmd = "", pred_names = "", dec = 3, envir = parent.frame(), ... )
object |
Return value from |
pred_data |
Provide the dataframe to generate predictions (e.g., ketchup). The dataset must contain all columns used in the estimation |
pred_cmd |
Generate predictions using a command. For example, ‘pclass = levels(pclass)' would produce predictions for the different levels of factor 'pclass'. To add another variable, create a vector of prediction strings, (e.g., c(’pclass = levels(pclass)', 'age = seq(0,100,20)') |
pred_names |
Names for the predictions to be stored. If one name is provided, only the first column of predictions is stored. If empty, the levels in the response variable of the mnl model will be used |
dec |
Number of decimals to show |
envir |
Environment to extract data from |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/mnl.html for an example in Radiant
mnl
to generate the result
summary.mnl
to summarize results
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) predict(result, pred_cmd = "price.heinz28 = seq(3, 5, 0.1)") predict(result, pred_data = slice(ketchup, 1:20))
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) predict(result, pred_cmd = "price.heinz28 = seq(3, 5, 0.1)") predict(result, pred_data = slice(ketchup, 1:20))
Predict method for the nb function
## S3 method for class 'nb' predict( object, pred_data = NULL, pred_cmd = "", pred_names = "", dec = 3, envir = parent.frame(), ... )
## S3 method for class 'nb' predict( object, pred_data = NULL, pred_cmd = "", pred_names = "", dec = 3, envir = parent.frame(), ... )
object |
Return value from |
pred_data |
Provide the dataframe to generate predictions (e.g., titanic). The dataset must contain all columns used in the estimation |
pred_cmd |
Generate predictions using a command. For example, ‘pclass = levels(pclass)' would produce predictions for the different levels of factor 'pclass'. To add another variable, create a vector of prediction strings, (e.g., c(’pclass = levels(pclass)', 'age = seq(0,100,20)') |
pred_names |
Names for the predictions to be stored. If one name is provided, only the first column of predictions is stored. If empty, the level in the response variable of the nb model will be used |
dec |
Number of decimals to show |
envir |
Environment to extract data from |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/nb.html for an example in Radiant
nb
to generate the result
summary.nb
to summarize results
result <- nb(titanic, "survived", c("pclass", "sex", "age")) predict(result, pred_data = titanic) predict(result, pred_data = titanic, pred_names = c("Yes", "No")) predict(result, pred_cmd = "pclass = levels(pclass)") result <- nb(titanic, "pclass", c("survived", "sex", "age")) predict(result, pred_data = titanic) predict(result, pred_data = titanic, pred_names = c("1st", "2nd", "3rd")) predict(result, pred_data = titanic, pred_names = "")
result <- nb(titanic, "survived", c("pclass", "sex", "age")) predict(result, pred_data = titanic) predict(result, pred_data = titanic, pred_names = c("Yes", "No")) predict(result, pred_cmd = "pclass = levels(pclass)") result <- nb(titanic, "pclass", c("survived", "sex", "age")) predict(result, pred_data = titanic) predict(result, pred_data = titanic, pred_names = c("1st", "2nd", "3rd")) predict(result, pred_data = titanic, pred_names = "")
Predict method for the nn function
## S3 method for class 'nn' predict( object, pred_data = NULL, pred_cmd = "", dec = 3, envir = parent.frame(), ... )
## S3 method for class 'nn' predict( object, pred_data = NULL, pred_cmd = "", dec = 3, envir = parent.frame(), ... )
object |
Return value from |
pred_data |
Provide the dataframe to generate predictions (e.g., diamonds). The dataset must contain all columns used in the estimation |
pred_cmd |
Generate predictions using a command. For example, ‘pclass = levels(pclass)' would produce predictions for the different levels of factor 'pclass'. To add another variable, create a vector of prediction strings, (e.g., c(’pclass = levels(pclass)', 'age = seq(0,100,20)') |
dec |
Number of decimals to show |
envir |
Environment to extract data from |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/nn.html for an example in Radiant
nn
to generate the result
summary.nn
to summarize results
result <- nn(titanic, "survived", c("pclass", "sex"), lev = "Yes") predict(result, pred_cmd = "pclass = levels(pclass)") result <- nn(diamonds, "price", "carat:color", type = "regression") predict(result, pred_cmd = "carat = 1:3") predict(result, pred_data = diamonds) %>% head()
result <- nn(titanic, "survived", c("pclass", "sex"), lev = "Yes") predict(result, pred_cmd = "pclass = levels(pclass)") result <- nn(diamonds, "price", "carat:color", type = "regression") predict(result, pred_cmd = "carat = 1:3") predict(result, pred_data = diamonds) %>% head()
Predict method for the regress function
## S3 method for class 'regress' predict( object, pred_data = NULL, pred_cmd = "", conf_lev = 0.95, se = TRUE, interval = "confidence", dec = 3, envir = parent.frame(), ... )
## S3 method for class 'regress' predict( object, pred_data = NULL, pred_cmd = "", conf_lev = 0.95, se = TRUE, interval = "confidence", dec = 3, envir = parent.frame(), ... )
object |
Return value from |
pred_data |
Provide the dataframe to generate predictions (e.g., diamonds). The dataset must contain all columns used in the estimation |
pred_cmd |
Command used to generate data for prediction |
conf_lev |
Confidence level used to estimate confidence intervals (.95 is the default) |
se |
Logical that indicates if prediction standard errors should be calculated (default = FALSE) |
interval |
Type of interval calculation ("confidence" or "prediction"). Set to "none" if se is FALSE |
dec |
Number of decimals to show |
envir |
Environment to extract data from |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/regress.html for an example in Radiant
regress
to generate the result
summary.regress
to summarize results
plot.regress
to plot results
result <- regress(diamonds, "price", c("carat", "clarity")) predict(result, pred_cmd = "carat = 1:10") predict(result, pred_cmd = "clarity = levels(clarity)") result <- regress(diamonds, "price", c("carat", "clarity"), int = "carat:clarity") predict(result, pred_data = diamonds) %>% head()
result <- regress(diamonds, "price", c("carat", "clarity")) predict(result, pred_cmd = "carat = 1:10") predict(result, pred_cmd = "clarity = levels(clarity)") result <- regress(diamonds, "price", c("carat", "clarity"), int = "carat:clarity") predict(result, pred_data = diamonds) %>% head()
Predict method for the rforest function
## S3 method for class 'rforest' predict( object, pred_data = NULL, pred_cmd = "", pred_names = "", OOB = NULL, dec = 3, envir = parent.frame(), ... )
## S3 method for class 'rforest' predict( object, pred_data = NULL, pred_cmd = "", pred_names = "", OOB = NULL, dec = 3, envir = parent.frame(), ... )
object |
Return value from |
pred_data |
Provide the dataframe to generate predictions (e.g., diamonds). The dataset must contain all columns used in the estimation |
pred_cmd |
Generate predictions using a command. For example, 'pclass = levels(pclass)' would produce predictions for the different levels of factor ‘pclass'. To add another variable, create a vector of prediction strings, (e.g., c(’pclass = levels(pclass)', 'age = seq(0,100,20)') |
pred_names |
Names for the predictions to be stored. If one name is provided, only the first column of predictions is stored. If empty, the levels in the response variable of the rforest model will be used |
OOB |
Use Out-Of-Bag predictions (TRUE or FALSE). Relevant when evaluating predictions for the training sample. If set to NULL, datasets will be compared to determine if OOB predictions should be used |
dec |
Number of decimals to show |
envir |
Environment to extract data from |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/rforest.html for an example in Radiant
rforest
to generate the result
summary.rforest
to summarize results
result <- rforest(titanic, "survived", c("pclass", "sex"), lev = "Yes") predict(result, pred_cmd = "pclass = levels(pclass)") result <- rforest(diamonds, "price", "carat:color", type = "regression") predict(result, pred_cmd = "carat = 1:3") predict(result, pred_data = diamonds) %>% head()
result <- rforest(titanic, "survived", c("pclass", "sex"), lev = "Yes") predict(result, pred_cmd = "pclass = levels(pclass)") result <- rforest(diamonds, "price", "carat:color", type = "regression") predict(result, pred_cmd = "carat = 1:3") predict(result, pred_data = diamonds) %>% head()
Print method for the model prediction
print_predict_model(x, ..., n = 10, header = "")
print_predict_model(x, ..., n = 10, header = "")
x |
Return value from prediction method |
... |
further arguments passed to or from other methods |
n |
Number of lines of prediction results to print. Use -1 to print all lines |
header |
Header line |
Print method for predict.crtree
## S3 method for class 'crtree.predict' print(x, ..., n = 10)
## S3 method for class 'crtree.predict' print(x, ..., n = 10)
x |
Return value from prediction method |
... |
further arguments passed to or from other methods |
n |
Number of lines of prediction results to print. Use -1 to print all lines |
Print method for predict.gbt
## S3 method for class 'gbt.predict' print(x, ..., n = 10)
## S3 method for class 'gbt.predict' print(x, ..., n = 10)
x |
Return value from prediction method |
... |
further arguments passed to or from other methods |
n |
Number of lines of prediction results to print. Use -1 to print all lines |
Print method for logistic.predict
## S3 method for class 'logistic.predict' print(x, ..., n = 10)
## S3 method for class 'logistic.predict' print(x, ..., n = 10)
x |
Return value from prediction method |
... |
further arguments passed to or from other methods |
n |
Number of lines of prediction results to print. Use -1 to print all lines |
Print method for mnl.predict
## S3 method for class 'mnl.predict' print(x, ..., n = 10)
## S3 method for class 'mnl.predict' print(x, ..., n = 10)
x |
Return value from prediction method |
... |
further arguments passed to or from other methods |
n |
Number of lines of prediction results to print. Use -1 to print all lines |
Print method for predict.nb
## S3 method for class 'nb.predict' print(x, ..., n = 10)
## S3 method for class 'nb.predict' print(x, ..., n = 10)
x |
Return value from prediction method |
... |
further arguments passed to or from other methods |
n |
Number of lines of prediction results to print. Use -1 to print all lines |
Print method for predict.nn
## S3 method for class 'nn.predict' print(x, ..., n = 10)
## S3 method for class 'nn.predict' print(x, ..., n = 10)
x |
Return value from prediction method |
... |
further arguments passed to or from other methods |
n |
Number of lines of prediction results to print. Use -1 to print all lines |
Print method for predict.regress
## S3 method for class 'regress.predict' print(x, ..., n = 10)
## S3 method for class 'regress.predict' print(x, ..., n = 10)
x |
Return value from prediction method |
... |
further arguments passed to or from other methods |
n |
Number of lines of prediction results to print. Use -1 to print all lines |
Print method for predict.rforest
## S3 method for class 'rforest.predict' print(x, ..., n = 10)
## S3 method for class 'rforest.predict' print(x, ..., n = 10)
x |
Return value from prediction method |
... |
further arguments passed to or from other methods |
n |
Number of lines of prediction results to print. Use -1 to print all lines |
Calculate Profit based on cost:margin ratio
profit(pred, rvar, lev, cost = 1, margin = 2)
profit(pred, rvar, lev, cost = 1, margin = 2)
pred |
Prediction or predictor |
rvar |
Response variable |
lev |
The level in the response variable defined as success |
cost |
Cost per treatment (e.g., mailing costs) |
margin |
Margin, or benefit, per 'success' (e.g., customer purchase). A cost:margin ratio of 1:2 implies the cost of False Positive are equivalent to the benefits of a True Positive |
profit
profit(runif(20000), dvd$buy, "yes", cost = 1, margin = 2) profit(ifelse(dvd$buy == "yes", 1, 0), dvd$buy, "yes", cost = 1, margin = 20) profit(ifelse(dvd$buy == "yes", 1, 0), dvd$buy)
profit(runif(20000), dvd$buy, "yes", cost = 1, margin = 2) profit(ifelse(dvd$buy == "yes", 1, 0), dvd$buy, "yes", cost = 1, margin = 20) profit(ifelse(dvd$buy == "yes", 1, 0), dvd$buy)
Launch radiant.model in the default web browser
radiant.model(state, ...)
radiant.model(state, ...)
state |
Path to state file to load |
... |
additional arguments to pass to shiny::runApp (e.g, port = 8080) |
See https://radiant-rstats.github.io/docs/ for documentation and tutorials
## Not run: radiant.model() ## End(Not run)
## Not run: radiant.model() ## End(Not run)
Launch radiant.model in the Rstudio viewer
radiant.model_viewer(state, ...)
radiant.model_viewer(state, ...)
state |
Path to state file to load |
... |
additional arguments to pass to shiny::runApp (e.g, port = 8080) |
See https://radiant-rstats.github.io/docs/ for documentation and tutorials
## Not run: radiant.model_viewer() ## End(Not run)
## Not run: radiant.model_viewer() ## End(Not run)
Launch radiant.model in an Rstudio window
radiant.model_window(state, ...)
radiant.model_window(state, ...)
state |
Path to state file to load |
... |
additional arguments to pass to shiny::runApp (e.g, port = 8080) |
See https://radiant-rstats.github.io/docs/ for documentation and tutorials
## Not run: radiant.model_window() ## End(Not run)
## Not run: radiant.model_window() ## End(Not run)
These functions are provided for compatibility with previous versions of radiant. They will eventually be removed.
ann(...)
ann(...)
... |
Parameters to be passed to the updated functions |
ann is now a synonym for nn
|
scaledf is now a synonym for scale_df
|
Movie ratings
data(ratings)
data(ratings)
A data frame with 110 rows and 4 variables
Use collaborative filtering to create recommendations based on ratings from existing users. Description provided in attr(ratings, "description")
Linear regression using OLS
regress( dataset, rvar, evar, int = "", check = "", form, data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
regress( dataset, rvar, evar, int = "", check = "", form, data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
dataset |
Dataset |
rvar |
The response variable in the regression |
evar |
Explanatory variables in the regression |
int |
Interaction terms to include in the model |
check |
Use "standardize" to see standardized coefficient estimates. Use "stepwise-backward" (or "stepwise-forward", or "stepwise-both") to apply step-wise selection of variables in estimation. Add "robust" for robust estimation of standard errors (HC1) |
form |
Optional formula to use instead of rvar, evar, and int |
data_filter |
Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000") |
arr |
Expression to arrange (sort) the data on (e.g., "color, desc(price)") |
rows |
Rows to select from the specified dataset |
envir |
Environment to extract data from |
See https://radiant-rstats.github.io/docs/model/regress.html for an example in Radiant
A list of all variables used in the regress function as an object of class regress
summary.regress
to summarize results
plot.regress
to plot results
predict.regress
to generate predictions
regress(diamonds, "price", c("carat", "clarity"), check = "standardize") %>% summary() regress(diamonds, "price", c("carat", "clarity")) %>% str()
regress(diamonds, "price", c("carat", "clarity"), check = "standardize") %>% summary() regress(diamonds, "price", c("carat", "clarity")) %>% str()
Remove comments from formula before it is evaluated
remove_comments(x)
remove_comments(x)
x |
Input string |
Cleaned string
Method to render DiagrammeR plots
## S3 method for class 'DiagrammeR' render(object, shiny = shiny::getDefaultReactiveDomain(), ...)
## S3 method for class 'DiagrammeR' render(object, shiny = shiny::getDefaultReactiveDomain(), ...)
object |
DiagrammeR plot |
shiny |
Check if function is called from a shiny application |
... |
Additional arguments |
Repeated simulation
repeater( dataset, nr = 12, vars = "", grid = "", sum_vars = "", byvar = ".sim", fun = "sum", form = "", seed = NULL, name = "", envir = parent.frame() )
repeater( dataset, nr = 12, vars = "", grid = "", sum_vars = "", byvar = ".sim", fun = "sum", form = "", seed = NULL, name = "", envir = parent.frame() )
dataset |
Return value from the simulater function |
nr |
Number times to repeat the simulation |
vars |
Variables to use in repeated simulation |
grid |
Character vector of expressions to use in grid search for constants |
sum_vars |
(Numeric) variables to summaries |
byvar |
Variable(s) to group data by before summarizing |
fun |
Functions to use for summarizing |
form |
A character vector with the formula to apply to the summarized data |
seed |
Seed for the repeated simulation |
name |
Deprecated argument |
envir |
Environment to extract data from |
summary.repeater
to summarize results from repeated simulation
plot.repeater
to plot results from repeated simulation
simdat <- simulater( const = c("var_cost 5", "fixed_cost 1000"), norm = "E 0 100;", discrete = "price 6 8 .3 .7;", form = c( "demand = 1000 - 50*price + E", "profit = demand*(price-var_cost) - fixed_cost", "profit_small = profit < 100" ), seed = 1234 ) repdat <- repeater( simdat, nr = 12, vars = c("E", "price"), sum_vars = "profit", byvar = ".sim", form = "profit_365 = profit_sum < 36500", seed = 1234, ) head(repdat) summary(repdat) plot(repdat)
simdat <- simulater( const = c("var_cost 5", "fixed_cost 1000"), norm = "E 0 100;", discrete = "price 6 8 .3 .7;", form = c( "demand = 1000 - 50*price + E", "profit = demand*(price-var_cost) - fixed_cost", "profit_small = profit < 100" ), seed = 1234 ) repdat <- repeater( simdat, nr = 12, vars = c("E", "price"), sum_vars = "profit", byvar = ".sim", form = "profit_365 = profit_sum < 36500", seed = 1234, ) head(repdat) summary(repdat) plot(repdat)
Random Forest using Ranger
rforest( dataset, rvar, evar, type = "classification", lev = "", mtry = NULL, num.trees = 100, min.node.size = 1, sample.fraction = 1, replace = NULL, num.threads = 12, wts = "None", seed = NA, data_filter = "", arr = "", rows = NULL, envir = parent.frame(), ... )
rforest( dataset, rvar, evar, type = "classification", lev = "", mtry = NULL, num.trees = 100, min.node.size = 1, sample.fraction = 1, replace = NULL, num.threads = 12, wts = "None", seed = NA, data_filter = "", arr = "", rows = NULL, envir = parent.frame(), ... )
dataset |
Dataset |
rvar |
The response variable in the model |
evar |
Explanatory variables in the model |
type |
Model type (i.e., "classification" or "regression") |
lev |
Level to use as the first column in prediction output |
mtry |
Number of variables to possibly split at in each node. Default is the (rounded down) square root of the number variables |
num.trees |
Number of trees to create |
min.node.size |
Minimal node size |
sample.fraction |
Fraction of observations to sample. Default is 1 for sampling with replacement and 0.632 for sampling without replacement |
replace |
Sample with (TRUE) or without (FALSE) replacement. If replace is NULL it will be reset to TRUE if the sample.fraction is equal to 1 and will be set to FALSE otherwise |
num.threads |
Number of parallel threads to use. Defaults to 12 if available |
wts |
Case weights to use in estimation |
seed |
Random seed to use as the starting point |
data_filter |
Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000") |
arr |
Expression to arrange (sort) the data on (e.g., "color, desc(price)") |
rows |
Rows to select from the specified dataset |
envir |
Environment to extract data from |
... |
Further arguments to pass to ranger |
See https://radiant-rstats.github.io/docs/model/rforest.html for an example in Radiant
A list with all variables defined in rforest as an object of class rforest
summary.rforest
to summarize results
plot.rforest
to plot results
predict.rforest
for prediction
rforest(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% summary() rforest(titanic, "survived", c("pclass", "sex")) %>% str() rforest(titanic, "survived", c("pclass", "sex"), max.depth = 1) rforest(diamonds, "price", c("carat", "clarity"), type = "regression") %>% summary()
rforest(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% summary() rforest(titanic, "survived", c("pclass", "sex")) %>% str() rforest(titanic, "survived", c("pclass", "sex"), max.depth = 1) rforest(diamonds, "price", c("carat", "clarity"), type = "regression") %>% summary()
Relative Information Gain (RIG)
rig(pred, rvar, lev, crv = 1e-07, na.rm = TRUE)
rig(pred, rvar, lev, crv = 1e-07, na.rm = TRUE)
pred |
Prediction or predictor |
rvar |
Response variable |
lev |
The level in the response variable defined as success |
crv |
Correction value to avoid log(0) |
na.rm |
Logical that indicates if missing values should be removed (TRUE) or not (FALSE) |
See https://radiant-rstats.github.io/docs/model/evalbin.html for an example in Radiant
RIG statistic
evalbin
to calculate results
summary.evalbin
to summarize results
plot.evalbin
to plot results
rig(runif(20000), dvd$buy, "yes") rig(ifelse(dvd$buy == "yes", 1, 0), dvd$buy, "yes")
rig(runif(20000), dvd$buy, "yes") rig(ifelse(dvd$buy == "yes", 1, 0), dvd$buy, "yes")
Root Mean Squared Error
RMSE(pred, rvar)
RMSE(pred, rvar)
pred |
Prediction (vector) |
rvar |
Response (vector) |
Root Mean Squared Error
R-squared
Rsq(pred, rvar)
Rsq(pred, rvar)
pred |
Prediction (vector) |
rvar |
Response (vector) |
R-squared
Center or standardize variables in a data frame
scale_df(dataset, center = TRUE, scale = TRUE, sf = 2, wts = NULL, calc = TRUE)
scale_df(dataset, center = TRUE, scale = TRUE, sf = 2, wts = NULL, calc = TRUE)
dataset |
Data frame |
center |
Center data (TRUE or FALSE) |
scale |
Scale data (TRUE or FALSE) |
sf |
Scaling factor (default is 2) |
wts |
Weights to use (default is NULL for no weights) |
calc |
Calculate mean and sd or use attributes attached to dat |
Scaled data frame
Standard deviation of weighted sum of variables
sdw(...)
sdw(...)
... |
A matched number of weights and stocks |
A vector of standard deviation estimates
Method to evaluate sensitivity of an analysis
sensitivity(object, ...)
sensitivity(object, ...)
object |
Object of relevant class for which to evaluate sensitivity |
... |
Additional arguments |
sensitivity.dtree
to plot results
Evaluate sensitivity of the decision tree
## S3 method for class 'dtree' sensitivity( object, vars = NULL, decs = NULL, envir = parent.frame(), shiny = FALSE, custom = FALSE, ... )
## S3 method for class 'dtree' sensitivity( object, vars = NULL, decs = NULL, envir = parent.frame(), shiny = FALSE, custom = FALSE, ... )
object |
Return value from |
vars |
Variables to include in the sensitivity analysis |
decs |
Decisions to include in the sensitivity analysis |
envir |
Environment to extract data from |
shiny |
Did the function call originate inside a shiny app |
custom |
Logical (TRUE, FALSE) to indicate if ggplot object (or list of ggplot objects) should be returned. This option can be used to customize plots (e.g., add a title, change x and y labels, etc.). See examples and https://ggplot2.tidyverse.org for options. |
... |
Additional arguments |
See https://radiant-rstats.github.io/docs/model/dtree.html for an example in Radiant
dtree
to generate the result
plot.dtree
to summarize results
summary.dtree
to summarize results
dtree(movie_contract, opt = "max") %>% sensitivity( vars = "legal fees 0 100000 10000", decs = c("Sign with Movie Company", "Sign with TV Network"), custom = FALSE )
dtree(movie_contract, opt = "max") %>% sensitivity( vars = "legal fees 0 100000 10000", decs = c("Sign with Movie Company", "Sign with TV Network"), custom = FALSE )
Clean input command string
sim_cleaner(x)
sim_cleaner(x)
x |
Input string |
Cleaned string
Simulate correlated normally distributed data
sim_cor(n, rho, means, sds, exact = FALSE)
sim_cor(n, rho, means, sds, exact = FALSE)
n |
The number of values to simulate (i.e., the number of rows in the simulated data) |
rho |
A vector of correlations to apply to the columns of the simulated data. The number of values should be equal to one or to the number of combinations of variables to be simulated |
means |
A vector of means. The number of values should be equal to the number of variables to simulate |
sds |
A vector of standard deviations. The number of values should be equal to the number of variables to simulate |
exact |
A logical that indicates if the inputs should be interpreted as population of sample characteristics |
A data.frame with the simulated data
sim <- sim_cor(100, .74, c(0, 10), c(1, 5), exact = TRUE) cor(sim) sim_summary(sim)
sim <- sim_cor(100, .74, c(0, 10), c(1, 5), exact = TRUE) cor(sim) sim_summary(sim)
Split input command string
sim_splitter(x, symbol = " ")
sim_splitter(x, symbol = " ")
x |
Input string |
symbol |
Symbol used to split the command string |
Split input command string
Print simulation summary
sim_summary(dataset, dc = get_class(dataset), fun = "", dec = 4)
sim_summary(dataset, dc = get_class(dataset), fun = "", dec = 4)
dataset |
Simulated data |
dc |
Variable classes |
fun |
Summary function to apply |
dec |
Number of decimals to show |
simulater
to run a simulation
repeater
to run a repeated simulation
simulater( const = "cost 3", norm = "demand 2000 1000", discrete = "price 5 8 .3 .7", form = c("profit = demand * (price - cost)", "profit5K = profit > 5000"), seed = 1234 ) %>% sim_summary()
simulater( const = "cost 3", norm = "demand 2000 1000", discrete = "price 5 8 .3 .7", form = c("profit = demand * (price - cost)", "profit5K = profit > 5000"), seed = 1234 ) %>% sim_summary()
Simulate data for decision analysis
simulater( const = "", lnorm = "", norm = "", unif = "", discrete = "", binom = "", pois = "", sequ = "", grid = "", data = NULL, form = "", funcs = "", seed = NULL, nexact = FALSE, ncorr = NULL, name = "", nr = 1000, dataset = NULL, envir = parent.frame() )
simulater( const = "", lnorm = "", norm = "", unif = "", discrete = "", binom = "", pois = "", sequ = "", grid = "", data = NULL, form = "", funcs = "", seed = NULL, nexact = FALSE, ncorr = NULL, name = "", nr = 1000, dataset = NULL, envir = parent.frame() )
const |
A character vector listing the constants to include in the analysis (e.g., c("cost = 3", "size = 4")) |
lnorm |
A character vector listing the log-normally distributed random variables to include in the analysis (e.g., "demand 2000 1000" where the first number is the log-mean and the second is the log-standard deviation) |
norm |
A character vector listing the normally distributed random variables to include in the analysis (e.g., "demand 2000 1000" where the first number is the mean and the second is the standard deviation) |
unif |
A character vector listing the uniformly distributed random variables to include in the analysis (e.g., "demand 0 1" where the first number is the minimum value and the second is the maximum value) |
discrete |
A character vector listing the random variables with a discrete distribution to include in the analysis (e.g., "price 5 8 .3 .7" where the first set of numbers are the values and the second set the probabilities |
binom |
A character vector listing the random variables with a binomial distribution to include in the analysis (e.g., "crash 100 .01") where the first number is the number of trials and the second is the probability of success) |
pois |
A character vector listing the random variables with a poisson distribution to include in the analysis (e.g., "demand 10") where the number is the lambda value (i.e., the average number of events or the event rate) |
sequ |
A character vector listing the start and end for a sequence to include in the analysis (e.g., "trend 1 100 1"). The number of 'steps' is determined by the number of simulations |
grid |
A character vector listing the start, end, and step for a set of sequences to include in the analysis (e.g., "trend 1 100 1"). The number of rows in the expanded will over ride the number of simulations |
data |
Dataset to be used in the calculations |
form |
A character vector with the formula to evaluate (e.g., "profit = demand * (price - cost)") |
funcs |
A named list of user defined functions to apply to variables generated as part of the simulation |
seed |
Optional seed used in simulation |
nexact |
Logical to indicate if normally distributed random variables should be simulated to the exact specified values |
ncorr |
A string of correlations used for normally distributed random variables. The number of values should be equal to one or to the number of combinations of variables simulated |
name |
Deprecated argument |
nr |
Number of simulations |
dataset |
Data list from previous simulation. Used by repeater function |
envir |
Environment to extract data from |
See https://radiant-rstats.github.io/docs/model/simulater.html for an example in Radiant
A data.frame with the simulated data
summary.simulater
to summarize results
plot.simulater
to plot results
simulater( const = "cost 3", norm = "demand 2000 1000", discrete = "price 5 8 .3 .7", form = "profit = demand * (price - cost)", seed = 1234 ) %>% str()
simulater( const = "cost 3", norm = "demand 2000 1000", discrete = "price 5 8 .3 .7", form = "profit = demand * (price - cost)", seed = 1234 ) %>% str()
Deprecated: Store method for the crs function
## S3 method for class 'crs' store(dataset, object, name, ...)
## S3 method for class 'crs' store(dataset, object, name, ...)
dataset |
Dataset |
object |
Return value from |
name |
Name to assign to the dataset |
... |
further arguments passed to or from other methods |
Return recommendations See https://radiant-rstats.github.io/docs/model/crs.html for an example in Radiant
Store predicted values generated in the mnl function
## S3 method for class 'mnl.predict' store(dataset, object, name = NULL, ...)
## S3 method for class 'mnl.predict' store(dataset, object, name = NULL, ...)
dataset |
Dataset to add predictions to |
object |
Return value from model function |
name |
Variable name(s) assigned to predicted values. If empty, the levels of the response variable will be used |
... |
Additional arguments |
See https://radiant-rstats.github.io/docs/model/mnl.html for an example in Radiant
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) pred <- predict(result, pred_data = ketchup) ketchup <- store(ketchup, pred, name = c("heinz28", "heinz32", "heinz41", "hunts32"))
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) pred <- predict(result, pred_data = ketchup) ketchup <- store(ketchup, pred, name = c("heinz28", "heinz32", "heinz41", "hunts32"))
Store residuals from a model
## S3 method for class 'model' store(dataset, object, name = "residuals", ...)
## S3 method for class 'model' store(dataset, object, name = "residuals", ...)
dataset |
Dataset to append residuals to |
object |
Return value from a model function |
name |
Variable name(s) assigned to model residuals |
... |
Additional arguments |
The store method for objects of class "model". Adds model residuals to the dataset while handling missing values and filters. See https://radiant-rstats.github.io/docs/model/regress.html for an example in Radiant
regress(diamonds, rvar = "price", evar = c("carat", "cut"), data_filter = "price > 1000") %>% store(diamonds, ., name = "resid") %>% head()
regress(diamonds, rvar = "price", evar = c("carat", "cut"), data_filter = "price > 1000") %>% store(diamonds, ., name = "resid") %>% head()
Store predicted values generated in model functions
## S3 method for class 'model.predict' store(dataset, object, name = "prediction", ...)
## S3 method for class 'model.predict' store(dataset, object, name = "prediction", ...)
dataset |
Dataset to add predictions to |
object |
Return value from model function |
name |
Variable name(s) assigned to predicted values |
... |
Additional arguments |
See https://radiant-rstats.github.io/docs/model/regress.html for an example in Radiant
regress(diamonds, rvar = "price", evar = c("carat", "cut")) %>% predict(pred_data = diamonds) %>% store(diamonds, ., name = c("pred", "pred_low", "pred_high")) %>% head()
regress(diamonds, rvar = "price", evar = c("carat", "cut")) %>% predict(pred_data = diamonds) %>% store(diamonds, ., name = c("pred", "pred_low", "pred_high")) %>% head()
Store predicted values generated in the nb function
## S3 method for class 'nb.predict' store(dataset, object, name = NULL, ...)
## S3 method for class 'nb.predict' store(dataset, object, name = NULL, ...)
dataset |
Dataset to add predictions to |
object |
Return value from model function |
name |
Variable name(s) assigned to predicted values. If empty, the levels of the response variable will be used |
... |
Additional arguments |
See https://radiant-rstats.github.io/docs/model/nb.html for an example in Radiant
result <- nb(titanic, rvar = "survived", evar = c("pclass", "sex", "age")) pred <- predict(result, pred_data = titanic) titanic <- store(titanic, pred, name = c("Yes", "No"))
result <- nb(titanic, rvar = "survived", evar = c("pclass", "sex", "age")) pred <- predict(result, pred_data = titanic) titanic <- store(titanic, pred, name = c("Yes", "No"))
Store predicted values generated in the rforest function
## S3 method for class 'rforest.predict' store(dataset, object, name = NULL, ...)
## S3 method for class 'rforest.predict' store(dataset, object, name = NULL, ...)
dataset |
Dataset to add predictions to |
object |
Return value from model function |
name |
Variable name(s) assigned to predicted values. If empty, the levels of the response variable will be used |
... |
Additional arguments |
See https://radiant-rstats.github.io/docs/model/rforest.html for an example in Radiant
result <- rforest( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) pred <- predict(result, pred_data = ketchup) ketchup <- store(ketchup, pred, name = c("heinz28", "heinz32", "heinz41", "hunts32"))
result <- rforest( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) pred <- predict(result, pred_data = ketchup) ketchup <- store(ketchup, pred, name = c("heinz28", "heinz32", "heinz41", "hunts32"))
Summary method for the confusion matrix
## S3 method for class 'confusion' summary(object, dec = 3, ...)
## S3 method for class 'confusion' summary(object, dec = 3, ...)
object |
Return value from |
dec |
Number of decimals to show |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/evalbin.html for an example in Radiant
confusion
to generate results
plot.confusion
to visualize result
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% confusion(c("pred1", "pred2"), "buy") %>% summary()
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% confusion(c("pred1", "pred2"), "buy") %>% summary()
Summary method for Collaborative Filter
## S3 method for class 'crs' summary(object, n = 36, dec = 2, ...)
## S3 method for class 'crs' summary(object, n = 36, dec = 2, ...)
object |
Return value from |
n |
Number of lines of recommendations to print. Use -1 to print all lines |
dec |
Number of decimals to show |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/crs.html for an example in Radiant
crs
to generate the results
plot.crs
to plot results if the actual ratings are available
crs(ratings, id = "Users", prod = "Movies", pred = c("M6", "M7", "M8", "M9", "M10"), rate = "Ratings", data_filter = "training == 1" ) %>% summary()
crs(ratings, id = "Users", prod = "Movies", pred = c("M6", "M7", "M8", "M9", "M10"), rate = "Ratings", data_filter = "training == 1" ) %>% summary()
Summary method for the crtree function
## S3 method for class 'crtree' summary(object, prn = TRUE, splits = FALSE, cptab = FALSE, modsum = FALSE, ...)
## S3 method for class 'crtree' summary(object, prn = TRUE, splits = FALSE, cptab = FALSE, modsum = FALSE, ...)
object |
Return value from |
prn |
Print tree in text form |
splits |
Print the tree splitting metrics used |
cptab |
Print the cp table |
modsum |
Print the model summary |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/crtree.html for an example in Radiant
crtree
to generate results
plot.crtree
to plot results
predict.crtree
for prediction
result <- crtree(titanic, "survived", c("pclass", "sex"), lev = "Yes") summary(result) result <- crtree(diamonds, "price", c("carat", "color"), type = "regression") summary(result)
result <- crtree(titanic, "survived", c("pclass", "sex"), lev = "Yes") summary(result) result <- crtree(diamonds, "price", c("carat", "color"), type = "regression") summary(result)
Summary method for the dtree function
## S3 method for class 'dtree' summary(object, input = TRUE, output = FALSE, dec = 2, ...)
## S3 method for class 'dtree' summary(object, input = TRUE, output = FALSE, dec = 2, ...)
object |
Return value from |
input |
Print decision tree input |
output |
Print decision tree output |
dec |
Number of decimals to show |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/dtree.html for an example in Radiant
dtree
to generate the results
plot.dtree
to plot results
sensitivity.dtree
to plot results
dtree(movie_contract, opt = "max") %>% summary(input = TRUE) dtree(movie_contract, opt = "max") %>% summary(input = FALSE, output = TRUE)
dtree(movie_contract, opt = "max") %>% summary(input = TRUE) dtree(movie_contract, opt = "max") %>% summary(input = FALSE, output = TRUE)
Summary method for the evalbin function
## S3 method for class 'evalbin' summary(object, prn = TRUE, dec = 3, ...)
## S3 method for class 'evalbin' summary(object, prn = TRUE, dec = 3, ...)
object |
Return value from |
prn |
Print full table of measures per model and bin |
dec |
Number of decimals to show |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/evalbin.html for an example in Radiant
evalbin
to summarize results
plot.evalbin
to plot results
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% evalbin(c("pred1", "pred2"), "buy") %>% summary()
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% evalbin(c("pred1", "pred2"), "buy") %>% summary()
Summary method for the evalreg function
## S3 method for class 'evalreg' summary(object, dec = 3, ...)
## S3 method for class 'evalreg' summary(object, dec = 3, ...)
object |
Return value from |
dec |
Number of decimals to show |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/evalreg.html for an example in Radiant
evalreg
to summarize results
plot.evalreg
to plot results
data.frame(price = diamonds$price, pred1 = rnorm(3000), pred2 = diamonds$price) %>% evalreg(pred = c("pred1", "pred2"), "price") %>% summary()
data.frame(price = diamonds$price, pred1 = rnorm(3000), pred2 = diamonds$price) %>% evalreg(pred = c("pred1", "pred2"), "price") %>% summary()
Summary method for the gbt function
## S3 method for class 'gbt' summary(object, prn = TRUE, ...)
## S3 method for class 'gbt' summary(object, prn = TRUE, ...)
object |
Return value from |
prn |
Print iteration history |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/gbt.html for an example in Radiant
gbt
to generate results
plot.gbt
to plot results
predict.gbt
for prediction
result <- gbt( titanic, "survived", c("pclass", "sex"), early_stopping_rounds = 0, nthread = 1 ) summary(result)
result <- gbt( titanic, "survived", c("pclass", "sex"), early_stopping_rounds = 0, nthread = 1 ) summary(result)
Summary method for the logistic function
## S3 method for class 'logistic' summary(object, sum_check = "", conf_lev = 0.95, test_var = "", dec = 3, ...)
## S3 method for class 'logistic' summary(object, sum_check = "", conf_lev = 0.95, test_var = "", dec = 3, ...)
object |
Return value from |
sum_check |
Optional output. "vif" to show multicollinearity diagnostics. "confint" to show coefficient confidence interval estimates. "odds" to show odds ratios and confidence interval estimates. |
conf_lev |
Confidence level to use for coefficient and odds confidence intervals (.95 is the default) |
test_var |
Variables to evaluate in model comparison (i.e., a competing models Chi-squared test) |
dec |
Number of decimals to show |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/logistic.html for an example in Radiant
logistic
to generate the results
plot.logistic
to plot the results
predict.logistic
to generate predictions
plot.model.predict
to plot prediction output
result <- logistic(titanic, "survived", "pclass", lev = "Yes") result <- logistic(titanic, "survived", "pclass", lev = "Yes") summary(result, test_var = "pclass") res <- logistic(titanic, "survived", c("pclass", "sex"), int = "pclass:sex", lev = "Yes") summary(res, sum_check = c("vif", "confint", "odds")) titanic %>% logistic("survived", c("pclass", "sex", "age"), lev = "Yes") %>% summary("vif")
result <- logistic(titanic, "survived", "pclass", lev = "Yes") result <- logistic(titanic, "survived", "pclass", lev = "Yes") summary(result, test_var = "pclass") res <- logistic(titanic, "survived", c("pclass", "sex"), int = "pclass:sex", lev = "Yes") summary(res, sum_check = c("vif", "confint", "odds")) titanic %>% logistic("survived", c("pclass", "sex", "age"), lev = "Yes") %>% summary("vif")
Summary method for the mnl function
## S3 method for class 'mnl' summary(object, sum_check = "", conf_lev = 0.95, test_var = "", dec = 3, ...)
## S3 method for class 'mnl' summary(object, sum_check = "", conf_lev = 0.95, test_var = "", dec = 3, ...)
object |
Return value from |
sum_check |
Optional output. "confint" to show coefficient confidence interval estimates. "rrr" to show relative risk ratios (RRRs) and confidence interval estimates. |
conf_lev |
Confidence level to use for coefficient and RRRs confidence intervals (.95 is the default) |
test_var |
Variables to evaluate in model comparison (i.e., a competing models Chi-squared test) |
dec |
Number of decimals to show |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/mnl.html for an example in Radiant
mnl
to generate the results
plot.mnl
to plot the results
predict.mnl
to generate predictions
plot.model.predict
to plot prediction output
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) summary(result)
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" ) summary(result)
Summary method for the nb function
## S3 method for class 'nb' summary(object, dec = 3, ...)
## S3 method for class 'nb' summary(object, dec = 3, ...)
object |
Return value from |
dec |
Decimals |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/nb.html for an example in Radiant
nb
to generate results
plot.nb
to plot results
predict.nb
for prediction
result <- nb(titanic, "survived", c("pclass", "sex", "age")) summary(result)
result <- nb(titanic, "survived", c("pclass", "sex", "age")) summary(result)
Summary method for the nn function
## S3 method for class 'nn' summary(object, prn = TRUE, ...)
## S3 method for class 'nn' summary(object, prn = TRUE, ...)
object |
Return value from |
prn |
Print list of weights |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/nn.html for an example in Radiant
nn
to generate results
plot.nn
to plot results
predict.nn
for prediction
result <- nn(titanic, "survived", "pclass", lev = "Yes") summary(result)
result <- nn(titanic, "survived", "pclass", lev = "Yes") summary(result)
Summary method for the regress function
## S3 method for class 'regress' summary(object, sum_check = "", conf_lev = 0.95, test_var = "", dec = 3, ...)
## S3 method for class 'regress' summary(object, sum_check = "", conf_lev = 0.95, test_var = "", dec = 3, ...)
object |
Return value from |
sum_check |
Optional output. "rsme" to show the root mean squared error and the standard deviation of the residuals. "sumsquares" to show the sum of squares table. "vif" to show multicollinearity diagnostics. "confint" to show coefficient confidence interval estimates. |
conf_lev |
Confidence level used to estimate confidence intervals (.95 is the default) |
test_var |
Variables to evaluate in model comparison (i.e., a competing models F-test) |
dec |
Number of decimals to show |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/regress.html for an example in Radiant
regress
to generate the results
plot.regress
to plot results
predict.regress
to generate predictions
result <- regress(diamonds, "price", c("carat", "clarity")) summary(result, sum_check = c("rmse", "sumsquares", "vif", "confint"), test_var = "clarity") result <- regress(ideal, "y", c("x1", "x2")) summary(result, test_var = "x2") ideal %>% regress("y", "x1:x3") %>% summary()
result <- regress(diamonds, "price", c("carat", "clarity")) summary(result, sum_check = c("rmse", "sumsquares", "vif", "confint"), test_var = "clarity") result <- regress(ideal, "y", c("x1", "x2")) summary(result, test_var = "x2") ideal %>% regress("y", "x1:x3") %>% summary()
Summarize repeated simulation
## S3 method for class 'repeater' summary(object, dec = 4, ...)
## S3 method for class 'repeater' summary(object, dec = 4, ...)
object |
Return value from |
dec |
Number of decimals to show |
... |
further arguments passed to or from other methods |
repeater
to run a repeated simulation
plot.repeater
to plot results from repeated simulation
Summary method for the rforest function
## S3 method for class 'rforest' summary(object, ...)
## S3 method for class 'rforest' summary(object, ...)
object |
Return value from |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/rforest.html for an example in Radiant
rforest
to generate results
plot.rforest
to plot results
predict.rforest
for prediction
result <- rforest(titanic, "survived", "pclass", lev = "Yes") summary(result)
result <- rforest(titanic, "survived", "pclass", lev = "Yes") summary(result)
Summary method for the simulater function
## S3 method for class 'simulater' summary(object, dec = 4, ...)
## S3 method for class 'simulater' summary(object, dec = 4, ...)
object |
Return value from |
dec |
Number of decimals to show |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/simulater.html for an example in Radiant
simulater
to generate the results
plot.simulater
to plot results
simdat <- simulater(norm = "demand 2000 1000", seed = 1234) summary(simdat)
simdat <- simulater(norm = "demand 2000 1000", seed = 1234) summary(simdat)
Summary method for the uplift function
## S3 method for class 'uplift' summary(object, prn = TRUE, dec = 3, ...)
## S3 method for class 'uplift' summary(object, prn = TRUE, dec = 3, ...)
object |
Return value from |
prn |
Print full table of measures per model and bin |
dec |
Number of decimals to show |
... |
further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/evalbin.html for an example in Radiant
evalbin
to summarize results
plot.evalbin
to plot results
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% evalbin(c("pred1", "pred2"), "buy") %>% summary()
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% evalbin(c("pred1", "pred2"), "buy") %>% summary()
Add interaction terms to list of test variables if needed
test_specs(tv, int)
test_specs(tv, int)
tv |
List of variables to use for testing for regress or logistic |
int |
Interaction terms specified |
See https://radiant-rstats.github.io/docs/model/regress.html for an example in Radiant
A vector of variables names to test
test_specs("a", "a:b") test_specs("a", c("a:b", "b:c")) test_specs("a", c("a:b", "b:c", "I(c^2)")) test_specs(c("a", "b", "c"), c("a:b", "b:c", "I(c^2)"))
test_specs("a", "a:b") test_specs("a", c("a:b", "b:c")) test_specs("a", c("a:b", "b:c", "I(c^2)")) test_specs(c("a", "b", "c"), c("a:b", "b:c", "I(c^2)"))
Evaluate uplift for different (binary) classification models
uplift( dataset, pred, rvar, lev = "", tvar, tlev = "", qnt = 10, cost = 1, margin = 2, scale = 1, train = "All", data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
uplift( dataset, pred, rvar, lev = "", tvar, tlev = "", qnt = 10, cost = 1, margin = 2, scale = 1, train = "All", data_filter = "", arr = "", rows = NULL, envir = parent.frame() )
dataset |
Dataset |
pred |
Predictions or predictors |
rvar |
Response variable |
lev |
The level in the response variable defined as success |
tvar |
Treatment variable |
tlev |
The level in the treatment variable defined as the treatment |
qnt |
Number of bins to create |
cost |
Cost for each connection (e.g., email or mailing) |
margin |
Margin on each customer purchase |
scale |
Scaling factor to apply to calculations |
train |
Use data from training ("Training"), test ("Test"), both ("Both"), or all data ("All") to evaluate model evalbin |
data_filter |
Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000") |
arr |
Expression to arrange (sort) the data on (e.g., "color, desc(price)") |
rows |
Rows to select from the specified dataset |
envir |
Environment to extract data from |
Evaluate uplift for different (binary) classification models based on predictions. See https://radiant-rstats.github.io/docs/model/evalbin.html for an example in Radiant
A list of results
summary.evalbin
to summarize results
plot.evalbin
to plot results
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% evalbin(c("pred1", "pred2"), "buy") %>% str()
data.frame(buy = dvd$buy, pred1 = runif(20000), pred2 = ifelse(dvd$buy == "yes", 1, 0)) %>% evalbin(c("pred1", "pred2"), "buy") %>% str()
Check if main effects for all interaction effects are included in the model
var_check(ev, cn, intv = c())
var_check(ev, cn, intv = c())
ev |
List of explanatory variables provided to |
cn |
Column names for all explanatory variables in the dataset |
intv |
Interaction terms specified |
If ':' is used to select a range evar is updated. See https://radiant-rstats.github.io/docs/model/regress.html for an example in Radiant
vars
is a vector of right-hand side variables, possibly with interactions, iv
is the list of explanatory variables, and intv
are interaction terms
var_check("a:d", c("a", "b", "c", "d")) var_check(c("a", "b"), c("a", "b"), "a:c") var_check(c("a", "b"), c("a", "b"), "a:c") var_check(c("a", "b"), c("a", "b"), c("a:c", "I(b^2)"))
var_check("a:d", c("a", "b", "c", "d")) var_check(c("a", "b"), c("a", "b"), "a:c") var_check(c("a", "b"), c("a", "b"), "a:c") var_check(c("a", "b"), c("a", "b"), c("a:c", "I(b^2)"))
Variable importance using the vip package and permutation importance
varimp(object, rvar, lev, data = NULL, seed = 1234)
varimp(object, rvar, lev, data = NULL, seed = 1234)
object |
Model object created by Radiant |
rvar |
Label to identify the response or target variable |
lev |
Reference class for binary classifier (rvar) |
data |
Data to use for prediction. Will default to the data used to estimate the model |
seed |
Random seed for reproducibility |
Plot permutation importance
varimp_plot(object, rvar, lev, data = NULL, seed = 1234)
varimp_plot(object, rvar, lev, data = NULL, seed = 1234)
object |
Model object created by Radiant |
rvar |
Label to identify the response or target variable |
lev |
Reference class for binary classifier (rvar) |
data |
Data to use for prediction. Will default to the data used to estimate the model |
seed |
Random seed for reproducibility |
Write coefficient table for linear and logistic regression
write.coeff(object, file = "", sort = FALSE, intercept = TRUE)
write.coeff(object, file = "", sort = FALSE, intercept = TRUE)
object |
A fitted model object of class regress or logistic |
file |
A character string naming a file. "" indicates output to the console |
sort |
Sort table by variable importance |
intercept |
Include the intercept in the output (TRUE or FALSE). TRUE is the default |
Write coefficients and importance scores to csv or or return as a data.frame
regress( diamonds, rvar = "price", evar = c("carat", "clarity", "color", "x"), int = c("carat:clarity", "clarity:color", "I(x^2)"), check = "standardize" ) %>% write.coeff(sort = TRUE) %>% format_df(dec = 3) logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% write.coeff(intercept = FALSE, sort = TRUE) %>% format_df(dec = 2)
regress( diamonds, rvar = "price", evar = c("carat", "clarity", "color", "x"), int = c("carat:clarity", "clarity:color", "I(x^2)"), check = "standardize" ) %>% write.coeff(sort = TRUE) %>% format_df(dec = 3) logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% write.coeff(intercept = FALSE, sort = TRUE) %>% format_df(dec = 2)