├── .Rbuildignore ├── .github ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md └── workflows │ ├── R-CMD-check-hard.yaml │ ├── R-CMD-check.yaml │ ├── lock.yaml │ ├── pkgdown.yaml │ ├── pr-commands.yaml │ └── test-coverage.yaml ├── .gitignore ├── .vscode ├── extensions.json └── settings.json ├── DESCRIPTION ├── LICENSE ├── LICENSE.md ├── NAMESPACE ├── NEWS.md ├── R ├── C5_rules_C5.0.R ├── aaa-import-standalone-obj-type.R ├── aaa-import-standalone-types-check.R ├── aaa.R ├── aaa_archive.R ├── aaa_models.R ├── aaa_multi_predict.R ├── aaa_quantiles.R ├── aaa_spark_helpers.R ├── add_in.R ├── adds.R ├── arguments.R ├── augment.R ├── auto_ml.R ├── auto_ml_h2o.R ├── autoplot.R ├── bag_mars.R ├── bag_mars_earth.R ├── bag_mlp.R ├── bag_mlp_nnet.R ├── bag_tree.R ├── bag_tree_C5.0.R ├── bag_tree_rpart.R ├── bart.R ├── bart_data.R ├── bart_dbarts.R ├── boost_tree.R ├── boost_tree_C5.0.R ├── boost_tree_data.R ├── boost_tree_h2o.R ├── boost_tree_lightgbm.R ├── boost_tree_mboost.R ├── boost_tree_spark.R ├── boost_tree_xgboost.R ├── c5_rules.R ├── case_weights.R ├── condense_control.R ├── control_parsnip.R ├── convert_data.R ├── cubist_rules.R ├── cubist_rules_Cubist.R ├── data.R ├── decision_tree.R ├── decision_tree_C5.0.R ├── decision_tree_data.R ├── decision_tree_partykit.R ├── decision_tree_rpart.R ├── decision_tree_spark.R ├── descriptors.R ├── discrim_flexible.R ├── discrim_flexible_earth.R ├── discrim_linear.R ├── discrim_linear_MASS.R ├── discrim_linear_mda.R ├── discrim_linear_sda.R ├── discrim_linear_sparsediscrim.R ├── discrim_quad.R ├── discrim_quad_MASS.R ├── discrim_quad_sparsediscrim.R ├── discrim_regularized.R ├── discrim_regularized_klaR.R ├── engine_docs.R ├── engines.R ├── extract.R ├── fit.R ├── fit_control.R ├── fit_helpers.R ├── gen_additive_mod.R ├── gen_additive_mod_data.R ├── gen_additive_mod_mgcv.R ├── glm_grouped.R ├── glmnet-engines.R ├── glmnet_details.R ├── install_packages.R ├── linear_reg.R ├── linear_reg_brulee.R ├── linear_reg_data.R ├── linear_reg_gee.R ├── linear_reg_glm.R ├── linear_reg_glmer.R ├── linear_reg_glmnet.R ├── linear_reg_gls.R ├── linear_reg_h2o.R ├── linear_reg_keras.R ├── linear_reg_lm.R ├── linear_reg_lme.R ├── linear_reg_lmer.R ├── linear_reg_quantreg.R ├── linear_reg_spark.R ├── linear_reg_stan.R ├── linear_reg_stan_glmer.R ├── logistic_reg.R ├── logistic_reg_LiblineaR.R ├── logistic_reg_brulee.R ├── logistic_reg_data.R ├── logistic_reg_gee.R ├── logistic_reg_glm.R ├── logistic_reg_glmer.R ├── logistic_reg_glmnet.R ├── logistic_reg_h2o.R ├── logistic_reg_keras.R ├── logistic_reg_spark.R ├── logistic_reg_stan.R ├── logistic_reg_stan_glmer.R ├── mars.R ├── mars_data.R ├── mars_earth.R ├── misc.R ├── mlp.R ├── mlp_brulee.R ├── mlp_brulee_two_layer.R ├── mlp_data.R ├── mlp_h2o.R ├── mlp_keras.R ├── mlp_nnet.R ├── model_formula.R ├── model_object_docs.R ├── multinom_reg.R ├── multinom_reg_brulee.R ├── multinom_reg_data.R ├── multinom_reg_glmnet.R ├── multinom_reg_h2o.R ├── multinom_reg_keras.R ├── multinom_reg_nnet.R ├── multinom_reg_spark.R ├── naive_Bayes.R ├── naive_Bayes_h2o.R ├── naive_Bayes_klaR.R ├── naive_Bayes_naivebayes.R ├── nearest_neighbor.R ├── nearest_neighbor_data.R ├── nearest_neighbor_kknn.R ├── nullmodel.R ├── nullmodel_data.R ├── parsnip-package.R ├── partykit.R ├── pls.R ├── pls_mixOmics.R ├── poisson_reg.R ├── poisson_reg_gee.R ├── poisson_reg_glm.R ├── poisson_reg_glmer.R ├── poisson_reg_glmnet.R ├── poisson_reg_h2o.R ├── poisson_reg_hurdle.R ├── poisson_reg_stan.R ├── poisson_reg_stan_glmer.R ├── poisson_reg_zeroinfl.R ├── predict.R ├── predict_class.R ├── predict_classprob.R ├── predict_hazard.R ├── predict_interval.R ├── predict_linear_pred.R ├── predict_numeric.R ├── predict_quantile.R ├── predict_raw.R ├── predict_survival.R ├── predict_time.R ├── print.R ├── proportional_hazards.R ├── proportional_hazards_data.R ├── proportional_hazards_glmnet.R ├── proportional_hazards_survival.R ├── rand_forest.R ├── rand_forest_aorsf.R ├── rand_forest_data.R ├── rand_forest_h2o.R ├── rand_forest_partykit.R ├── rand_forest_randomForest.R ├── rand_forest_ranger.R ├── rand_forest_spark.R ├── reexports.R ├── repair_call.R ├── req_pkgs.R ├── required_pkgs.R ├── rule_fit.R ├── rule_fit_h2o.R ├── rule_fit_xrf.R ├── sparsevctrs.R ├── standalone-survival.R ├── surv_reg.R ├── surv_reg_data.R ├── survival-censoring-model.R ├── survival-censoring-weights.R ├── survival-helpers.R ├── survival_reg.R ├── survival_reg_data.R ├── survival_reg_flexsurv.R ├── survival_reg_flexsurvspline.R ├── survival_reg_survival.R ├── svm_linear.R ├── svm_linear_LiblineaR.R ├── svm_linear_data.R ├── svm_linear_kernlab.R ├── svm_poly.R ├── svm_poly_data.R ├── svm_poly_kernlab.R ├── svm_rbf.R ├── svm_rbf_data.R ├── svm_rbf_kernlab.R ├── tidy.R ├── tidy_glmnet.R ├── tidy_liblinear.R ├── translate.R ├── tunable.R ├── tune_args.R ├── type_sum.R ├── update.R └── varying.R ├── README.Rmd ├── README.md ├── _pkgdown.yml ├── air.toml ├── codecov.yml ├── data └── model_db.rda ├── inst ├── README-DOCS.md ├── add-in │ ├── gadget.R │ └── parsnip_model_db.R ├── models.tsv └── rstudio │ └── addins.dcf ├── issue_template.md ├── man-roxygen ├── spec-details.R ├── spec-references.R └── spec-survival.R ├── man ├── C5.0_train.Rd ├── C5_rules.Rd ├── add_on_exports.Rd ├── add_rowindex.Rd ├── augment.Rd ├── auto_ml.Rd ├── autoplot.model_fit.Rd ├── bag_mars.Rd ├── bag_mlp.Rd ├── bag_tree.Rd ├── bart-internal.Rd ├── bart.Rd ├── boost_tree.Rd ├── case_weights.Rd ├── case_weights_allowed.Rd ├── censoring_weights.Rd ├── check_empty_ellipse.Rd ├── condense_control.Rd ├── control_parsnip.Rd ├── convert_helpers.Rd ├── convert_stan_interval.Rd ├── ctree_train.Rd ├── cubist_rules.Rd ├── decision_tree.Rd ├── descriptors.Rd ├── details_C5_rules_C5.0.Rd ├── details_auto_ml_h2o.Rd ├── details_bag_mars_earth.Rd ├── details_bag_mlp_nnet.Rd ├── details_bag_tree_C5.0.Rd ├── details_bag_tree_rpart.Rd ├── details_bart_dbarts.Rd ├── details_boost_tree_C5.0.Rd ├── details_boost_tree_h2o.Rd ├── details_boost_tree_lightgbm.Rd ├── details_boost_tree_mboost.Rd ├── details_boost_tree_spark.Rd ├── details_boost_tree_xgboost.Rd ├── details_cubist_rules_Cubist.Rd ├── details_decision_tree_C5.0.Rd ├── details_decision_tree_partykit.Rd ├── details_decision_tree_rpart.Rd ├── details_decision_tree_spark.Rd ├── details_discrim_flexible_earth.Rd ├── details_discrim_linear_MASS.Rd ├── details_discrim_linear_mda.Rd ├── details_discrim_linear_sda.Rd ├── details_discrim_linear_sparsediscrim.Rd ├── details_discrim_quad_MASS.Rd ├── details_discrim_quad_sparsediscrim.Rd ├── details_discrim_regularized_klaR.Rd ├── details_gen_additive_mod_mgcv.Rd ├── details_linear_reg_brulee.Rd ├── details_linear_reg_gee.Rd ├── details_linear_reg_glm.Rd ├── details_linear_reg_glmer.Rd ├── details_linear_reg_glmnet.Rd ├── details_linear_reg_gls.Rd ├── details_linear_reg_h2o.Rd ├── details_linear_reg_keras.Rd ├── details_linear_reg_lm.Rd ├── details_linear_reg_lme.Rd ├── details_linear_reg_lmer.Rd ├── details_linear_reg_quantreg.Rd ├── details_linear_reg_spark.Rd ├── details_linear_reg_stan.Rd ├── details_linear_reg_stan_glmer.Rd ├── details_logistic_reg_LiblineaR.Rd ├── details_logistic_reg_brulee.Rd ├── details_logistic_reg_gee.Rd ├── details_logistic_reg_glm.Rd ├── details_logistic_reg_glmer.Rd ├── details_logistic_reg_glmnet.Rd ├── details_logistic_reg_h2o.Rd ├── details_logistic_reg_keras.Rd ├── details_logistic_reg_spark.Rd ├── details_logistic_reg_stan.Rd ├── details_logistic_reg_stan_glmer.Rd ├── details_mars_earth.Rd ├── details_mlp_brulee.Rd ├── details_mlp_brulee_two_layer.Rd ├── details_mlp_h2o.Rd ├── details_mlp_keras.Rd ├── details_mlp_nnet.Rd ├── details_multinom_reg_brulee.Rd ├── details_multinom_reg_glmnet.Rd ├── details_multinom_reg_h2o.Rd ├── details_multinom_reg_keras.Rd ├── details_multinom_reg_nnet.Rd ├── details_multinom_reg_spark.Rd ├── details_naive_Bayes_h2o.Rd ├── details_naive_Bayes_klaR.Rd ├── details_naive_Bayes_naivebayes.Rd ├── details_nearest_neighbor_kknn.Rd ├── details_pls_mixOmics.Rd ├── details_poisson_reg_gee.Rd ├── details_poisson_reg_glm.Rd ├── details_poisson_reg_glmer.Rd ├── details_poisson_reg_glmnet.Rd ├── details_poisson_reg_h2o.Rd ├── details_poisson_reg_hurdle.Rd ├── details_poisson_reg_stan.Rd ├── details_poisson_reg_stan_glmer.Rd ├── details_poisson_reg_zeroinfl.Rd ├── details_proportional_hazards_glmnet.Rd ├── details_proportional_hazards_survival.Rd ├── details_rand_forest_aorsf.Rd ├── details_rand_forest_h2o.Rd ├── details_rand_forest_partykit.Rd ├── details_rand_forest_randomForest.Rd ├── details_rand_forest_ranger.Rd ├── details_rand_forest_spark.Rd ├── details_rule_fit_h2o.Rd ├── details_rule_fit_xrf.Rd ├── details_survival_reg_flexsurv.Rd ├── details_survival_reg_flexsurvspline.Rd ├── details_survival_reg_survival.Rd ├── details_svm_linear_LiblineaR.Rd ├── details_svm_linear_kernlab.Rd ├── details_svm_poly_kernlab.Rd ├── details_svm_rbf_kernlab.Rd ├── discrim_flexible.Rd ├── discrim_linear.Rd ├── discrim_quad.Rd ├── discrim_regularized.Rd ├── doc-tools.Rd ├── dot-extract_surv_status.Rd ├── dot-extract_surv_time.Rd ├── dot-get_prediction_column_names.Rd ├── dot-model_param_name_key.Rd ├── eval_args.Rd ├── extension-check-helpers.Rd ├── extract-parsnip.Rd ├── figures │ ├── adjust.png │ ├── comittees.png │ ├── comittees.tiff │ ├── lifecycle-archived.svg │ ├── lifecycle-defunct.svg │ ├── lifecycle-deprecated.svg │ ├── lifecycle-experimental.svg │ ├── lifecycle-maturing.svg │ ├── lifecycle-questioning.svg │ ├── lifecycle-soft-deprecated.svg │ ├── lifecycle-stable.svg │ ├── lifecycle-superseded.svg │ ├── logo.png │ ├── random_int_model.png │ ├── random_int_pop.png │ └── rules-from-trees.svg ├── fit.Rd ├── fit_control.Rd ├── format-internals.Rd ├── gen_additive_mod.Rd ├── get_model_env.Rd ├── glance.model_fit.Rd ├── glm_grouped.Rd ├── glmnet-details.Rd ├── glmnet_helpers.Rd ├── glmnet_helpers_prediction.Rd ├── has_multi_predict.Rd ├── keras_activations.Rd ├── keras_mlp.Rd ├── keras_predict_classes.Rd ├── knit_engine_docs.Rd ├── linear_reg.Rd ├── list_md_problems.Rd ├── logistic_reg.Rd ├── make_call.Rd ├── make_classes.Rd ├── mars.Rd ├── matrix_to_quantile_pred.Rd ├── max_mtry_formula.Rd ├── maybe_matrix.Rd ├── min_cols.Rd ├── mlp.Rd ├── model_db.Rd ├── model_fit.Rd ├── model_formula.Rd ├── model_printer.Rd ├── model_spec.Rd ├── multi_predict.Rd ├── multinom_reg.Rd ├── naive_Bayes.Rd ├── nearest_neighbor.Rd ├── null_model.Rd ├── nullmodel.Rd ├── other_predict.Rd ├── parsnip-package.Rd ├── parsnip_addin.Rd ├── parsnip_update.Rd ├── pls.Rd ├── poisson_reg.Rd ├── predict.model_fit.Rd ├── prepare_data.Rd ├── proportional_hazards.Rd ├── rand_forest.Rd ├── reexports.Rd ├── repair_call.Rd ├── req_pkgs.Rd ├── required_pkgs.model_spec.Rd ├── rmd │ ├── C5_rules_C5.0.Rmd │ ├── C5_rules_C5.0.md │ ├── aaa.Rmd │ ├── auto_ml_h2o.Rmd │ ├── auto_ml_h2o.md │ ├── bag_mars_earth.Rmd │ ├── bag_mars_earth.md │ ├── bag_mlp_nnet.Rmd │ ├── bag_mlp_nnet.md │ ├── bag_tree_C5.0.Rmd │ ├── bag_tree_C5.0.md │ ├── bag_tree_rpart.Rmd │ ├── bag_tree_rpart.md │ ├── bart_dbarts.Rmd │ ├── bart_dbarts.md │ ├── boost_tree_C5.0.Rmd │ ├── boost_tree_C5.0.md │ ├── boost_tree_h2o.Rmd │ ├── boost_tree_h2o.md │ ├── boost_tree_lightgbm.Rmd │ ├── boost_tree_lightgbm.md │ ├── boost_tree_mboost.Rmd │ ├── boost_tree_mboost.md │ ├── boost_tree_spark.Rmd │ ├── boost_tree_spark.md │ ├── boost_tree_xgboost.Rmd │ ├── boost_tree_xgboost.md │ ├── cubist_rules_Cubist.Rmd │ ├── cubist_rules_Cubist.md │ ├── decision_tree_C5.0.Rmd │ ├── decision_tree_C5.0.md │ ├── decision_tree_partykit.Rmd │ ├── decision_tree_partykit.md │ ├── decision_tree_rpart.Rmd │ ├── decision_tree_rpart.md │ ├── decision_tree_spark.Rmd │ ├── decision_tree_spark.md │ ├── discrim_flexible_earth.Rmd │ ├── discrim_flexible_earth.md │ ├── discrim_linear_MASS.Rmd │ ├── discrim_linear_MASS.md │ ├── discrim_linear_mda.Rmd │ ├── discrim_linear_mda.md │ ├── discrim_linear_sda.Rmd │ ├── discrim_linear_sda.md │ ├── discrim_linear_sparsediscrim.Rmd │ ├── discrim_linear_sparsediscrim.md │ ├── discrim_quad_MASS.Rmd │ ├── discrim_quad_MASS.md │ ├── discrim_quad_sparsediscrim.Rmd │ ├── discrim_quad_sparsediscrim.md │ ├── discrim_regularized_klaR.Rmd │ ├── discrim_regularized_klaR.md │ ├── gen_additive_mod_mgcv.Rmd │ ├── gen_additive_mod_mgcv.md │ ├── glmnet-details.Rmd │ ├── glmnet-details.md │ ├── linear_reg_brulee.Rmd │ ├── linear_reg_brulee.md │ ├── linear_reg_gee.Rmd │ ├── linear_reg_gee.md │ ├── linear_reg_glm.Rmd │ ├── linear_reg_glm.md │ ├── linear_reg_glmer.Rmd │ ├── linear_reg_glmer.md │ ├── linear_reg_glmnet.Rmd │ ├── linear_reg_glmnet.md │ ├── linear_reg_gls.Rmd │ ├── linear_reg_gls.md │ ├── linear_reg_h2o.Rmd │ ├── linear_reg_h2o.md │ ├── linear_reg_keras.Rmd │ ├── linear_reg_keras.md │ ├── linear_reg_lm.Rmd │ ├── linear_reg_lm.md │ ├── linear_reg_lme.Rmd │ ├── linear_reg_lme.md │ ├── linear_reg_lmer.Rmd │ ├── linear_reg_lmer.md │ ├── linear_reg_quantreg.Rmd │ ├── linear_reg_quantreg.md │ ├── linear_reg_spark.Rmd │ ├── linear_reg_spark.md │ ├── linear_reg_stan.Rmd │ ├── linear_reg_stan.md │ ├── linear_reg_stan_glmer.Rmd │ ├── linear_reg_stan_glmer.md │ ├── logistic_reg_LiblineaR.Rmd │ ├── logistic_reg_LiblineaR.md │ ├── logistic_reg_brulee.Rmd │ ├── logistic_reg_brulee.md │ ├── logistic_reg_gee.Rmd │ ├── logistic_reg_gee.md │ ├── logistic_reg_glm.Rmd │ ├── logistic_reg_glm.md │ ├── logistic_reg_glmer.Rmd │ ├── logistic_reg_glmer.md │ ├── logistic_reg_glmnet.Rmd │ ├── logistic_reg_glmnet.md │ ├── logistic_reg_h2o.Rmd │ ├── logistic_reg_h2o.md │ ├── logistic_reg_keras.Rmd │ ├── logistic_reg_keras.md │ ├── logistic_reg_spark.Rmd │ ├── logistic_reg_spark.md │ ├── logistic_reg_stan.Rmd │ ├── logistic_reg_stan.md │ ├── logistic_reg_stan_glmer.Rmd │ ├── logistic_reg_stan_glmer.md │ ├── mars_earth.Rmd │ ├── mars_earth.md │ ├── mlp_brulee.Rmd │ ├── mlp_brulee.md │ ├── mlp_brulee_two_layer.Rmd │ ├── mlp_brulee_two_layer.md │ ├── mlp_h2o.Rmd │ ├── mlp_h2o.md │ ├── mlp_keras.Rmd │ ├── mlp_keras.md │ ├── mlp_nnet.Rmd │ ├── mlp_nnet.md │ ├── multinom_reg_brulee.Rmd │ ├── multinom_reg_brulee.md │ ├── multinom_reg_glmnet.Rmd │ ├── multinom_reg_glmnet.md │ ├── multinom_reg_h2o.Rmd │ ├── multinom_reg_h2o.md │ ├── multinom_reg_keras.Rmd │ ├── multinom_reg_keras.md │ ├── multinom_reg_nnet.Rmd │ ├── multinom_reg_nnet.md │ ├── multinom_reg_spark.Rmd │ ├── multinom_reg_spark.md │ ├── naive_Bayes_h2o.Rmd │ ├── naive_Bayes_h2o.md │ ├── naive_Bayes_klaR.Rmd │ ├── naive_Bayes_klaR.md │ ├── naive_Bayes_naivebayes.Rmd │ ├── naive_Bayes_naivebayes.md │ ├── nearest-neighbor.md │ ├── nearest_neighbor_kknn.Rmd │ ├── nearest_neighbor_kknn.md │ ├── no-pooling.md │ ├── null-model.Rmd │ ├── null-model.md │ ├── pls_mixOmics.Rmd │ ├── pls_mixOmics.md │ ├── poisson_reg_gee.Rmd │ ├── poisson_reg_gee.md │ ├── poisson_reg_glm.Rmd │ ├── poisson_reg_glm.md │ ├── poisson_reg_glmer.Rmd │ ├── poisson_reg_glmer.md │ ├── poisson_reg_glmnet.Rmd │ ├── poisson_reg_glmnet.md │ ├── poisson_reg_h2o.Rmd │ ├── poisson_reg_h2o.md │ ├── poisson_reg_hurdle.Rmd │ ├── poisson_reg_hurdle.md │ ├── poisson_reg_stan.Rmd │ ├── poisson_reg_stan.md │ ├── poisson_reg_stan_glmer.Rmd │ ├── poisson_reg_stan_glmer.md │ ├── poisson_reg_zeroinfl.Rmd │ ├── poisson_reg_zeroinfl.md │ ├── proportional_hazards_glmnet.Rmd │ ├── proportional_hazards_glmnet.md │ ├── proportional_hazards_survival.Rmd │ ├── proportional_hazards_survival.md │ ├── rand_forest_aorsf.Rmd │ ├── rand_forest_aorsf.md │ ├── rand_forest_h2o.Rmd │ ├── rand_forest_h2o.md │ ├── rand_forest_partykit.Rmd │ ├── rand_forest_partykit.md │ ├── rand_forest_randomForest.Rmd │ ├── rand_forest_randomForest.md │ ├── rand_forest_ranger.Rmd │ ├── rand_forest_ranger.md │ ├── rand_forest_spark.Rmd │ ├── rand_forest_spark.md │ ├── rule_fit_h2o.Rmd │ ├── rule_fit_h2o.md │ ├── rule_fit_xrf.Rmd │ ├── rule_fit_xrf.md │ ├── survival_reg_flexsurv.Rmd │ ├── survival_reg_flexsurv.md │ ├── survival_reg_flexsurvspline.Rmd │ ├── survival_reg_flexsurvspline.md │ ├── survival_reg_survival.Rmd │ ├── survival_reg_survival.md │ ├── svm_linear_LiblineaR.Rmd │ ├── svm_linear_LiblineaR.md │ ├── svm_linear_kernlab.Rmd │ ├── svm_linear_kernlab.md │ ├── svm_poly_kernlab.Rmd │ ├── svm_poly_kernlab.md │ ├── svm_rbf_kernlab.Rmd │ ├── svm_rbf_kernlab.md │ ├── template-bundle.Rmd │ ├── template-butcher.Rmd │ ├── template-censored-linear-predictor.Rmd │ ├── template-early-stopping.Rmd │ ├── template-gee-silent.Rmd │ ├── template-h2o-glm-penalty.Rmd │ ├── template-h2o-init.Rmd │ ├── template-makes-dummies.Rmd │ ├── template-mtry-prop.Rmd │ ├── template-no-case-weights.Rmd │ ├── template-no-pooling.Rmd │ ├── template-same-scale.Rmd │ ├── template-spark-notes.Rmd │ ├── template-survival-mean.Rmd │ ├── template-survival-median.Rmd │ ├── template-tree-split-factors.Rmd │ ├── template-uses-case-weights.Rmd │ ├── template-uses-sparse-data.Rmd │ ├── template-zv-conditional.Rmd │ └── template-zv.Rmd ├── rule_fit.Rd ├── set_args.Rd ├── set_engine.Rd ├── set_new_model.Rd ├── set_tf_seed.Rd ├── show_call.Rd ├── show_engines.Rd ├── sparse_data.Rd ├── stan_conf_int.Rd ├── surv_reg.Rd ├── survival_reg.Rd ├── svm_linear.Rd ├── svm_poly.Rd ├── svm_rbf.Rd ├── tidy._LiblineaR.Rd ├── tidy._elnet.Rd ├── tidy.model_fit.Rd ├── tidy.nullmodel.Rd ├── translate.Rd ├── type_sum.model_spec.Rd ├── update_model_info_file.Rd ├── varying.Rd ├── varying_args.Rd └── xgb_train.Rd ├── parsnip.Rproj ├── tests ├── testthat.R └── testthat │ ├── README.md │ ├── _snaps │ ├── args_and_modes.md │ ├── arguments.md │ ├── augment.md │ ├── boost_tree.md │ ├── case-weights.md │ ├── condense_control.md │ ├── engines.md │ ├── model_basics.md │ ├── nearest_neighbor.md │ ├── packages.md │ ├── partykit.md │ ├── print.md │ ├── rand_forest.md │ ├── re_registration.md │ ├── registration.md │ ├── standalone-survival.md │ ├── surv_reg.md │ ├── surv_reg_flexsurv.md │ ├── surv_reg_survreg.md │ ├── translate.md │ └── update.md │ ├── helper-extract_parameter_set.R │ ├── helper-objects.R │ ├── mars_model.RData │ ├── nnet_test.txt │ ├── test-aaaa.R │ ├── test-adds.R │ ├── test-args_and_modes.R │ ├── test-arguments.R │ ├── test-augment.R │ ├── test-bag_mars.R │ ├── test-bag_mlp.R │ ├── test-bag_tree.R │ ├── test-bart.R │ ├── test-boost_tree.R │ ├── test-boost_tree_C5.0.R │ ├── test-boost_tree_xgboost.R │ ├── test-c5_rules.R │ ├── test-case-weights.R │ ├── test-condense_control.R │ ├── test-convert_data.R │ ├── test-cubist_rules.R │ ├── test-decision_tree.R │ ├── test-default_engines.R │ ├── test-descriptors.R │ ├── test-discrim_flexible.R │ ├── test-discrim_linear.R │ ├── test-discrim_quad.R │ ├── test-discrim_regularized.R │ ├── test-engines.R │ ├── test-extract.R │ ├── test-failed_models.R │ ├── test-fit_interfaces.R │ ├── test-gen_additive_model.R │ ├── test-glm_grouped.R │ ├── test-linear_reg.R │ ├── test-linear_reg_keras.R │ ├── test-linear_reg_quantreg.R │ ├── test-logistic_reg.R │ ├── test-logistic_reg_keras.R │ ├── test-mars.R │ ├── test-misc.R │ ├── test-mlp.R │ ├── test-mlp_keras.R │ ├── test-mlp_nnet.R │ ├── test-model_basics.R │ ├── test-multinom_reg.R │ ├── test-multinom_reg_keras.R │ ├── test-multinom_reg_nnet.R │ ├── test-naive_Bayes.R │ ├── test-nearest_neighbor.R │ ├── test-nearest_neighbor_kknn.R │ ├── test-nullmodel.R │ ├── test-packages.R │ ├── test-partykit.R │ ├── test-pls.R │ ├── test-poisson_reg.R │ ├── test-predict_formats.R │ ├── test-print.R │ ├── test-proportional_hazards.R │ ├── test-rand_forest.R │ ├── test-rand_forest_ranger.R │ ├── test-re_registration.R │ ├── test-registration.R │ ├── test-rule_fit.R │ ├── test-sparsevctrs.R │ ├── test-standalone-survival.R │ ├── test-surv_reg.R │ ├── test-surv_reg_flexsurv.R │ ├── test-surv_reg_survreg.R │ ├── test-survival-censoring-weights.R │ ├── test-survival_reg.R │ ├── test-svm_linear.R │ ├── test-svm_poly.R │ ├── test-svm_rbf.R │ ├── test-translate.R │ ├── test-tunable.R │ ├── test-update.R │ └── test-varying.R └── vignettes ├── articles ├── .gitignore ├── Examples.Rmd ├── Submodels.Rmd ├── checklists.Rmd ├── template-cls-multi-class.R ├── template-cls-two-class.R ├── template-reg-chicago.R └── template-reg-sacramento.R └── parsnip.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^tests/testthat/*\.log$ 2 | ^tests/testthat/logs$ 3 | ^_pkgdown\.yml$ 4 | ^docs$ 5 | ^pkgdown$ 6 | ^parsnip\.Rproj$ 7 | ^\.Rproj\.user$ 8 | ^.travis.yml$ 9 | ^R/README\.md$ 10 | derby.log 11 | ^logs$ 12 | ^tests/testthat/logs$ 13 | ^revdep$ 14 | ^issue_template.md$ 15 | ^README\.Rmd$ 16 | ^\.github$ 17 | ^CODE_OF_CONDUCT\.md$ 18 | ^README\.html$ 19 | ^codecov\.yml$ 20 | ^LICENSE\.md$ 21 | ^man-roxygen$ 22 | ^vignettes/articles$ 23 | ^[\.]?air\.toml$ 24 | ^\.vscode$ 25 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/workflows/lock.yaml: -------------------------------------------------------------------------------- 1 | name: 'Lock Threads' 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' 6 | 7 | jobs: 8 | lock: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: dessant/lock-threads@v2 12 | with: 13 | github-token: ${{ github.token }} 14 | issue-lock-inactive-days: '14' 15 | # issue-exclude-labels: '' 16 | # issue-lock-labels: 'outdated' 17 | issue-lock-comment: > 18 | This issue has been automatically locked. If you believe you have 19 | found a related problem, please file a new issue (with a reprex: 20 | ) and link to this issue. 21 | issue-lock-reason: '' 22 | pr-lock-inactive-days: '14' 23 | # pr-exclude-labels: 'wip' 24 | pr-lock-labels: '' 25 | pr-lock-comment: > 26 | This pull request has been automatically locked. If you believe you 27 | have found a related problem, please file a new issue (with a reprex: 28 | ) and link to this issue. 29 | pr-lock-reason: '' 30 | # process-only: 'issues' 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rhistory 2 | .RData 3 | .Rproj.user 4 | .DS_Store 5 | tests/testthat/derby.log 6 | tests/testthat/logs/ 7 | *.history 8 | derby.log 9 | logs/* 10 | revdep/* 11 | docs* 12 | docs 13 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "Posit.air-vscode" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "[r]": { 3 | "editor.formatOnSave": true, 4 | "editor.defaultFormatter": "Posit.air-vscode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2025 2 | COPYRIGHT HOLDER: parsnip authors 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2025 parsnip authors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /R/C5_rules_C5.0.R: -------------------------------------------------------------------------------- 1 | #' C5.0 rule-based classification models 2 | #' 3 | #' [C50::C5.0()] fits a model that derives feature rules from a tree for 4 | #' prediction. A single tree or boosted ensemble can be used. [rules::c5_fit()] 5 | #' is a wrapper around this function. 6 | #' 7 | #' @includeRmd man/rmd/C5_rules_C5.0.md details 8 | #' 9 | #' @name details_C5_rules_C5.0 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/aaa_quantiles.R: -------------------------------------------------------------------------------- 1 | #' Reformat quantile predictions 2 | #' 3 | #' @param x A matrix of predictions with rows as samples and columns as quantile 4 | #' levels. 5 | #' @param object A parsnip `model_fit` object from a quantile regression model. 6 | #' @keywords internal 7 | #' @export 8 | matrix_to_quantile_pred <- function(x, object) { 9 | if (!is.matrix(x)) { 10 | x <- as.matrix(x) 11 | } 12 | rownames(x) <- NULL 13 | n_pred_quantiles <- ncol(x) 14 | quantile_levels <- object$spec$quantile_levels 15 | 16 | tibble::new_tibble(x = list(.pred_quantile = hardhat::quantile_pred(x, quantile_levels))) 17 | } 18 | -------------------------------------------------------------------------------- /R/aaa_spark_helpers.R: -------------------------------------------------------------------------------- 1 | # some spark helper functions 2 | 3 | format_spark_probs <- function(results, object) { 4 | results <- dplyr::select(results, starts_with("probability_")) 5 | p <- ncol(results) 6 | lvl <- colnames(results) 7 | names(lvl) <- paste0("pred_", object$fit$index_labels) 8 | results |> dplyr::rename(!!!syms(lvl)) 9 | } 10 | 11 | format_spark_class <- function(results, object) { 12 | results <- dplyr::select(results, predicted_label) 13 | results <- dplyr::rename(results, pred_class = predicted_label) 14 | results 15 | } 16 | 17 | format_spark_num <- function(results, object) { 18 | results <- dplyr::select(results, prediction) 19 | results <- dplyr::rename(results, pred = prediction) 20 | results 21 | } 22 | -------------------------------------------------------------------------------- /R/add_in.R: -------------------------------------------------------------------------------- 1 | #' Start an RStudio Addin that can write model specifications 2 | #' 3 | #' `parsnip_addin()` starts a process in the RStudio IDE Viewer window 4 | #' that allows users to write code for parsnip model specifications from 5 | #' various R packages. The new code is written to the current document at the 6 | #' location of the cursor. 7 | #' 8 | #' @export 9 | parsnip_addin <- function() { 10 | sys.source( 11 | system.file("add-in", "gadget.R", package = "parsnip", mustWork = TRUE), 12 | envir = rlang::new_environment(parent = rlang::global_env()), 13 | keep.source = FALSE 14 | ) 15 | } 16 | -------------------------------------------------------------------------------- /R/adds.R: -------------------------------------------------------------------------------- 1 | #' Add a column of row numbers to a data frame 2 | #' 3 | #' @param x A data frame 4 | #' @return The same data frame with a column of 1-based integers named `.row`. 5 | #' @examplesIf !parsnip:::is_cran_check() 6 | #' mtcars |> add_rowindex() 7 | #' @export 8 | add_rowindex <- function(x) { 9 | if (!is.data.frame(x)) { 10 | cli::cli_abort("{.arg x} should be a data frame.") 11 | } 12 | x <- dplyr::mutate(x, .row = seq_len(nrow(x))) 13 | x 14 | } 15 | 16 | -------------------------------------------------------------------------------- /R/auto_ml.R: -------------------------------------------------------------------------------- 1 | #' Automatic Machine Learning 2 | #' 3 | #' @description 4 | #' 5 | #' `auto_ml()` defines an automated searching and tuning process where 6 | #' many models of different families are trained and ranked given their 7 | #' performance on the training data. 8 | #' 9 | #' \Sexpr[stage=render,results=rd]{parsnip:::make_engine_list("auto_ml")} 10 | #' 11 | #' More information on how \pkg{parsnip} is used for modeling is at 12 | #' \url{https://www.tidymodels.org/}. 13 | #' 14 | #' @param mode A single character string for the prediction outcome mode. 15 | #' Possible values for this model are "unknown", "regression", or 16 | #' "classification". 17 | #' @param engine A single character string specifying what computational engine 18 | #' to use for fitting. 19 | #' 20 | #' @templateVar modeltype auto_ml 21 | #' @template spec-details 22 | #' 23 | #' @template spec-references 24 | #' 25 | #' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("auto_ml")} 26 | #' @export 27 | auto_ml <- function(mode = "unknown", engine = "h2o") { 28 | args <- list() 29 | out <- list(args = args, eng_args = NULL, 30 | mode = mode, method = NULL, engine = engine) 31 | class(out) <- make_classes("auto_ml") 32 | out 33 | } 34 | 35 | # ------------------------------------------------------------------------------ 36 | set_new_model("auto_ml") 37 | set_model_mode("auto_ml", "regression") 38 | set_model_mode("auto_ml", "classification") 39 | -------------------------------------------------------------------------------- /R/auto_ml_h2o.R: -------------------------------------------------------------------------------- 1 | #' Automatic machine learning via h2o 2 | #' 3 | #' [h2o::h2o.automl] defines an automated model training process and returns a 4 | #' leaderboard of models with best performances. 5 | #' 6 | #' @includeRmd man/rmd/auto_ml_h2o.md details 7 | #' 8 | #' @name details_auto_ml_h2o 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/bag_mars_earth.R: -------------------------------------------------------------------------------- 1 | #' Bagged MARS via earth 2 | #' 3 | #' [baguette::bagger()] creates an collection of MARS models forming an 4 | #' ensemble. All models in the ensemble are combined to produce a final prediction. 5 | #' 6 | #' @includeRmd man/rmd/bag_mars_earth.md details 7 | #' 8 | #' @name details_bag_mars_earth 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/bag_mlp_nnet.R: -------------------------------------------------------------------------------- 1 | #' Bagged neural networks via nnet 2 | #' 3 | #' [baguette::bagger()] creates a collection of neural networks forming an 4 | #' ensemble. All trees in the ensemble are combined to produce a final prediction. 5 | #' 6 | #' @includeRmd man/rmd/bag_mlp_nnet.md details 7 | #' 8 | #' @name details_bag_mlp_nnet 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/bag_tree_C5.0.R: -------------------------------------------------------------------------------- 1 | #' Bagged trees via C5.0 2 | #' 3 | #' [baguette::bagger()] creates an collection of decision trees forming an 4 | #' ensemble. All trees in the ensemble are combined to produce a final prediction. 5 | #' 6 | #' @includeRmd man/rmd/bag_tree_C5.0.md details 7 | #' 8 | #' @name details_bag_tree_C5.0 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/bag_tree_rpart.R: -------------------------------------------------------------------------------- 1 | #' Bagged trees via rpart 2 | #' 3 | #' [baguette::bagger()] and [ipred::bagging()] create collections of decision 4 | #' trees forming an ensemble. All trees in the ensemble are combined to produce 5 | #' a final prediction. 6 | #' 7 | #' @includeRmd man/rmd/bag_tree_rpart.md details 8 | #' 9 | #' @name details_bag_tree_rpart 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/bart_dbarts.R: -------------------------------------------------------------------------------- 1 | #' Bayesian additive regression trees via dbarts 2 | #' 3 | #' [dbarts::bart()] creates an ensemble of tree-based model whose training 4 | #' and assembly is determined using Bayesian analysis. 5 | #' 6 | #' @includeRmd man/rmd/bart_dbarts.md details 7 | #' 8 | #' @name details_bart_dbarts 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/boost_tree_C5.0.R: -------------------------------------------------------------------------------- 1 | #' Boosted trees via C5.0 2 | #' 3 | #' [C50::C5.0()] creates a series of classification trees forming an 4 | #' ensemble. Each tree depends on the results of previous trees. All trees in 5 | #' the ensemble are combined to produce a final prediction. 6 | #' 7 | #' @includeRmd man/rmd/boost_tree_C5.0.md details 8 | #' 9 | #' @name details_boost_tree_C5.0 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/boost_tree_h2o.R: -------------------------------------------------------------------------------- 1 | #' Boosted trees via h2o 2 | #' 3 | #' [h2o::h2o.xgboost()] creates a series of decision trees 4 | #' forming an ensemble. Each tree depends on the results of previous trees. 5 | #' All trees in the ensemble are combined to produce a final prediction. 6 | #' 7 | #' @includeRmd man/rmd/boost_tree_h2o.md details 8 | #' 9 | #' @name details_boost_tree_h2o 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/boost_tree_lightgbm.R: -------------------------------------------------------------------------------- 1 | #' Boosted trees via lightgbm 2 | #' 3 | #' [lightgbm::lgb.train()] creates a series of decision trees 4 | #' forming an ensemble. Each tree depends on the results of previous trees. 5 | #' All trees in the ensemble are combined to produce a final prediction. 6 | #' 7 | #' @includeRmd man/rmd/boost_tree_lightgbm.md details 8 | #' 9 | #' @name details_boost_tree_lightgbm 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/boost_tree_mboost.R: -------------------------------------------------------------------------------- 1 | #' Boosted trees 2 | #' 3 | #' [mboost::blackboost()] fits a series of decision trees forming an ensemble. 4 | #' Each tree depends on the results of previous trees. All trees in the 5 | #' ensemble are combined to produce a final prediction. 6 | #' 7 | #' @includeRmd man/rmd/boost_tree_mboost.md details 8 | #' 9 | #' @name details_boost_tree_mboost 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/boost_tree_spark.R: -------------------------------------------------------------------------------- 1 | #' Boosted trees via Spark 2 | #' 3 | #' [sparklyr::ml_gradient_boosted_trees()] creates a series of decision trees 4 | #' forming an ensemble. Each tree depends on the results of previous trees. 5 | #' All trees in the ensemble are combined to produce a final prediction. 6 | #' 7 | #' @includeRmd man/rmd/boost_tree_spark.md details 8 | #' 9 | #' @name details_boost_tree_spark 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/boost_tree_xgboost.R: -------------------------------------------------------------------------------- 1 | #' Boosted trees via xgboost 2 | #' 3 | #' [xgboost::xgb.train()] creates a series of decision trees forming an 4 | #' ensemble. Each tree depends on the results of previous trees. All trees in 5 | #' the ensemble are combined to produce a final prediction. 6 | #' 7 | #' @includeRmd man/rmd/boost_tree_xgboost.md details 8 | #' 9 | #' @name details_boost_tree_xgboost 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/condense_control.R: -------------------------------------------------------------------------------- 1 | #' Condense control object into strictly smaller control object 2 | #' 3 | #' This function is used to help the hierarchy of control functions used 4 | #' throughout the tidymodels packages. It is now assumed that each control 5 | #' function is either a subset or a superset of another control function. 6 | #' 7 | #' @param x A control object to be condensed. 8 | #' @param ref A control object that is used to determine what element should be 9 | #' kept. 10 | #' 11 | #' @return A control object with the same elements and classes of `ref`, with 12 | #' values of `x`. 13 | #' @param call The execution environment of a currently running function, e.g. 14 | #' `caller_env()`. The function will be mentioned in error messages as the 15 | #' source of the error. See the call argument of [rlang::abort()] for more 16 | #' information. 17 | #' @keywords internal 18 | #' @export 19 | #' 20 | #' @examplesIf !parsnip:::is_cran_check() 21 | #' ctrl <- control_parsnip(catch = TRUE) 22 | #' ctrl$allow_par <- TRUE 23 | #' str(ctrl) 24 | #' 25 | #' ctrl <- condense_control(ctrl, control_parsnip()) 26 | #' str(ctrl) 27 | condense_control <- function(x, ref, ..., call = rlang::caller_env()) { 28 | check_dots_empty() 29 | mismatch <- setdiff(names(ref), names(x)) 30 | if (length(mismatch)) { 31 | cli::cli_abort( 32 | c( 33 | "{.obj_type_friendly {x}} cannot be coerced to {.obj_type_friendly {ref}}.", 34 | "i" = "{cli::qty(mismatch)} The argument{?s} {.arg {mismatch}} 35 | {?is/are} missing." 36 | ), 37 | call = call 38 | ) 39 | } 40 | res <- x[names(ref)] 41 | class(res) <- class(ref) 42 | res 43 | } 44 | -------------------------------------------------------------------------------- /R/cubist_rules_Cubist.R: -------------------------------------------------------------------------------- 1 | #' Cubist rule-based regression models 2 | #' 3 | #' [Cubist::cubist()] fits a model that derives simple feature rules from a tree 4 | #' ensemble and uses creates regression models within each rule. 5 | #' [rules::cubist_fit()] is a wrapper around this function. 6 | #' 7 | #' @includeRmd man/rmd/cubist_rules_Cubist.md details 8 | #' 9 | #' @name details_cubist_rules_Cubist 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/data.R: -------------------------------------------------------------------------------- 1 | #' parsnip model specification database 2 | #' 3 | #' This is used in the RStudio add-in and captures information about mode 4 | #' specifications in various R packages. 5 | #' 6 | #' @name model_db 7 | #' @aliases model_db 8 | #' @docType data 9 | #' @return \item{model_db}{a data frame} 10 | #' @keywords datasets internal 11 | #' @examplesIf !parsnip:::is_cran_check() 12 | #' data(model_db) 13 | NULL 14 | 15 | -------------------------------------------------------------------------------- /R/decision_tree_C5.0.R: -------------------------------------------------------------------------------- 1 | #' Decision trees via C5.0 2 | #' 3 | #' [C50::C5.0()] fits a model as a set of `if/then` statements that 4 | #' creates a tree-based structure. 5 | #' 6 | #' @includeRmd man/rmd/decision_tree_C5.0.md details 7 | #' 8 | #' @name details_decision_tree_C5.0 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/decision_tree_partykit.R: -------------------------------------------------------------------------------- 1 | #' Decision trees via partykit 2 | #' 3 | #' [partykit::ctree()] fits a model as a set of if/then statements that creates a 4 | #' tree-based structure using hypothesis testing methods. 5 | #' 6 | #' @includeRmd man/rmd/decision_tree_partykit.md details 7 | #' 8 | #' @name details_decision_tree_partykit 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/decision_tree_rpart.R: -------------------------------------------------------------------------------- 1 | #' Decision trees via CART 2 | #' 3 | #' [rpart::rpart()] fits a model as a set of `if/then` statements that 4 | #' creates a tree-based structure. 5 | #' 6 | #' @includeRmd man/rmd/decision_tree_rpart.md details 7 | #' 8 | #' @name details_decision_tree_rpart 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/decision_tree_spark.R: -------------------------------------------------------------------------------- 1 | #' Decision trees via Spark 2 | #' 3 | #' [sparklyr::ml_decision_tree()] fits a model as a set of `if/then` 4 | #' statements that creates a tree-based structure. 5 | #' 6 | #' @includeRmd man/rmd/decision_tree_spark.md details 7 | #' 8 | #' @name details_decision_tree_spark 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/discrim_flexible_earth.R: -------------------------------------------------------------------------------- 1 | #' Flexible discriminant analysis via earth 2 | #' 3 | #' [mda::fda()] (in conjunction with [earth::earth()] can fit a nonlinear 4 | #' discriminant analysis model that uses nonlinear features created using 5 | #' multivariate adaptive regression splines (MARS). This function can fit 6 | #' classification models. 7 | #' 8 | #' @includeRmd man/rmd/discrim_flexible_earth.md details 9 | #' 10 | #' @name details_discrim_flexible_earth 11 | #' @keywords internal 12 | NULL 13 | 14 | # See inst/README-DOCS.md for a description of how these files are processed 15 | -------------------------------------------------------------------------------- /R/discrim_linear_MASS.R: -------------------------------------------------------------------------------- 1 | #' Linear discriminant analysis via MASS 2 | #' 3 | #' [MASS::lda()] fits a model that estimates a multivariate 4 | #' distribution for the predictors separately for the data in each class 5 | #' (Gaussian with a common covariance matrix). Bayes' theorem is used 6 | #' to compute the probability of each class, given the predictor values. 7 | #' 8 | #' @includeRmd man/rmd/discrim_linear_MASS.md details 9 | #' 10 | #' @name details_discrim_linear_MASS 11 | #' @keywords internal 12 | NULL 13 | 14 | # See inst/README-DOCS.md for a description of how these files are processed 15 | -------------------------------------------------------------------------------- /R/discrim_linear_mda.R: -------------------------------------------------------------------------------- 1 | #' Linear discriminant analysis via flexible discriminant analysis 2 | #' 3 | #' [mda::fda()] (in conjunction with [mda::gen.ridge()] can fit a linear 4 | #' discriminant analysis model that penalizes the predictor coefficients with a 5 | #' quadratic penalty (i.e., a ridge or weight decay approach). 6 | #' 7 | #' @includeRmd man/rmd/discrim_linear_mda.md details 8 | #' 9 | #' @name details_discrim_linear_mda 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/discrim_linear_sda.R: -------------------------------------------------------------------------------- 1 | #' Linear discriminant analysis via James-Stein-type shrinkage estimation 2 | #' 3 | #' [sda::sda()] can fit a linear discriminant analysis model that can fit models 4 | #' between classical discriminant analysis and diagonal discriminant analysis. 5 | #' 6 | #' @includeRmd man/rmd/discrim_linear_sda.md details 7 | #' 8 | #' @name details_discrim_linear_sda 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/discrim_linear_sparsediscrim.R: -------------------------------------------------------------------------------- 1 | #' Linear discriminant analysis via regularization 2 | #' 3 | #' Functions in the \pkg{sparsediscrim} package fit different types of linear 4 | #' discriminant analysis model that regularize the estimates (like the mean or 5 | #' covariance). 6 | #' 7 | #' @includeRmd man/rmd/discrim_linear_sparsediscrim.md details 8 | #' 9 | #' @name details_discrim_linear_sparsediscrim 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/discrim_quad_MASS.R: -------------------------------------------------------------------------------- 1 | #' Quadratic discriminant analysis via MASS 2 | #' 3 | #' [MASS::qda()] fits a model that estimates a multivariate 4 | #' distribution for the predictors separately for the data in each class 5 | #' (Gaussian with separate covariance matrices). Bayes' theorem is used 6 | #' to compute the probability of each class, given the predictor values. 7 | #' 8 | #' @includeRmd man/rmd/discrim_quad_MASS.md details 9 | #' 10 | #' @name details_discrim_quad_MASS 11 | #' @keywords internal 12 | NULL 13 | 14 | # See inst/README-DOCS.md for a description of how these files are processed 15 | -------------------------------------------------------------------------------- /R/discrim_quad_sparsediscrim.R: -------------------------------------------------------------------------------- 1 | #' Quadratic discriminant analysis via regularization 2 | #' 3 | #' Functions in the \pkg{sparsediscrim} package fit different types of quadratic 4 | #' discriminant analysis model that regularize the estimates (like the mean or 5 | #' covariance). 6 | #' 7 | #' @includeRmd man/rmd/discrim_quad_sparsediscrim.md details 8 | #' 9 | #' @name details_discrim_quad_sparsediscrim 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/discrim_regularized_klaR.R: -------------------------------------------------------------------------------- 1 | #' Regularized discriminant analysis via klaR 2 | #' 3 | #' [klaR::rda()] fits a a model that estimates a multivariate 4 | #' distribution for the predictors separately for the data in each class. The 5 | #' structure of the model can be LDA, QDA, or some amalgam of the two. Bayes' 6 | #' theorem is used to compute the probability of each class, given the 7 | #' predictor values. 8 | #' 9 | #' @includeRmd man/rmd/discrim_regularized_klaR.md details 10 | #' 11 | #' @name details_discrim_regularized_klaR 12 | #' @keywords internal 13 | NULL 14 | 15 | # See inst/README-DOCS.md for a description of how these files are processed 16 | -------------------------------------------------------------------------------- /R/fit_control.R: -------------------------------------------------------------------------------- 1 | #' Control the fit function 2 | #' 3 | #' @description 4 | #' `r lifecycle::badge("deprecated")` 5 | #' 6 | #' Pass options to the [fit.model_spec()] function to control its 7 | #' output and computations 8 | #' 9 | #' @param verbosity An integer to control how verbose the output is. For a 10 | #' value of zero, no messages or output are shown when packages are loaded or 11 | #' when the model is fit. For a value of 1, package loading is quiet but model 12 | #' fits can produce output to the screen (depending on if they contain their 13 | #' own `verbose`-type argument). For a value of 2 or more, any output at all 14 | #' is displayed and the execution time of the fit is recorded and printed. 15 | #' @param catch A logical where a value of `TRUE` will evaluate the model 16 | #' inside of `try(, silent = TRUE)`. If the model fails, an object is still 17 | #' returned (without an error) that inherits the class "try-error". 18 | #' @return An S3 object with class "control_parsnip" that is a named list 19 | #' with the results of the function call 20 | #' 21 | #' @examplesIf !parsnip:::is_cran_check() 22 | #' fit_control(verbosity = 2L) 23 | #' 24 | #' @details 25 | #' `fit_control()` is deprecated in favor of `control_parsnip()`. 26 | #' 27 | #' @export 28 | #' @keywords internal 29 | fit_control <- function(verbosity = 1L, catch = FALSE) { 30 | lifecycle::deprecate_warn("0.1.8", "fit_control()", "control_parsnip()") 31 | control_parsnip(verbosity = verbosity, catch = catch) 32 | } 33 | -------------------------------------------------------------------------------- /R/gen_additive_mod_mgcv.R: -------------------------------------------------------------------------------- 1 | #' Generalized additive models via mgcv 2 | #' 3 | #' [mgcv::gam()] fits a generalized linear model with additive smoother terms 4 | #' for continuous predictors. 5 | #' 6 | #' @includeRmd man/rmd/gen_additive_mod_mgcv.md details 7 | #' 8 | #' @name details_gen_additive_mod_mgcv 9 | #' @keywords internal 10 | NULL 11 | -------------------------------------------------------------------------------- /R/glmnet_details.R: -------------------------------------------------------------------------------- 1 | #' Technical aspects of the glmnet model 2 | #' 3 | #' glmnet is a popular statistical model for regularized generalized linear 4 | #' models. These notes reflect common questions about this particular model. 5 | #' 6 | #' @includeRmd man/rmd/glmnet-details.md details 7 | #' 8 | #' @name glmnet-details 9 | #' @keywords internal 10 | NULL 11 | -------------------------------------------------------------------------------- /R/install_packages.R: -------------------------------------------------------------------------------- 1 | # Installs packages needed to run `knit_engine_docs()`. 2 | install_engine_packages <- function(extension = TRUE, extras = TRUE, 3 | ignore_pkgs = c("stats", "liquidSVM", 4 | "parsnip")) { 5 | bio_pkgs <- c() 6 | 7 | if (extension) { 8 | extensions_packages <- extensions() 9 | rlang::check_installed(extensions_packages) 10 | bio_pkgs <- c(bio_pkgs, "mixOmics") 11 | } 12 | 13 | engine_packages <- purrr::map( 14 | ls(envir = get_model_env(), pattern = "_pkgs$"), 15 | get_from_env 16 | ) |> 17 | purrr::list_rbind() |> 18 | dplyr::pull(pkg) |> 19 | unlist() |> 20 | unique() |> 21 | setdiff(ignore_pkgs) |> 22 | setdiff(bio_pkgs) 23 | 24 | if (extension) { 25 | engine_packages <- setdiff(engine_packages, extensions_packages) 26 | } 27 | 28 | if (extras) { 29 | rmd_pkgs <- c("ape", "broom.mixed", "Cubist", "glmnet", "quantreg", 30 | "rmarkdown", "tidymodels", "xrf") 31 | engine_packages <- unique(c(engine_packages, rmd_pkgs)) 32 | } 33 | 34 | rlang::check_installed(engine_packages) 35 | rlang::check_installed(bio_pkgs) 36 | } 37 | -------------------------------------------------------------------------------- /R/linear_reg_brulee.R: -------------------------------------------------------------------------------- 1 | #' Linear regression via brulee 2 | #' 3 | #' [brulee::brulee_linear_reg()] uses ordinary least squares to fit models with 4 | #' numeric outcomes. 5 | #' 6 | #' @includeRmd man/rmd/linear_reg_brulee.md details 7 | #' 8 | #' @name details_linear_reg_brulee 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/linear_reg_gee.R: -------------------------------------------------------------------------------- 1 | #' Linear regression via generalized estimating equations (GEE) 2 | #' 3 | #' `gee::gee()` uses generalized least squares to fit different types of models 4 | #' with errors that are not independent. 5 | #' 6 | #' @includeRmd man/rmd/linear_reg_gee.md details 7 | #' 8 | #' @name details_linear_reg_gee 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/linear_reg_glm.R: -------------------------------------------------------------------------------- 1 | #' Linear regression via glm 2 | #' 3 | #' [stats::glm()] fits a generalized linear model for numeric outcomes. A 4 | #' linear combination of the predictors is used to model the numeric outcome 5 | #' via a link function. 6 | #' 7 | #' @includeRmd man/rmd/linear_reg_glm.md details 8 | #' 9 | #' @name details_linear_reg_glm 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/linear_reg_glmer.R: -------------------------------------------------------------------------------- 1 | #' Linear regression via generalized mixed models 2 | #' 3 | #' The `"glmer"` engine estimates fixed and random effect regression parameters 4 | #' using maximum likelihood (or restricted maximum likelihood) estimation. 5 | #' 6 | #' @includeRmd man/rmd/linear_reg_glmer.md details 7 | #' 8 | #' @name details_linear_reg_glmer 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/linear_reg_glmnet.R: -------------------------------------------------------------------------------- 1 | #' Linear regression via glmnet 2 | #' 3 | #' [glmnet::glmnet()] uses regularized least squares to fit models with numeric outcomes. 4 | #' 5 | #' @includeRmd man/rmd/linear_reg_glmnet.md details 6 | #' 7 | #' @name details_linear_reg_glmnet 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/linear_reg_gls.R: -------------------------------------------------------------------------------- 1 | #' Linear regression via generalized least squares 2 | #' 3 | #' The `"gls"` engine estimates linear regression for models where the rows of the 4 | #' data are not independent. 5 | #' 6 | #' @includeRmd man/rmd/linear_reg_gls.md details 7 | #' 8 | #' @name details_linear_reg_gls 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/linear_reg_h2o.R: -------------------------------------------------------------------------------- 1 | #' Linear regression via h2o 2 | #' 3 | #' This model uses regularized least squares to fit models with numeric outcomes. 4 | #' 5 | #' @includeRmd man/rmd/linear_reg_h2o.md details 6 | #' 7 | #' @name details_linear_reg_h2o 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/linear_reg_keras.R: -------------------------------------------------------------------------------- 1 | #' Linear regression via keras/tensorflow 2 | #' 3 | #' This model uses regularized least squares to fit models with numeric outcomes. 4 | #' 5 | #' @includeRmd man/rmd/linear_reg_keras.md details 6 | #' 7 | #' @name details_linear_reg_keras 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/linear_reg_lm.R: -------------------------------------------------------------------------------- 1 | #' Linear regression via lm 2 | #' 3 | #' [stats::lm()] uses ordinary least squares to fit models with numeric outcomes. 4 | #' 5 | #' @includeRmd man/rmd/linear_reg_lm.md details 6 | #' 7 | #' @name details_linear_reg_lm 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/linear_reg_lme.R: -------------------------------------------------------------------------------- 1 | #' Linear regression via mixed models 2 | #' 3 | #' The `"lme"` engine estimates fixed and random effect regression parameters 4 | #' using maximum likelihood (or restricted maximum likelihood) estimation. 5 | #' 6 | #' @includeRmd man/rmd/linear_reg_lme.md details 7 | #' 8 | #' @name details_linear_reg_lme 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/linear_reg_lmer.R: -------------------------------------------------------------------------------- 1 | #' Linear regression via mixed models 2 | #' 3 | #' The `"lmer"` engine estimates fixed and random effect regression parameters 4 | #' using maximum likelihood (or restricted maximum likelihood) estimation. 5 | #' 6 | #' @includeRmd man/rmd/linear_reg_lmer.md details 7 | #' 8 | #' @name details_linear_reg_lmer 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/linear_reg_quantreg.R: -------------------------------------------------------------------------------- 1 | #' Linear quantile regression via the quantreg package 2 | #' 3 | #' [quantreg::rq()] optimizes quantile loss to fit models with numeric outcomes. 4 | #' 5 | #' @includeRmd man/rmd/linear_reg_quantreg.md details 6 | #' 7 | #' @name details_linear_reg_quantreg 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/linear_reg_spark.R: -------------------------------------------------------------------------------- 1 | #' Linear regression via spark 2 | #' 3 | #' [sparklyr::ml_linear_regression()] uses regularized least squares to fit 4 | #' models with numeric outcomes. 5 | #' 6 | #' @includeRmd man/rmd/linear_reg_spark.md details 7 | #' 8 | #' @name details_linear_reg_spark 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/linear_reg_stan.R: -------------------------------------------------------------------------------- 1 | #' Linear regression via Bayesian Methods 2 | #' 3 | #' The `"stan"` engine estimates regression parameters using Bayesian estimation. 4 | #' 5 | #' @includeRmd man/rmd/linear_reg_stan.md details 6 | #' 7 | #' @name details_linear_reg_stan 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/linear_reg_stan_glmer.R: -------------------------------------------------------------------------------- 1 | #' Linear regression via hierarchical Bayesian methods 2 | #' 3 | #' The `"stan_glmer"` engine estimates hierarchical regression parameters using 4 | #' Bayesian estimation. 5 | #' 6 | #' @includeRmd man/rmd/linear_reg_stan_glmer.md details 7 | #' 8 | #' @name details_linear_reg_stan_glmer 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/logistic_reg_LiblineaR.R: -------------------------------------------------------------------------------- 1 | #' Logistic regression via LiblineaR 2 | #' 3 | #' [LiblineaR::LiblineaR()] fits a generalized linear model for binary outcomes. A 4 | #' linear combination of the predictors is used to model the log odds of an 5 | #' event. 6 | #' 7 | #' @includeRmd man/rmd/logistic_reg_LiblineaR.md details 8 | #' 9 | #' @name details_logistic_reg_LiblineaR 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/logistic_reg_brulee.R: -------------------------------------------------------------------------------- 1 | #' Logistic regression via brulee 2 | #' 3 | #' [brulee::brulee_logistic_reg()] fits a generalized linear model for binary 4 | #' outcomes. A linear combination of the predictors is used to model the log 5 | #' odds of an event. 6 | #' 7 | #' @includeRmd man/rmd/logistic_reg_brulee.md details 8 | #' 9 | #' @name details_logistic_reg_brulee 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/logistic_reg_gee.R: -------------------------------------------------------------------------------- 1 | #' Logistic regression via generalized estimating equations (GEE) 2 | #' 3 | #' `gee::gee()` uses generalized least squares to fit different types of models 4 | #' with errors that are not independent. 5 | #' 6 | #' @includeRmd man/rmd/logistic_reg_gee.md details 7 | #' 8 | #' @name details_logistic_reg_gee 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/logistic_reg_glm.R: -------------------------------------------------------------------------------- 1 | #' Logistic regression via glm 2 | #' 3 | #' [stats::glm()] fits a generalized linear model for binary outcomes. A 4 | #' linear combination of the predictors is used to model the log odds of an 5 | #' event. 6 | #' 7 | #' @includeRmd man/rmd/logistic_reg_glm.md details 8 | #' 9 | #' @name details_logistic_reg_glm 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/logistic_reg_glmer.R: -------------------------------------------------------------------------------- 1 | #' Logistic regression via mixed models 2 | #' 3 | #' The `"glmer"` engine estimates fixed and random effect regression parameters 4 | #' using maximum likelihood (or restricted maximum likelihood) estimation. 5 | #' 6 | #' @includeRmd man/rmd/logistic_reg_glmer.md details 7 | #' 8 | #' @name details_logistic_reg_glmer 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/logistic_reg_glmnet.R: -------------------------------------------------------------------------------- 1 | #' Logistic regression via glmnet 2 | #' 3 | #' [glmnet::glmnet()] fits a generalized linear model for binary outcomes. A 4 | #' linear combination of the predictors is used to model the log odds of an 5 | #' event. 6 | #' 7 | #' @includeRmd man/rmd/logistic_reg_glmnet.md details 8 | #' 9 | #' @name details_logistic_reg_glmnet 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/logistic_reg_h2o.R: -------------------------------------------------------------------------------- 1 | #' Logistic regression via h2o 2 | #' 3 | #' [h2o::h2o.glm()] fits a generalized linear model for binary outcomes. 4 | #' A linear combination of the predictors is used to model the log odds of an 5 | #' event. 6 | #' 7 | #' @includeRmd man/rmd/logistic_reg_h2o.md details 8 | #' 9 | #' @name details_logistic_reg_h2o 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/logistic_reg_keras.R: -------------------------------------------------------------------------------- 1 | #' Logistic regression via keras 2 | #' 3 | #' [keras_mlp()] fits a generalized linear model for binary outcomes. A 4 | #' linear combination of the predictors is used to model the log odds of an 5 | #' event. 6 | #' 7 | #' @includeRmd man/rmd/logistic_reg_keras.md details 8 | #' 9 | #' @name details_logistic_reg_keras 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/logistic_reg_spark.R: -------------------------------------------------------------------------------- 1 | #' Logistic regression via spark 2 | #' 3 | #' [sparklyr::ml_logistic_regression()] fits a generalized linear model for 4 | #' binary outcomes. A linear combination of the predictors is used to model the 5 | #' log odds of an event. 6 | #' 7 | #' @includeRmd man/rmd/logistic_reg_spark.md details 8 | #' 9 | #' @name details_logistic_reg_spark 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/logistic_reg_stan.R: -------------------------------------------------------------------------------- 1 | #' Logistic regression via stan 2 | #' 3 | #' [rstanarm::stan_glm()] fits a generalized linear model for binary outcomes. 4 | #' A linear combination of the predictors is used to model the log odds of an 5 | #' event. 6 | #' 7 | #' @includeRmd man/rmd/logistic_reg_stan.md details 8 | #' 9 | #' @name details_logistic_reg_stan 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/logistic_reg_stan_glmer.R: -------------------------------------------------------------------------------- 1 | #' Logistic regression via hierarchical Bayesian methods 2 | #' 3 | #' The `"stan_glmer"` engine estimates hierarchical regression parameters using 4 | #' Bayesian estimation. 5 | #' 6 | #' @includeRmd man/rmd/logistic_reg_stan_glmer.md details 7 | #' 8 | #' @name details_logistic_reg_stan_glmer 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/mars_earth.R: -------------------------------------------------------------------------------- 1 | #' Multivariate adaptive regression splines (MARS) via earth 2 | #' 3 | #' [earth::earth()] fits a generalized linear model that uses artificial features for 4 | #' some predictors. These features resemble hinge functions and the result is 5 | #' a model that is a segmented regression in small dimensions. 6 | #' 7 | #' @includeRmd man/rmd/mars_earth.md details 8 | #' 9 | #' @name details_mars_earth 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/mlp_brulee.R: -------------------------------------------------------------------------------- 1 | #' Multilayer perceptron via brulee 2 | #' 3 | #' [brulee::brulee_mlp()] fits a neural network. 4 | #' 5 | #' @includeRmd man/rmd/mlp_brulee.md details 6 | #' 7 | #' @name details_mlp_brulee 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/mlp_brulee_two_layer.R: -------------------------------------------------------------------------------- 1 | #' Multilayer perceptron via brulee with two hidden layers 2 | #' 3 | #' [brulee::brulee_mlp_two_layer()] fits a neural network (with version 0.3.0.9000 or higher of brulee) 4 | #' 5 | #' @includeRmd man/rmd/mlp_brulee_two_layer.md details 6 | #' 7 | #' @name details_mlp_brulee_two_layer 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/mlp_h2o.R: -------------------------------------------------------------------------------- 1 | #' Multilayer perceptron via h2o 2 | #' 3 | #' [h2o::h2o.deeplearning()] fits a feed-forward neural network. 4 | #' 5 | #' @includeRmd man/rmd/mlp_h2o.md details 6 | #' 7 | #' @name details_mlp_h2o 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/mlp_keras.R: -------------------------------------------------------------------------------- 1 | #' Multilayer perceptron via keras 2 | #' 3 | #' [keras_mlp()] fits a single layer, feed-forward neural network. 4 | #' 5 | #' @includeRmd man/rmd/mlp_keras.md details 6 | #' 7 | #' @name details_mlp_keras 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/mlp_nnet.R: -------------------------------------------------------------------------------- 1 | #' Multilayer perceptron via nnet 2 | #' 3 | #' [nnet::nnet()] fits a single layer, feed-forward neural network. 4 | #' 5 | #' @includeRmd man/rmd/mlp_nnet.md details 6 | #' 7 | #' @name details_mlp_nnet 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/multinom_reg_brulee.R: -------------------------------------------------------------------------------- 1 | #' Multinomial regression via brulee 2 | #' 3 | #' [brulee::brulee_multinomial_reg()] fits a model that uses linear predictors 4 | #' to predict multiclass data using the multinomial distribution. 5 | #' 6 | #' @includeRmd man/rmd/multinom_reg_brulee.md details 7 | #' 8 | #' @name details_multinom_reg_brulee 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/multinom_reg_glmnet.R: -------------------------------------------------------------------------------- 1 | #' Multinomial regression via glmnet 2 | #' 3 | #' [glmnet::glmnet()] fits a model that uses linear predictors to predict 4 | #' multiclass data using the multinomial distribution. 5 | #' 6 | #' @includeRmd man/rmd/multinom_reg_glmnet.md details 7 | #' 8 | #' @name details_multinom_reg_glmnet 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/multinom_reg_h2o.R: -------------------------------------------------------------------------------- 1 | #' Multinomial regression via h2o 2 | #' 3 | #' [h2o::h2o.glm()] fits a model that uses linear predictors to predict 4 | #' multiclass data for multinomial responses. 5 | #' 6 | #' @includeRmd man/rmd/multinom_reg_h2o.md details 7 | #' 8 | #' @name details_multinom_reg_h2o 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/multinom_reg_keras.R: -------------------------------------------------------------------------------- 1 | #' Multinomial regression via keras 2 | #' 3 | #' [keras_mlp()] fits a model that uses linear predictors to predict 4 | #' multiclass data using the multinomial distribution. 5 | #' 6 | #' @includeRmd man/rmd/multinom_reg_keras.md details 7 | #' 8 | #' @name details_multinom_reg_keras 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/multinom_reg_nnet.R: -------------------------------------------------------------------------------- 1 | #' Multinomial regression via nnet 2 | #' 3 | #' [nnet::multinom()] fits a model that uses linear predictors to predict 4 | #' multiclass data using the multinomial distribution. 5 | #' 6 | #' @includeRmd man/rmd/multinom_reg_nnet.md details 7 | #' 8 | #' @name details_multinom_reg_nnet 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/multinom_reg_spark.R: -------------------------------------------------------------------------------- 1 | #' Multinomial regression via spark 2 | #' 3 | #' [sparklyr::ml_logistic_regression()] fits a model that uses linear 4 | #' predictors to predict multiclass data using the multinomial distribution. 5 | #' 6 | #' @includeRmd man/rmd/multinom_reg_spark.md details 7 | #' 8 | #' @name details_multinom_reg_spark 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/naive_Bayes_h2o.R: -------------------------------------------------------------------------------- 1 | #' Naive Bayes models via naivebayes 2 | #' 3 | #' [h2o::h2o.naiveBayes()] fits a model that uses Bayes' theorem to compute 4 | #' the probability of each class, given the predictor values. 5 | #' 6 | #' @includeRmd man/rmd/naive_Bayes_h2o.md details 7 | #' 8 | #' @name details_naive_Bayes_h2o 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/naive_Bayes_klaR.R: -------------------------------------------------------------------------------- 1 | #' Naive Bayes models via klaR 2 | #' 3 | #' [klaR::NaiveBayes()] fits a model that uses Bayes' theorem to compute the 4 | #' probability of each class, given the predictor values. 5 | #' 6 | #' @includeRmd man/rmd/naive_Bayes_klaR.md details 7 | #' 8 | #' @name details_naive_Bayes_klaR 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/naive_Bayes_naivebayes.R: -------------------------------------------------------------------------------- 1 | #' Naive Bayes models via naivebayes 2 | #' 3 | #' [naivebayes::naive_bayes()] fits a model that uses Bayes' theorem to compute 4 | #' the probability of each class, given the predictor values. 5 | #' 6 | #' @includeRmd man/rmd/naive_Bayes_naivebayes.md details 7 | #' 8 | #' @name details_naive_Bayes_naivebayes 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/nearest_neighbor_kknn.R: -------------------------------------------------------------------------------- 1 | #' K-nearest neighbors via kknn 2 | #' 3 | #' [kknn::train.kknn()] fits a model that uses the `K` most similar data points 4 | #' from the training set to predict new samples. 5 | #' 6 | #' @includeRmd man/rmd/nearest_neighbor_kknn.md details 7 | #' 8 | #' @name details_nearest_neighbor_kknn 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/pls_mixOmics.R: -------------------------------------------------------------------------------- 1 | #' Partial least squares via mixOmics 2 | #' 3 | #' The mixOmics package can fit several different types of PLS models. 4 | #' 5 | #' @includeRmd man/rmd/pls_mixOmics.md details 6 | #' 7 | #' @name details_pls_mixOmics 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/poisson_reg_gee.R: -------------------------------------------------------------------------------- 1 | #' Poisson regression via generalized estimating equations (GEE) 2 | #' 3 | #' `gee::gee()` uses generalized least squares to fit different types of models 4 | #' with errors that are not independent. 5 | #' 6 | #' @includeRmd man/rmd/poisson_reg_gee.md details 7 | #' 8 | #' @name details_poisson_reg_gee 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/poisson_reg_glm.R: -------------------------------------------------------------------------------- 1 | #' Poisson regression via glm 2 | #' 3 | #' [stats::glm()] uses maximum likelihood to fit a model for count data. 4 | #' 5 | #' @includeRmd man/rmd/poisson_reg_glm.md details 6 | #' 7 | #' @name details_poisson_reg_glm 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/poisson_reg_glmer.R: -------------------------------------------------------------------------------- 1 | #' Poisson regression via mixed models 2 | #' 3 | #' The `"glmer"` engine estimates fixed and random effect regression parameters 4 | #' using maximum likelihood (or restricted maximum likelihood) estimation. 5 | #' 6 | #' @includeRmd man/rmd/poisson_reg_glmer.md details 7 | #' 8 | #' @name details_poisson_reg_glmer 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/poisson_reg_glmnet.R: -------------------------------------------------------------------------------- 1 | #' Poisson regression via glmnet 2 | #' 3 | #' `glmnet::glmnet()` uses penalized maximum likelihood to fit a model for 4 | #' count data. 5 | #' 6 | #' @includeRmd man/rmd/poisson_reg_glmnet.md details 7 | #' 8 | #' @name details_poisson_reg_glmnet 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/poisson_reg_h2o.R: -------------------------------------------------------------------------------- 1 | #' Poisson regression via h2o 2 | #' 3 | #' `h2o::h2o.glm()` uses penalized maximum likelihood to fit a model for 4 | #' count data. 5 | #' 6 | #' @includeRmd man/rmd/poisson_reg_h2o.md details 7 | #' 8 | #' @name details_poisson_reg_h2o 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/poisson_reg_hurdle.R: -------------------------------------------------------------------------------- 1 | #' Poisson regression via pscl 2 | #' 3 | #' [pscl::hurdle()] uses maximum likelihood estimation to fit a model for 4 | #' count data that has separate model terms for predicting the counts and for 5 | #' predicting the probability of a zero count. 6 | #' 7 | #' @includeRmd man/rmd/poisson_reg_hurdle.md details 8 | #' 9 | #' @name details_poisson_reg_hurdle 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/poisson_reg_stan.R: -------------------------------------------------------------------------------- 1 | #' Poisson regression via stan 2 | #' 3 | #' [rstanarm::stan_glm()] uses Bayesian estimation to fit a model for 4 | #' count data. 5 | #' 6 | #' @includeRmd man/rmd/poisson_reg_stan.md details 7 | #' 8 | #' @name details_poisson_reg_stan 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/poisson_reg_stan_glmer.R: -------------------------------------------------------------------------------- 1 | #' Poisson regression via hierarchical Bayesian methods 2 | #' 3 | #' The `"stan_glmer"` engine estimates hierarchical regression parameters using 4 | #' Bayesian estimation. 5 | #' 6 | #' @includeRmd man/rmd/poisson_reg_stan_glmer.md details 7 | #' 8 | #' @name details_poisson_reg_stan_glmer 9 | #' @keywords internal 10 | NULL 11 | 12 | # See inst/README-DOCS.md for a description of how these files are processed 13 | -------------------------------------------------------------------------------- /R/poisson_reg_zeroinfl.R: -------------------------------------------------------------------------------- 1 | #' Poisson regression via pscl 2 | #' 3 | #' [pscl::zeroinfl()] uses maximum likelihood estimation to fit a model for 4 | #' count data that has separate model terms for predicting the counts and for 5 | #' predicting the probability of a zero count. 6 | #' 7 | #' @includeRmd man/rmd/poisson_reg_zeroinfl.md details 8 | #' 9 | #' @name details_poisson_reg_zeroinfl 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/predict_hazard.R: -------------------------------------------------------------------------------- 1 | #' @keywords internal 2 | #' @rdname other_predict 3 | #' @inheritParams predict.model_fit 4 | #' @method predict_hazard model_fit 5 | #' @export predict_hazard.model_fit 6 | #' @export 7 | predict_hazard.model_fit <- function(object, 8 | new_data, 9 | eval_time, 10 | time = deprecated(), 11 | ...) { 12 | if (lifecycle::is_present(time)) { 13 | lifecycle::deprecate_warn( 14 | "1.0.4.9005", 15 | "predict_hazard(time)", 16 | "predict_hazard(eval_time)" 17 | ) 18 | eval_time <- time 19 | } 20 | eval_time <- .filter_eval_time(eval_time) 21 | 22 | check_spec_pred_type(object, "hazard") 23 | 24 | if (inherits(object$fit, "try-error")) { 25 | cli::cli_warn("Model fit failed; cannot make predictions.") 26 | return(NULL) 27 | } 28 | 29 | new_data <- prepare_data(object, new_data) 30 | 31 | # preprocess data 32 | if (!is.null(object$spec$method$pred$hazard$pre)) 33 | new_data <- object$spec$method$pred$hazard$pre(new_data, object) 34 | 35 | # create prediction call 36 | pred_call <- make_pred_call(object$spec$method$pred$hazard) 37 | 38 | res <- eval_tidy(pred_call) 39 | 40 | # post-process the predictions 41 | if(!is.null(object$spec$method$pred$hazard$post)) { 42 | res <- object$spec$method$pred$hazard$post(res, object) 43 | } 44 | 45 | res 46 | } 47 | 48 | # @export 49 | # @keywords internal 50 | # @rdname other_predict 51 | # @inheritParams predict.model_fit 52 | predict_hazard <- function (object, ...) 53 | UseMethod("predict_hazard") 54 | -------------------------------------------------------------------------------- /R/predict_linear_pred.R: -------------------------------------------------------------------------------- 1 | #' @keywords internal 2 | #' @rdname other_predict 3 | #' @inheritParams predict.model_fit 4 | #' @method predict_linear_pred model_fit 5 | #' @export predict_linear_pred.model_fit 6 | #' @export 7 | predict_linear_pred.model_fit <- function(object, new_data, ...) { 8 | 9 | check_spec_pred_type(object, "linear_pred") 10 | 11 | if (inherits(object$fit, "try-error")) { 12 | cli::cli_warn("Model fit failed; cannot make predictions.") 13 | return(NULL) 14 | } 15 | 16 | new_data <- prepare_data(object, new_data) 17 | 18 | # preprocess data 19 | if (!is.null(object$spec$method$pred$linear_pred$pre)) 20 | new_data <- object$spec$method$pred$linear_pred$pre(new_data, object) 21 | 22 | # create prediction call 23 | pred_call <- make_pred_call(object$spec$method$pred$linear_pred) 24 | 25 | res <- eval_tidy(pred_call) 26 | 27 | # post-process the predictions 28 | if (!is.null(object$spec$method$pred$linear_pred$post)) { 29 | res <- object$spec$method$pred$linear_pred$post(res, object) 30 | } 31 | 32 | if (is.vector(res)) { 33 | res <- unname(res) 34 | } 35 | 36 | res 37 | } 38 | 39 | 40 | #' @export 41 | #' @keywords internal 42 | #' @rdname other_predict 43 | #' @inheritParams predict_linear_pred.model_fit 44 | predict_linear_pred <- function(object, ...) 45 | UseMethod("predict_linear_pred") 46 | -------------------------------------------------------------------------------- /R/predict_raw.R: -------------------------------------------------------------------------------- 1 | #' @rdname predict.model_fit 2 | #' @method predict_raw model_fit 3 | #' @export predict_raw.model_fit 4 | #' @export 5 | predict_raw.model_fit <- function(object, new_data, opts = list(), ...) { 6 | protected_args <- names(object$spec$method$pred$raw$args) 7 | dup_args <- names(opts) %in% protected_args 8 | if (any(dup_args)) { 9 | opts <- opts[[!dup_args]] 10 | } 11 | if (length(opts) > 0) { 12 | object$spec$method$pred$raw$args <- 13 | c(object$spec$method$pred$raw$args, opts) 14 | } 15 | 16 | check_spec_pred_type(object, "raw") 17 | 18 | if (inherits(object$fit, "try-error")) { 19 | cli::cli_warn("Model fit failed; cannot make predictions.") 20 | return(NULL) 21 | } 22 | 23 | new_data <- prepare_data(object, new_data) 24 | 25 | # preprocess data 26 | if (!is.null(object$spec$method$pred$raw$pre)) 27 | new_data <- object$spec$method$pred$raw$pre(new_data, object) 28 | 29 | # create prediction call 30 | pred_call <- make_pred_call(object$spec$method$pred$raw) 31 | 32 | res <- eval_tidy(pred_call) 33 | 34 | res 35 | } 36 | 37 | 38 | #' @export 39 | #' @keywords internal 40 | #' @rdname predict.model_fit 41 | predict_raw <- function(object, ...) 42 | UseMethod("predict_raw") 43 | -------------------------------------------------------------------------------- /R/predict_time.R: -------------------------------------------------------------------------------- 1 | #' @keywords internal 2 | #' @rdname other_predict 3 | #' @inheritParams predict.model_fit 4 | #' @method predict_time model_fit 5 | #' @export predict_time.model_fit 6 | #' @export 7 | predict_time.model_fit <- function(object, new_data, ...) { 8 | if (object$spec$mode != "censored regression") { 9 | cli::cli_abort( 10 | c( 11 | "{.fun predict_time} is for predicting time outcomes.", 12 | "i" = "Use {.fun predict_class} or {.fun predict_classprob} for 13 | classification models." 14 | ), 15 | call = rlang::call2("predict") 16 | ) 17 | } 18 | 19 | check_spec_pred_type(object, "time") 20 | 21 | if (inherits(object$fit, "try-error")) { 22 | cli::cli_warn("Model fit failed; cannot make predictions.") 23 | return(NULL) 24 | } 25 | 26 | new_data <- prepare_data(object, new_data) 27 | 28 | # preprocess data 29 | if (!is.null(object$spec$method$pred$time$pre)) { 30 | new_data <- object$spec$method$pred$time$pre(new_data, object) 31 | } 32 | 33 | # create prediction call 34 | pred_call <- make_pred_call(object$spec$method$pred$time) 35 | 36 | res <- eval_tidy(pred_call) 37 | 38 | # post-process the predictions 39 | if (!is.null(object$spec$method$pred$time$post)) { 40 | res <- object$spec$method$pred$time$post(res, object) 41 | } 42 | 43 | if (is.vector(res)) { 44 | res <- unname(res) 45 | } 46 | 47 | res 48 | } 49 | 50 | 51 | #' @export 52 | #' @keywords internal 53 | #' @rdname other_predict 54 | #' @inheritParams predict_time.model_fit 55 | predict_time <- function(object, ...) { 56 | UseMethod("predict_time") 57 | } 58 | -------------------------------------------------------------------------------- /R/proportional_hazards_data.R: -------------------------------------------------------------------------------- 1 | 2 | # parsnip just contains the model specification, the engines are the censored package. 3 | 4 | set_new_model("proportional_hazards") 5 | set_model_mode("proportional_hazards", "censored regression") 6 | -------------------------------------------------------------------------------- /R/proportional_hazards_glmnet.R: -------------------------------------------------------------------------------- 1 | #' Proportional hazards regression 2 | #' 3 | #' [glmnet::glmnet()] fits a regularized Cox proportional hazards model. 4 | #' 5 | #' @includeRmd man/rmd/proportional_hazards_glmnet.md details 6 | #' 7 | #' @name details_proportional_hazards_glmnet 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/proportional_hazards_survival.R: -------------------------------------------------------------------------------- 1 | #' Proportional hazards regression 2 | #' 3 | #' [survival::coxph()] fits a Cox proportional hazards model. 4 | #' 5 | #' @includeRmd man/rmd/proportional_hazards_survival.md details 6 | #' 7 | #' @name details_proportional_hazards_survival 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/rand_forest_aorsf.R: -------------------------------------------------------------------------------- 1 | #' Oblique random survival forests via aorsf 2 | #' 3 | #' [aorsf::orsf()] fits a model that creates a large number of oblique decision 4 | #' trees, each de-correlated from the others. The final prediction uses all 5 | #' predictions from the individual trees and combines them. 6 | #' 7 | #' @includeRmd man/rmd/rand_forest_aorsf.md details 8 | #' 9 | #' @name details_rand_forest_aorsf 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/rand_forest_h2o.R: -------------------------------------------------------------------------------- 1 | #' Random forests via h2o 2 | #' 3 | #' [h2o::h2o.randomForest()] fits a model that creates a large number of 4 | #' decision trees, each independent of the others. The final prediction uses all 5 | #' predictions from the individual trees and combines them. 6 | #' 7 | #' @includeRmd man/rmd/rand_forest_h2o.md details 8 | #' 9 | #' @name details_rand_forest_h2o 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/rand_forest_partykit.R: -------------------------------------------------------------------------------- 1 | #' Random forests via partykit 2 | #' 3 | #' [partykit::cforest()] fits a model that creates a large number of decision 4 | #' trees, each independent of the others. The final prediction uses all 5 | #' predictions from the individual trees and combines them. 6 | #' 7 | #' @includeRmd man/rmd/rand_forest_partykit.md details 8 | #' 9 | #' @name details_rand_forest_partykit 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/rand_forest_randomForest.R: -------------------------------------------------------------------------------- 1 | #' Random forests via randomForest 2 | #' 3 | #' [randomForest::randomForest()] fits a model that creates a large number of 4 | #' decision trees, each independent of the others. The final prediction uses all 5 | #' predictions from the individual trees and combines them. 6 | #' 7 | #' @includeRmd man/rmd/rand_forest_randomForest.md details 8 | #' 9 | #' @name details_rand_forest_randomForest 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/rand_forest_ranger.R: -------------------------------------------------------------------------------- 1 | #' Random forests via ranger 2 | #' 3 | #' [ranger::ranger()] fits a model that creates a large number of decision 4 | #' trees, each independent of the others. The final prediction uses all 5 | #' predictions from the individual trees and combines them. 6 | #' 7 | #' @includeRmd man/rmd/rand_forest_ranger.md details 8 | #' 9 | #' @name details_rand_forest_ranger 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/rand_forest_spark.R: -------------------------------------------------------------------------------- 1 | #' Random forests via spark 2 | #' 3 | #' [sparklyr::ml_random_forest()] fits a model that creates a large number of 4 | #' decision trees, each independent of the others. The final prediction uses all 5 | #' predictions from the individual trees and combines them. 6 | #' 7 | #' @includeRmd man/rmd/rand_forest_spark.md details 8 | #' 9 | #' @name details_rand_forest_spark 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/reexports.R: -------------------------------------------------------------------------------- 1 | #' @importFrom ggplot2 autoplot 2 | #' @export 3 | ggplot2::autoplot 4 | 5 | #' @importFrom magrittr %>% 6 | #' @export 7 | magrittr::`%>%` 8 | 9 | #' @importFrom generics fit 10 | #' @export 11 | generics::fit 12 | 13 | #' @importFrom generics fit_xy 14 | #' @export 15 | generics::fit_xy 16 | 17 | #' @importFrom generics tidy 18 | #' @export 19 | generics::tidy 20 | 21 | #' @importFrom generics glance 22 | #' @export 23 | generics::glance 24 | 25 | #' @importFrom generics augment 26 | #' @export 27 | generics::augment 28 | 29 | #' @importFrom generics required_pkgs 30 | #' @export 31 | generics::required_pkgs 32 | 33 | #' @importFrom hardhat contr_one_hot 34 | #' @export 35 | hardhat::contr_one_hot 36 | 37 | #' @importFrom hardhat extract_spec_parsnip 38 | #' @export 39 | hardhat::extract_spec_parsnip 40 | 41 | #' @importFrom hardhat extract_fit_engine 42 | #' @export 43 | hardhat::extract_fit_engine 44 | 45 | #' @importFrom hardhat extract_parameter_set_dials 46 | #' @export 47 | hardhat::extract_parameter_set_dials 48 | 49 | #' @importFrom hardhat extract_parameter_dials 50 | #' @export 51 | hardhat::extract_parameter_dials 52 | 53 | #' @importFrom hardhat tune 54 | #' @export 55 | hardhat::tune 56 | 57 | #' @importFrom hardhat frequency_weights 58 | #' @export 59 | hardhat::frequency_weights 60 | 61 | #' @importFrom hardhat importance_weights 62 | #' @export 63 | hardhat::importance_weights 64 | 65 | #' @importFrom hardhat extract_fit_time 66 | #' @export 67 | hardhat::extract_fit_time 68 | -------------------------------------------------------------------------------- /R/req_pkgs.R: -------------------------------------------------------------------------------- 1 | #' Determine required packages for a model 2 | #' 3 | #' @description 4 | #' `r lifecycle::badge("deprecated")` 5 | #' 6 | #' @param x A [model specification][model_spec] or [fit][model_fit]. 7 | #' @param ... Not used. 8 | #' @return A character string of package names (if any). 9 | #' @details 10 | #' This function has been deprecated in favor of `required_pkgs()`. 11 | #' 12 | #' @export 13 | req_pkgs <- function(x, ...) { 14 | lifecycle::deprecate_stop("0.1.8", "req_pkgs()", "required_pkgs()") 15 | } 16 | -------------------------------------------------------------------------------- /R/rule_fit_h2o.R: -------------------------------------------------------------------------------- 1 | #' RuleFit models via h2o 2 | #' 3 | #' [h2o::h2o.rulefit()] fits a model that derives simple feature rules from a tree 4 | #' ensemble and uses the rules as features to a regularized (LASSO) model. [agua::h2o_train_rule()] 5 | #' is a wrapper around this function. 6 | #' 7 | #' @includeRmd man/rmd/rule_fit_h2o.md details 8 | #' 9 | #' @name details_rule_fit_h2o 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/rule_fit_xrf.R: -------------------------------------------------------------------------------- 1 | #' RuleFit models via xrf 2 | #' 3 | #' [xrf::xrf()] fits a model that derives simple feature rules from a tree 4 | #' ensemble and uses the rules as features to a regularized model. [rules::xrf_fit()] 5 | #' is a wrapper around this function. 6 | #' 7 | #' @includeRmd man/rmd/rule_fit_xrf.md details 8 | #' 9 | #' @name details_rule_fit_xrf 10 | #' @keywords internal 11 | NULL 12 | 13 | # See inst/README-DOCS.md for a description of how these files are processed 14 | -------------------------------------------------------------------------------- /R/survival-helpers.R: -------------------------------------------------------------------------------- 1 | # standalone-survival.R is loaded already. We'll capture the environment where 2 | # the functions of interest reside. We then document them and connect the 3 | # functions to their docs via the use of @alias. After the roxygen comments, 4 | # assign the function by referencing its name in the environment. 5 | 6 | surv_ns <- environment(.extract_surv_status) 7 | 8 | #' Extract survival time 9 | #' 10 | #' Extract the time component(s) from a [survival::Surv()] object. 11 | #' @name .extract_surv_time 12 | #' @aliases .extract_surv_time 13 | #' @param surv A single [survival::Surv()] object. 14 | #' @return A vector when the type is `"right"` or `"left"` and a tibble otherwise. 15 | #' @export 16 | assign(".extract_surv_time", surv_ns[[".extract_surv_time"]]) 17 | 18 | #' Extract survival status 19 | #' 20 | #' Extract the status from a [survival::Surv()] object. 21 | #' @name .extract_surv_status 22 | #' @aliases .extract_surv_status 23 | #' @param surv A single [survival::Surv()] object. 24 | #' @return A numeric vector. 25 | #' @export 26 | assign(".extract_surv_status", surv_ns[[".extract_surv_status"]]) 27 | -------------------------------------------------------------------------------- /R/survival_reg_data.R: -------------------------------------------------------------------------------- 1 | 2 | set_new_model("survival_reg") 3 | set_model_mode("survival_reg", "censored regression") 4 | 5 | # ------------------------------------------------------------------------------ 6 | 7 | # parsnip just contains the model specification, the engines are the censored package. 8 | -------------------------------------------------------------------------------- /R/survival_reg_flexsurv.R: -------------------------------------------------------------------------------- 1 | #' Parametric survival regression 2 | #' 3 | #' [flexsurv::flexsurvreg()] fits a parametric survival model. 4 | #' 5 | #' @includeRmd man/rmd/survival_reg_flexsurv.md details 6 | #' 7 | #' @name details_survival_reg_flexsurv 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/survival_reg_flexsurvspline.R: -------------------------------------------------------------------------------- 1 | #' Flexible parametric survival regression 2 | #' 3 | #' [flexsurv::flexsurvspline()] fits a flexible parametric survival model. 4 | #' 5 | #' @includeRmd man/rmd/survival_reg_flexsurvspline.md details 6 | #' 7 | #' @name details_survival_reg_flexsurvspline 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/survival_reg_survival.R: -------------------------------------------------------------------------------- 1 | #' Parametric survival regression 2 | #' 3 | #' [survival::survreg()] fits a parametric survival model. 4 | #' 5 | #' @includeRmd man/rmd/survival_reg_survival.md details 6 | #' 7 | #' @name details_survival_reg_survival 8 | #' @keywords internal 9 | NULL 10 | 11 | # See inst/README-DOCS.md for a description of how these files are processed 12 | -------------------------------------------------------------------------------- /R/svm_linear_LiblineaR.R: -------------------------------------------------------------------------------- 1 | #' Linear support vector machines (SVMs) via LiblineaR 2 | #' 3 | #' [LiblineaR::LiblineaR()] fits a support vector machine model. For classification, 4 | #' the model tries to maximize the width of the margin between classes. 5 | #' For regression, the model optimizes a robust loss function that is only 6 | #' affected by very large model residuals. 7 | #' 8 | #' @includeRmd man/rmd/svm_linear_LiblineaR.md details 9 | #' 10 | #' @name details_svm_linear_LiblineaR 11 | #' @keywords internal 12 | NULL 13 | 14 | # See inst/README-DOCS.md for a description of how these files are processed 15 | -------------------------------------------------------------------------------- /R/svm_linear_kernlab.R: -------------------------------------------------------------------------------- 1 | #' Linear support vector machines (SVMs) via kernlab 2 | #' 3 | #' [kernlab::ksvm()] fits a support vector machine model. For classification, 4 | #' the model tries to maximize the width of the margin between classes. 5 | #' For regression, the model optimizes a robust loss function that is only 6 | #' affected by very large model residuals. 7 | #' 8 | #' @includeRmd man/rmd/svm_linear_kernlab.md details 9 | #' 10 | #' @name details_svm_linear_kernlab 11 | #' @keywords internal 12 | NULL 13 | 14 | # See inst/README-DOCS.md for a description of how these files are processed 15 | -------------------------------------------------------------------------------- /R/svm_poly_kernlab.R: -------------------------------------------------------------------------------- 1 | #' Polynomial support vector machines (SVMs) via kernlab 2 | #' 3 | #' [kernlab::ksvm()] fits a support vector machine model. For classification, 4 | #' the model tries to maximize the width of the margin between classes. 5 | #' For regression, the model optimizes a robust loss function that is only 6 | #' affected by very large model residuals. 7 | #' 8 | #' @includeRmd man/rmd/svm_poly_kernlab.md details 9 | #' 10 | #' @name details_svm_poly_kernlab 11 | #' @keywords internal 12 | NULL 13 | 14 | # See inst/README-DOCS.md for a description of how these files are processed 15 | -------------------------------------------------------------------------------- /R/svm_rbf_kernlab.R: -------------------------------------------------------------------------------- 1 | #' Radial basis function support vector machines (SVMs) via kernlab 2 | #' 3 | #' [kernlab::ksvm()] fits a support vector machine model. For classification, 4 | #' the model tries to maximize the width of the margin between classes. 5 | #' For regression, the model optimizes a robust loss function that is only 6 | #' affected by very large model residuals. 7 | #' 8 | #' @includeRmd man/rmd/svm_rbf_kernlab.md details 9 | #' 10 | #' @name details_svm_rbf_kernlab 11 | #' @keywords internal 12 | NULL 13 | 14 | # See inst/README-DOCS.md for a description of how these files are processed 15 | -------------------------------------------------------------------------------- /R/tidy.R: -------------------------------------------------------------------------------- 1 | #' Turn a parsnip model object into a tidy tibble 2 | #' 3 | #' This method tidies the model in a parsnip model object, if it exists. 4 | #' 5 | #' @inheritParams generics::tidy 6 | #' 7 | #' @return a tibble 8 | #' @export 9 | tidy.model_fit <- function(x, ...) generics::tidy(x$fit, ...) 10 | 11 | 12 | #' Construct a single row summary "glance" of a model, fit, or other object 13 | #' 14 | #' This method glances the model in a parsnip model object, if it exists. 15 | #' 16 | #' @inheritParams generics::glance 17 | #' 18 | #' @return a tibble 19 | #' @export 20 | glance.model_fit <- function(x, ...) generics::glance(x$fit, ...) 21 | -------------------------------------------------------------------------------- /R/tidy_liblinear.R: -------------------------------------------------------------------------------- 1 | #' tidy methods for LiblineaR models 2 | #' 3 | #' `tidy()` methods for the various `LiblineaR` models that return the 4 | #' coefficients from the parsnip model fit. 5 | #' @param x A fitted parsnip model that used the `LiblineaR` engine. 6 | #' @param ... Not used 7 | #' @return A tibble with columns `term` and `estimate`. 8 | #' @keywords internal 9 | #' @export 10 | 11 | tidy._LiblineaR <- function(x, ...) { 12 | check_installs(x$spec) 13 | ret <- tibble(colnames(x$fit$W), x$fit$W[1,]) 14 | colnames(ret) <- c("term", "estimate") 15 | 16 | ret 17 | } 18 | -------------------------------------------------------------------------------- /R/type_sum.R: -------------------------------------------------------------------------------- 1 | #' Succinct summary of parsnip object 2 | #' 3 | #' `type_sum` controls how objects are shown when inside tibble 4 | #' columns. 5 | #' @param x A `model_spec` or `model_fit` object to summarise. 6 | #' @details For `model_spec` objects, the summary is "`spec[?]`" 7 | #' or "`spec[+]`". The former indicates that either the model 8 | #' mode has not been declared or that the specification has 9 | #' `tune()` parameters. Otherwise, the latter is shown. 10 | #' 11 | #' For fitted models, either "`fit[x]`" or "`fit[+]`" are used 12 | #' where the "x" implies that the model fit failed in some way. 13 | #' @return A character value. 14 | #' @method type_sum model_spec 15 | #' @keywords internal 16 | #' @export 17 | type_sum.model_spec <- function(x) { 18 | resolved <- TRUE 19 | if (x$mode == "unknown") 20 | resolved <- FALSE 21 | arg_info <- generics::tune_args(x) 22 | if (any(arg_info$tunable)) 23 | resolved <- FALSE 24 | 25 | res <- "spec" 26 | if (resolved) { 27 | res <- paste0(res, "[+]") 28 | } else { 29 | res <- paste0(res, "[?]") 30 | } 31 | res 32 | } 33 | 34 | #' @rdname type_sum.model_spec 35 | #' @method type_sum model_fit 36 | #' @keywords internal 37 | #' @export 38 | type_sum.model_fit <- function(x) { 39 | resolved <- TRUE 40 | if (inherits(x$fit, "try-error")) 41 | resolved <- FALSE 42 | 43 | res <- "fit" 44 | if (resolved) { 45 | res <- paste0(res, "[+]") 46 | } else { 47 | res <- paste0(res, "[x]") 48 | } 49 | res 50 | } 51 | -------------------------------------------------------------------------------- /air.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidymodels/parsnip/6d4c68477ef81a9a7fe044cd628b3d80e451fe3b/air.toml -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | target: auto 8 | threshold: 1% 9 | informational: true 10 | patch: 11 | default: 12 | target: auto 13 | threshold: 1% 14 | informational: true 15 | -------------------------------------------------------------------------------- /data/model_db.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidymodels/parsnip/6d4c68477ef81a9a7fe044cd628b3d80e451fe3b/data/model_db.rda -------------------------------------------------------------------------------- /inst/rstudio/addins.dcf: -------------------------------------------------------------------------------- 1 | 2 | Name: Generate parsnip model specifications 3 | Description: Automatically generate code for multiple parsnip model specifications. 4 | Binding: parsnip_addin 5 | Interactive: true 6 | -------------------------------------------------------------------------------- /man-roxygen/spec-details.R: -------------------------------------------------------------------------------- 1 | #' @details 2 | #' This function only defines what _type_ of model is being fit. Once an engine 3 | #' is specified, the _method_ to fit the model is also defined. See 4 | #' [set_engine()] for more on setting the engine, including how to set engine 5 | #' arguments. 6 | #' 7 | #' The model is not trained or fit until the [`fit()`][fit.model_spec()] function is used 8 | #' with the data. 9 | #' 10 | #' Each of the arguments in this function other than `mode` and `engine` are 11 | #' captured as [quosures][rlang::topic-quosure]. To pass values 12 | #' programmatically, use the [injection operator][rlang::!!] like so: 13 | #' 14 | #' ``` r 15 | #' value <- 1 16 | #' <%= modeltype %>(argument = !!value) 17 | #' ``` 18 | -------------------------------------------------------------------------------- /man-roxygen/spec-references.R: -------------------------------------------------------------------------------- 1 | #' @references \url{https://www.tidymodels.org}, [_Tidy Modeling with R_](https://www.tmwr.org/), [searchable table of parsnip models](https://www.tidymodels.org/find/parsnip/) 2 | -------------------------------------------------------------------------------- /man-roxygen/spec-survival.R: -------------------------------------------------------------------------------- 1 | #' @details 2 | #' Since survival models typically involve censoring (and require the use of 3 | #' [survival::Surv()] objects), the [fit.model_spec()] function will require that the 4 | #' survival model be specified via the formula interface. 5 | -------------------------------------------------------------------------------- /man/C5.0_train.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/boost_tree.R 3 | \name{C5.0_train} 4 | \alias{C5.0_train} 5 | \title{Boosted trees via C5.0} 6 | \usage{ 7 | C5.0_train(x, y, weights = NULL, trials = 15, minCases = 2, sample = 0, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A data frame or matrix of predictors.} 11 | 12 | \item{y}{A factor vector with 2 or more levels} 13 | 14 | \item{weights}{An optional numeric vector of case weights. Note 15 | that the data used for the case weights will not be used as a 16 | splitting variable in the model (see 17 | \verb{https://www.rulequest.com/see5-info.html} for 18 | Quinlan's notes on case weights).} 19 | 20 | \item{trials}{An integer specifying the number of boosting 21 | iterations. A value of one indicates that a single model is 22 | used.} 23 | 24 | \item{minCases}{An integer for the smallest number of samples 25 | that must be put in at least two of the splits.} 26 | 27 | \item{sample}{A value between (0, .999) that specifies the 28 | random proportion of the data should be used to train the model. 29 | By default, all the samples are used for model training. Samples 30 | not used for training are used to evaluate the accuracy of the 31 | model in the printed output. A value of zero means that all the training 32 | data are used.} 33 | 34 | \item{...}{Other arguments to pass.} 35 | } 36 | \value{ 37 | A fitted C5.0 model. 38 | } 39 | \description{ 40 | \code{C5.0_train} is a wrapper for the \code{C5.0()} function in the 41 | \pkg{C50} package that fits tree-based models 42 | where all of the model arguments are in the main function. 43 | } 44 | \keyword{internal} 45 | -------------------------------------------------------------------------------- /man/add_on_exports.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/arguments.R, R/misc.R, R/print.R, R/update.R, 3 | % R/varying.R 4 | \name{null_value} 5 | \alias{null_value} 6 | \alias{show_fit} 7 | \alias{check_args} 8 | \alias{update_dot_check} 9 | \alias{new_model_spec} 10 | \alias{check_final_param} 11 | \alias{update_main_parameters} 12 | \alias{update_engine_parameters} 13 | \alias{print_model_spec} 14 | \alias{update_spec} 15 | \alias{is_varying} 16 | \title{Functions required for parsnip-adjacent packages} 17 | \usage{ 18 | null_value(x) 19 | 20 | show_fit(model, eng) 21 | 22 | check_args(object, call = rlang::caller_env()) 23 | 24 | update_dot_check(...) 25 | 26 | new_model_spec( 27 | cls, 28 | args, 29 | eng_args, 30 | mode, 31 | user_specified_mode = TRUE, 32 | method, 33 | engine, 34 | user_specified_engine = TRUE 35 | ) 36 | 37 | check_final_param(x, call = rlang::caller_env()) 38 | 39 | update_main_parameters(args, param, call = rlang::caller_env()) 40 | 41 | update_engine_parameters(eng_args, fresh, ...) 42 | 43 | print_model_spec(x, cls = class(x)[1], desc = get_model_desc(cls), ...) 44 | 45 | update_spec( 46 | object, 47 | parameters, 48 | args_enquo_list, 49 | fresh, 50 | cls, 51 | ..., 52 | call = caller_env() 53 | ) 54 | 55 | is_varying(x) 56 | } 57 | \description{ 58 | These functions are helpful when creating new packages that will register 59 | new model specifications. 60 | } 61 | \keyword{internal} 62 | -------------------------------------------------------------------------------- /man/add_rowindex.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/adds.R 3 | \name{add_rowindex} 4 | \alias{add_rowindex} 5 | \title{Add a column of row numbers to a data frame} 6 | \usage{ 7 | add_rowindex(x) 8 | } 9 | \arguments{ 10 | \item{x}{A data frame} 11 | } 12 | \value{ 13 | The same data frame with a column of 1-based integers named \code{.row}. 14 | } 15 | \description{ 16 | Add a column of row numbers to a data frame 17 | } 18 | \examples{ 19 | \dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 20 | mtcars |> add_rowindex() 21 | \dontshow{\}) # examplesIf} 22 | } 23 | -------------------------------------------------------------------------------- /man/bart-internal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/bart.R 3 | \name{bart-internal} 4 | \alias{bart-internal} 5 | \alias{dbart_predict_calc} 6 | \title{Developer functions for predictions via BART models} 7 | \usage{ 8 | dbart_predict_calc(obj, new_data, type, level = 0.95, std_err = FALSE) 9 | } 10 | \arguments{ 11 | \item{obj}{A parsnip object.} 12 | 13 | \item{new_data}{A rectangular data object, such as a data frame.} 14 | 15 | \item{type}{A single character value or \code{NULL}. Possible values 16 | are \code{"numeric"}, \code{"class"}, \code{"prob"}, \code{"conf_int"}, \code{"pred_int"}, 17 | \code{"quantile"}, \code{"time"}, \code{"hazard"}, \code{"survival"}, or \code{"raw"}. When \code{NULL}, 18 | \code{predict()} will choose an appropriate value based on the model's mode.} 19 | 20 | \item{level}{Confidence level.} 21 | 22 | \item{std_err}{Attach column for standard error of prediction or not.} 23 | } 24 | \description{ 25 | Developer functions for predictions via BART models 26 | } 27 | \keyword{internal} 28 | -------------------------------------------------------------------------------- /man/case_weights_allowed.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/case_weights.R 3 | \name{case_weights_allowed} 4 | \alias{case_weights_allowed} 5 | \title{Determine if case weights are used} 6 | \usage{ 7 | case_weights_allowed(spec) 8 | } 9 | \arguments{ 10 | \item{spec}{A parsnip \link[=model_spec]{model specification}.} 11 | } 12 | \value{ 13 | A single logical. 14 | } 15 | \description{ 16 | Not all modeling engines can incorporate case weights into their 17 | calculations. This function can determine whether they can be used. 18 | } 19 | \examples{ 20 | case_weights_allowed(linear_reg()) 21 | case_weights_allowed(linear_reg(engine = "keras")) 22 | } 23 | -------------------------------------------------------------------------------- /man/check_empty_ellipse.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/misc.R 3 | \name{check_empty_ellipse} 4 | \alias{check_empty_ellipse} 5 | \title{Check to ensure that ellipses are empty} 6 | \usage{ 7 | check_empty_ellipse(...) 8 | } 9 | \arguments{ 10 | \item{...}{Extra arguments.} 11 | } 12 | \value{ 13 | If an error is not thrown (from non-empty ellipses), a NULL list. 14 | } 15 | \description{ 16 | Check to ensure that ellipses are empty 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/condense_control.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/condense_control.R 3 | \name{condense_control} 4 | \alias{condense_control} 5 | \title{Condense control object into strictly smaller control object} 6 | \usage{ 7 | condense_control(x, ref, ..., call = rlang::caller_env()) 8 | } 9 | \arguments{ 10 | \item{x}{A control object to be condensed.} 11 | 12 | \item{ref}{A control object that is used to determine what element should be 13 | kept.} 14 | 15 | \item{call}{The execution environment of a currently running function, e.g. 16 | \code{caller_env()}. The function will be mentioned in error messages as the 17 | source of the error. See the call argument of \code{\link[rlang:abort]{rlang::abort()}} for more 18 | information.} 19 | } 20 | \value{ 21 | A control object with the same elements and classes of \code{ref}, with 22 | values of \code{x}. 23 | } 24 | \description{ 25 | This function is used to help the hierarchy of control functions used 26 | throughout the tidymodels packages. It is now assumed that each control 27 | function is either a subset or a superset of another control function. 28 | } 29 | \examples{ 30 | \dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 31 | ctrl <- control_parsnip(catch = TRUE) 32 | ctrl$allow_par <- TRUE 33 | str(ctrl) 34 | 35 | ctrl <- condense_control(ctrl, control_parsnip()) 36 | str(ctrl) 37 | \dontshow{\}) # examplesIf} 38 | } 39 | \keyword{internal} 40 | -------------------------------------------------------------------------------- /man/control_parsnip.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/control_parsnip.R 3 | \name{control_parsnip} 4 | \alias{control_parsnip} 5 | \title{Control the fit function} 6 | \usage{ 7 | control_parsnip(verbosity = 1L, catch = FALSE) 8 | } 9 | \arguments{ 10 | \item{verbosity}{An integer to control how verbose the output is. For a 11 | value of zero, no messages or output are shown when packages are loaded or 12 | when the model is fit. For a value of 1, package loading is quiet but model 13 | fits can produce output to the screen (depending on if they contain their 14 | own \code{verbose}-type argument). For a value of 2 or more, any output at all 15 | is displayed and the execution time of the fit is recorded and printed.} 16 | 17 | \item{catch}{A logical where a value of \code{TRUE} will evaluate the model 18 | inside of \code{try(, silent = TRUE)}. If the model fails, an object is still 19 | returned (without an error) that inherits the class "try-error".} 20 | } 21 | \value{ 22 | An S3 object with class "control_parsnip" that is a named list 23 | with the results of the function call 24 | } 25 | \description{ 26 | Pass options to the \code{\link[=fit.model_spec]{fit.model_spec()}} function to control its 27 | output and computations 28 | } 29 | \examples{ 30 | \dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 31 | control_parsnip(verbosity = 2L) 32 | \dontshow{\}) # examplesIf} 33 | } 34 | -------------------------------------------------------------------------------- /man/convert_stan_interval.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/aaa.R 3 | \name{convert_stan_interval} 4 | \alias{convert_stan_interval} 5 | \title{Convenience function for intervals} 6 | \usage{ 7 | convert_stan_interval(x, level = 0.95, lower = TRUE) 8 | } 9 | \arguments{ 10 | \item{x}{A fitted model object} 11 | 12 | \item{level}{Level of uncertainty for intervals} 13 | 14 | \item{lower}{Is \code{level} the lower level?} 15 | } 16 | \description{ 17 | Convenience function for intervals 18 | } 19 | \keyword{internal} 20 | -------------------------------------------------------------------------------- /man/dot-extract_surv_status.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/survival-helpers.R 3 | \name{.extract_surv_status} 4 | \alias{.extract_surv_status} 5 | \title{Extract survival status} 6 | \arguments{ 7 | \item{surv}{A single \code{\link[survival:Surv]{survival::Surv()}} object.} 8 | } 9 | \value{ 10 | A numeric vector. 11 | } 12 | \description{ 13 | Extract the status from a \code{\link[survival:Surv]{survival::Surv()}} object. 14 | } 15 | -------------------------------------------------------------------------------- /man/dot-extract_surv_time.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/survival-helpers.R 3 | \name{.extract_surv_time} 4 | \alias{.extract_surv_time} 5 | \title{Extract survival time} 6 | \arguments{ 7 | \item{surv}{A single \code{\link[survival:Surv]{survival::Surv()}} object.} 8 | } 9 | \value{ 10 | A vector when the type is \code{"right"} or \code{"left"} and a tibble otherwise. 11 | } 12 | \description{ 13 | Extract the time component(s) from a \code{\link[survival:Surv]{survival::Surv()}} object. 14 | } 15 | -------------------------------------------------------------------------------- /man/dot-get_prediction_column_names.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/misc.R 3 | \name{.get_prediction_column_names} 4 | \alias{.get_prediction_column_names} 5 | \title{Obtain names of prediction columns for a fitted model or workflow} 6 | \usage{ 7 | .get_prediction_column_names(x, syms = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{A fitted parsnip model (class \code{"model_fit"}) or a fitted workflow.} 11 | 12 | \item{syms}{Should the column names be converted to symbols? Defaults to \code{FALSE}.} 13 | } 14 | \value{ 15 | A list with elements \code{"estimate"} and \code{"probabilities"}. 16 | } 17 | \description{ 18 | \code{\link[=.get_prediction_column_names]{.get_prediction_column_names()}} returns a list that has the names of the 19 | columns for the primary prediction types for a model. 20 | } 21 | \examples{ 22 | \dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("modeldata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 23 | library(dplyr) 24 | library(modeldata) 25 | data("two_class_dat") 26 | 27 | levels(two_class_dat$Class) 28 | lr_fit <- logistic_reg() |> fit(Class ~ ., data = two_class_dat) 29 | 30 | .get_prediction_column_names(lr_fit) 31 | .get_prediction_column_names(lr_fit, syms = TRUE) 32 | \dontshow{\}) # examplesIf} 33 | } 34 | -------------------------------------------------------------------------------- /man/dot-model_param_name_key.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/translate.R 3 | \name{.model_param_name_key} 4 | \alias{.model_param_name_key} 5 | \title{Translate names of model tuning parameters} 6 | \usage{ 7 | .model_param_name_key(object, as_tibble = TRUE) 8 | } 9 | \arguments{ 10 | \item{object}{A workflow or parsnip model specification.} 11 | 12 | \item{as_tibble}{A logical. Should the results be in a tibble (the default) 13 | or in a list that can facilitate renaming grid objects?} 14 | } 15 | \value{ 16 | A tibble with columns \code{user}, \code{parsnip}, and \code{engine}, or a list 17 | with named character vectors \code{user_to_parsnip} and \code{parsnip_to_engine}. 18 | } 19 | \description{ 20 | This function creates a key that connects the identifiers users make for 21 | tuning parameter names, the standardized parsnip parameter names, and the 22 | argument names to the underlying fit function for the engine. 23 | } 24 | \examples{ 25 | \dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("dials")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 26 | mod <- 27 | linear_reg(penalty = tune("regularization"), mixture = tune()) |> 28 | set_engine("glmnet") 29 | 30 | mod |> .model_param_name_key() 31 | 32 | rn <- mod |> .model_param_name_key(as_tibble = FALSE) 33 | rn 34 | 35 | grid <- tidyr::crossing(regularization = c(0, 1), mixture = (0:3) / 3) 36 | 37 | grid |> 38 | dplyr::rename(!!!rn$user_to_parsnip) 39 | 40 | grid |> 41 | dplyr::rename(!!!rn$user_to_parsnip) |> 42 | dplyr::rename(!!!rn$parsnip_to_engine) 43 | \dontshow{\}) # examplesIf} 44 | } 45 | \keyword{internal} 46 | -------------------------------------------------------------------------------- /man/eval_args.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/arguments.R 3 | \name{eval_args} 4 | \alias{eval_args} 5 | \title{Evaluate parsnip model arguments} 6 | \usage{ 7 | eval_args(spec, ...) 8 | } 9 | \arguments{ 10 | \item{spec}{A \link[=model_spec]{model specification}.} 11 | 12 | \item{...}{Not used.} 13 | } 14 | \description{ 15 | Evaluate parsnip model arguments 16 | } 17 | \keyword{internal} 18 | -------------------------------------------------------------------------------- /man/figures/adjust.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidymodels/parsnip/6d4c68477ef81a9a7fe044cd628b3d80e451fe3b/man/figures/adjust.png -------------------------------------------------------------------------------- /man/figures/comittees.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidymodels/parsnip/6d4c68477ef81a9a7fe044cd628b3d80e451fe3b/man/figures/comittees.png -------------------------------------------------------------------------------- /man/figures/comittees.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidymodels/parsnip/6d4c68477ef81a9a7fe044cd628b3d80e451fe3b/man/figures/comittees.tiff -------------------------------------------------------------------------------- /man/figures/lifecycle-archived.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: archived 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | archived 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/lifecycle-defunct.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: defunct 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | defunct 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/lifecycle-deprecated.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: deprecated 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | deprecated 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/lifecycle-experimental.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: experimental 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | experimental 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/lifecycle-maturing.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: maturing 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | maturing 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/lifecycle-questioning.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: questioning 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | questioning 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/lifecycle-soft-deprecated.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: soft-deprecated 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | soft-deprecated 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/lifecycle-stable.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: stable 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 19 | 20 | lifecycle 21 | 22 | 25 | 26 | stable 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /man/figures/lifecycle-superseded.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: superseded 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | superseded 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidymodels/parsnip/6d4c68477ef81a9a7fe044cd628b3d80e451fe3b/man/figures/logo.png -------------------------------------------------------------------------------- /man/figures/random_int_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidymodels/parsnip/6d4c68477ef81a9a7fe044cd628b3d80e451fe3b/man/figures/random_int_model.png -------------------------------------------------------------------------------- /man/figures/random_int_pop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidymodels/parsnip/6d4c68477ef81a9a7fe044cd628b3d80e451fe3b/man/figures/random_int_pop.png -------------------------------------------------------------------------------- /man/format-internals.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/predict.R 3 | \name{format-internals} 4 | \alias{format-internals} 5 | \alias{format_num} 6 | \alias{format_class} 7 | \alias{format_classprobs} 8 | \alias{format_time} 9 | \alias{format_survival} 10 | \alias{format_linear_pred} 11 | \alias{format_hazard} 12 | \alias{ensure_parsnip_format} 13 | \title{Internal functions that format predictions} 14 | \usage{ 15 | format_num(x) 16 | 17 | format_class(x) 18 | 19 | format_classprobs(x) 20 | 21 | format_time(x) 22 | 23 | format_survival(x) 24 | 25 | format_linear_pred(x) 26 | 27 | format_hazard(x) 28 | 29 | ensure_parsnip_format(x, col_name, overwrite = TRUE) 30 | } 31 | \arguments{ 32 | \item{x}{A data frame or vector (depending on the context and function).} 33 | 34 | \item{col_name}{A string for a prediction column name.} 35 | 36 | \item{overwrite}{A logical for whether to overwrite the column name.} 37 | } 38 | \value{ 39 | A tibble 40 | } 41 | \description{ 42 | These are used to ensure that we have appropriate column names inside of 43 | tibbles. 44 | } 45 | \keyword{internal} 46 | -------------------------------------------------------------------------------- /man/get_model_env.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/aaa_models.R 3 | \name{get_model_env} 4 | \alias{get_model_env} 5 | \alias{get_from_env} 6 | \alias{set_in_env} 7 | \alias{set_env_val} 8 | \title{Working with the parsnip model environment} 9 | \usage{ 10 | get_model_env() 11 | 12 | get_from_env(items) 13 | 14 | set_in_env(...) 15 | 16 | set_env_val(name, value) 17 | } 18 | \arguments{ 19 | \item{items}{A character string of objects in the model environment.} 20 | 21 | \item{...}{Named values that will be assigned to the model environment.} 22 | 23 | \item{name}{A single character value for a new symbol in the model environment.} 24 | 25 | \item{value}{A single value for a new value in the model environment.} 26 | } 27 | \description{ 28 | These functions read and write to the environment where the package stores 29 | information about model specifications. 30 | } 31 | \examples{ 32 | \dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 33 | # Access the model data: 34 | current_code <- get_model_env() 35 | ls(envir = current_code) 36 | \dontshow{\}) # examplesIf} 37 | } 38 | \references{ 39 | "How to build a parsnip model" 40 | \url{https://www.tidymodels.org/learn/develop/models/} 41 | } 42 | \keyword{internal} 43 | -------------------------------------------------------------------------------- /man/glance.model_fit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tidy.R 3 | \name{glance.model_fit} 4 | \alias{glance.model_fit} 5 | \title{Construct a single row summary "glance" of a model, fit, or other object} 6 | \usage{ 7 | \method{glance}{model_fit}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{model or other R object to convert to single-row data frame} 11 | 12 | \item{...}{other arguments passed to methods} 13 | } 14 | \value{ 15 | a tibble 16 | } 17 | \description{ 18 | This method glances the model in a parsnip model object, if it exists. 19 | } 20 | -------------------------------------------------------------------------------- /man/glmnet_helpers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/glmnet-engines.R 3 | \name{.check_glmnet_penalty_fit} 4 | \alias{.check_glmnet_penalty_fit} 5 | \alias{.check_glmnet_penalty_predict} 6 | \title{Helper functions for checking the penalty of glmnet models} 7 | \usage{ 8 | .check_glmnet_penalty_fit(x, call = rlang::caller_env()) 9 | 10 | .check_glmnet_penalty_predict( 11 | penalty = NULL, 12 | object, 13 | multi = FALSE, 14 | call = rlang::caller_env() 15 | ) 16 | } 17 | \arguments{ 18 | \item{x}{An object of class \code{model_spec}.} 19 | 20 | \item{penalty}{A penalty value to check.} 21 | 22 | \item{object}{An object of class \code{model_fit}.} 23 | 24 | \item{multi}{A logical indicating if multiple values are allowed.} 25 | } 26 | \description{ 27 | These functions are for developer use. 28 | 29 | \code{.check_glmnet_penalty_fit()} checks that the model specification for fitting a 30 | glmnet model contains a single value. 31 | 32 | \code{.check_glmnet_penalty_predict()} checks that the penalty value used for prediction is valid. 33 | If called by \code{predict()}, it needs to be a single value. Multiple values are 34 | allowed for \code{multi_predict()}. 35 | } 36 | \keyword{internal} 37 | -------------------------------------------------------------------------------- /man/glmnet_helpers_prediction.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/glmnet-engines.R 3 | \name{.organize_glmnet_pred} 4 | \alias{.organize_glmnet_pred} 5 | \title{Organize glmnet predictions} 6 | \usage{ 7 | .organize_glmnet_pred(x, object) 8 | } 9 | \arguments{ 10 | \item{x}{Predictions as returned by the \code{predict()} method for glmnet models.} 11 | 12 | \item{object}{An object of class \code{model_fit}.} 13 | } 14 | \description{ 15 | This function is for developer use and organizes predictions from glmnet 16 | models. 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/keras_activations.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mlp.R 3 | \name{keras_activations} 4 | \alias{keras_activations} 5 | \title{Activation functions for neural networks in keras} 6 | \usage{ 7 | keras_activations() 8 | } 9 | \value{ 10 | A character vector of values. 11 | } 12 | \description{ 13 | Activation functions for neural networks in keras 14 | } 15 | \keyword{internal} 16 | -------------------------------------------------------------------------------- /man/keras_predict_classes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mlp.R 3 | \name{keras_predict_classes} 4 | \alias{keras_predict_classes} 5 | \title{Wrapper for keras class predictions} 6 | \usage{ 7 | keras_predict_classes(object, x) 8 | } 9 | \arguments{ 10 | \item{object}{A keras model fit} 11 | 12 | \item{x}{A data set.} 13 | } 14 | \description{ 15 | Wrapper for keras class predictions 16 | } 17 | \keyword{internal} 18 | -------------------------------------------------------------------------------- /man/knit_engine_docs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/engine_docs.R 3 | \name{knit_engine_docs} 4 | \alias{knit_engine_docs} 5 | \title{Knit engine-specific documentation} 6 | \usage{ 7 | knit_engine_docs(pattern = NULL) 8 | } 9 | \arguments{ 10 | \item{pattern}{A regular expression to specify which files to knit. The 11 | default knits all engine documentation files.} 12 | } 13 | \value{ 14 | A tibble with column \code{file} for the file name and \code{result} (a 15 | character vector that echos the output file name or, when there is 16 | a failure, the error message). 17 | } 18 | \description{ 19 | Knit engine-specific documentation 20 | } 21 | \details{ 22 | This function will check whether the known parsnip extension packages, 23 | engine specific packages, and a few other ancillary packages are installed. 24 | Users will be prompted to install anything required to create the engine 25 | documentation. 26 | } 27 | \keyword{internal} 28 | -------------------------------------------------------------------------------- /man/list_md_problems.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/engine_docs.R 3 | \name{list_md_problems} 4 | \alias{list_md_problems} 5 | \title{Locate and show errors/warnings in engine-specific documentation} 6 | \usage{ 7 | list_md_problems() 8 | } 9 | \value{ 10 | A tibble with column \code{file} for the file name, \code{line} indicating 11 | the line where the error/warning occurred, and \code{problem} showing the 12 | error/warning message. 13 | } 14 | \description{ 15 | Locate and show errors/warnings in engine-specific documentation 16 | } 17 | \keyword{internal} 18 | -------------------------------------------------------------------------------- /man/make_call.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/arguments.R 3 | \name{make_call} 4 | \alias{make_call} 5 | \title{Make a parsnip call expression} 6 | \usage{ 7 | make_call(fun, ns, args, ...) 8 | } 9 | \arguments{ 10 | \item{fun}{A character string of a function name.} 11 | 12 | \item{ns}{A character string of a package name.} 13 | 14 | \item{args}{A named list of argument values.} 15 | } 16 | \value{ 17 | A call. 18 | } 19 | \description{ 20 | Make a parsnip call expression 21 | } 22 | \details{ 23 | The arguments are spliced into the \code{ns::fun()} call. If they are 24 | missing, null, or a single logical, then are not spliced. 25 | } 26 | \keyword{internal} 27 | -------------------------------------------------------------------------------- /man/make_classes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/misc.R 3 | \name{make_classes} 4 | \alias{make_classes} 5 | \title{Prepend a new class} 6 | \usage{ 7 | make_classes(prefix) 8 | } 9 | \arguments{ 10 | \item{prefix}{A character string for a class.} 11 | } 12 | \value{ 13 | A character vector. 14 | } 15 | \description{ 16 | This adds an extra class to a base class of "model_spec". 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/matrix_to_quantile_pred.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/aaa_quantiles.R 3 | \name{matrix_to_quantile_pred} 4 | \alias{matrix_to_quantile_pred} 5 | \title{Reformat quantile predictions} 6 | \usage{ 7 | matrix_to_quantile_pred(x, object) 8 | } 9 | \arguments{ 10 | \item{x}{A matrix of predictions with rows as samples and columns as quantile 11 | levels.} 12 | 13 | \item{object}{A parsnip \code{model_fit} object from a quantile regression model.} 14 | } 15 | \description{ 16 | Reformat quantile predictions 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/max_mtry_formula.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/partykit.R 3 | \name{max_mtry_formula} 4 | \alias{max_mtry_formula} 5 | \title{Determine largest value of mtry from formula. 6 | This function potentially caps the value of \code{mtry} based on a formula and 7 | data set. This is a safe approach for survival and/or multivariate models.} 8 | \usage{ 9 | max_mtry_formula(mtry, formula, data) 10 | } 11 | \arguments{ 12 | \item{mtry}{An initial value of \code{mtry} (which may be too large).} 13 | 14 | \item{formula}{A model formula.} 15 | 16 | \item{data}{The training set (data frame).} 17 | } 18 | \value{ 19 | A value for \code{mtry}. 20 | } 21 | \description{ 22 | Determine largest value of mtry from formula. 23 | This function potentially caps the value of \code{mtry} based on a formula and 24 | data set. This is a safe approach for survival and/or multivariate models. 25 | } 26 | \examples{ 27 | \dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 28 | # should be 9 29 | max_mtry_formula(200, cbind(wt, mpg) ~ ., data = mtcars) 30 | \dontshow{\}) # examplesIf} 31 | } 32 | -------------------------------------------------------------------------------- /man/maybe_matrix.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/convert_data.R 3 | \name{maybe_matrix} 4 | \alias{maybe_matrix} 5 | \alias{maybe_data_frame} 6 | \title{Fuzzy conversions} 7 | \usage{ 8 | maybe_matrix(x) 9 | 10 | maybe_data_frame(x) 11 | } 12 | \arguments{ 13 | \item{x}{A data frame, matrix, or sparse matrix.} 14 | } 15 | \value{ 16 | A data frame, matrix, or sparse matrix. 17 | } 18 | \description{ 19 | These are substitutes for \code{as.matrix()} and \code{as.data.frame()} that leave 20 | a sparse matrix as-is. 21 | } 22 | -------------------------------------------------------------------------------- /man/model_db.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{model_db} 5 | \alias{model_db} 6 | \title{parsnip model specification database} 7 | \value{ 8 | \item{model_db}{a data frame} 9 | } 10 | \description{ 11 | This is used in the RStudio add-in and captures information about mode 12 | specifications in various R packages. 13 | } 14 | \examples{ 15 | \dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 16 | data(model_db) 17 | \dontshow{\}) # examplesIf} 18 | } 19 | \keyword{datasets} 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/model_printer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/print.R 3 | \name{model_printer} 4 | \alias{model_printer} 5 | \title{Print helper for model objects} 6 | \usage{ 7 | model_printer(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A model object.} 11 | 12 | \item{...}{Not currently used.} 13 | } 14 | \description{ 15 | A common format function that prints information about the model object (e.g. 16 | arguments, calls, packages, etc). 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/parsnip-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/parsnip-package.R 3 | \docType{package} 4 | \name{parsnip-package} 5 | \alias{parsnip} 6 | \alias{parsnip-package} 7 | \title{parsnip} 8 | \description{ 9 | The goal of parsnip is to provide a tidy, unified interface to models that 10 | can be used to try a range of models without getting bogged down in the 11 | syntactical minutiae of the underlying packages. 12 | } 13 | \seealso{ 14 | Useful links: 15 | \itemize{ 16 | \item \url{https://github.com/tidymodels/parsnip} 17 | \item \url{https://parsnip.tidymodels.org/} 18 | \item Report bugs at \url{https://github.com/tidymodels/parsnip/issues} 19 | } 20 | 21 | } 22 | \author{ 23 | \strong{Maintainer}: Max Kuhn \email{max@posit.co} 24 | 25 | Authors: 26 | \itemize{ 27 | \item Davis Vaughan \email{davis@posit.co} 28 | } 29 | 30 | Other contributors: 31 | \itemize{ 32 | \item Emil Hvitfeldt \email{emil.hvitfeldt@posit.co} [contributor] 33 | \item Posit Software, PBC (03wc8by49) [copyright holder, funder] 34 | } 35 | 36 | } 37 | \keyword{internal} 38 | -------------------------------------------------------------------------------- /man/parsnip_addin.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_in.R 3 | \name{parsnip_addin} 4 | \alias{parsnip_addin} 5 | \title{Start an RStudio Addin that can write model specifications} 6 | \usage{ 7 | parsnip_addin() 8 | } 9 | \description{ 10 | \code{parsnip_addin()} starts a process in the RStudio IDE Viewer window 11 | that allows users to write code for parsnip model specifications from 12 | various R packages. The new code is written to the current document at the 13 | location of the cursor. 14 | } 15 | -------------------------------------------------------------------------------- /man/prepare_data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/predict.R 3 | \name{prepare_data} 4 | \alias{prepare_data} 5 | \title{Prepare data based on parsnip encoding information} 6 | \usage{ 7 | prepare_data(object, new_data) 8 | } 9 | \arguments{ 10 | \item{object}{A parsnip model object} 11 | 12 | \item{new_data}{A data frame} 13 | } 14 | \value{ 15 | A data frame or matrix 16 | } 17 | \description{ 18 | Prepare data based on parsnip encoding information 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/req_pkgs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/req_pkgs.R 3 | \name{req_pkgs} 4 | \alias{req_pkgs} 5 | \title{Determine required packages for a model} 6 | \usage{ 7 | req_pkgs(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A \link[=model_spec]{model specification} or \link[=model_fit]{fit}.} 11 | 12 | \item{...}{Not used.} 13 | } 14 | \value{ 15 | A character string of package names (if any). 16 | } 17 | \description{ 18 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} 19 | } 20 | \details{ 21 | This function has been deprecated in favor of \code{required_pkgs()}. 22 | } 23 | -------------------------------------------------------------------------------- /man/required_pkgs.model_spec.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/required_pkgs.R 3 | \name{required_pkgs.model_spec} 4 | \alias{required_pkgs.model_spec} 5 | \alias{required_pkgs.model_fit} 6 | \title{Determine required packages for a model} 7 | \usage{ 8 | \method{required_pkgs}{model_spec}(x, infra = TRUE, ...) 9 | 10 | \method{required_pkgs}{model_fit}(x, infra = TRUE, ...) 11 | } 12 | \arguments{ 13 | \item{x}{A \link[=model_spec]{model specification} or \link[=model_fit]{fit}.} 14 | 15 | \item{infra}{Should parsnip itself be included in the result?} 16 | 17 | \item{...}{Not used.} 18 | } 19 | \value{ 20 | A character vector 21 | } 22 | \description{ 23 | Determine required packages for a model 24 | } 25 | \examples{ 26 | \dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 27 | should_fail <- try(required_pkgs(linear_reg(engine = NULL)), silent = TRUE) 28 | should_fail 29 | 30 | linear_reg() |> 31 | set_engine("glmnet") |> 32 | required_pkgs() 33 | 34 | linear_reg() |> 35 | set_engine("glmnet") |> 36 | required_pkgs(infra = FALSE) 37 | 38 | linear_reg() |> 39 | set_engine("lm") |> 40 | fit(mpg ~ ., data = mtcars) |> 41 | required_pkgs() 42 | \dontshow{\}) # examplesIf} 43 | } 44 | -------------------------------------------------------------------------------- /man/rmd/auto_ml_h2o.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| child: aaa.Rmd 3 | #| include: false 4 | ``` 5 | 6 | `r descr_models("auto_ml", "h2o")` 7 | 8 | ## Tuning Parameters 9 | 10 | This model has no tuning parameters. 11 | 12 | Engine arguments of interest 13 | 14 | - `max_runtime_secs` and `max_models`: controls the maximum running time and number of models to build in the automatic process. 15 | 16 | - `exclude_algos` and `include_algos`: a character vector indicating the excluded or included algorithms during model building. To see a full list of supported models, see the details section in [h2o::h2o.automl()]. 17 | 18 | - `validation`: An integer between 0 and 1 specifying the _proportion_ of training data reserved as validation set. This is used by h2o for performance assessment and potential early stopping. 19 | 20 | ## Translation from parsnip to the original package (regression) 21 | 22 | [agua::h2o_train_auto()] is a wrapper around [h2o::h2o.automl()]. 23 | 24 | ```{r} 25 | #| label: h2o-reg 26 | auto_ml() |> 27 | set_engine("h2o") |> 28 | set_mode("regression") |> 29 | translate() 30 | ``` 31 | 32 | 33 | ## Translation from parsnip to the original package (classification) 34 | 35 | ```{r} 36 | #| label: h2o-cls 37 | auto_ml() |> 38 | set_engine("h2o") |> 39 | set_mode("classification") |> 40 | translate() 41 | ``` 42 | 43 | ## Preprocessing requirements 44 | 45 | ```{r} 46 | #| child: template-makes-dummies.Rmd 47 | ``` 48 | 49 | ## Initializing h2o 50 | 51 | ```{r} 52 | #| child: template-h2o-init.Rmd 53 | ``` 54 | 55 | ## Saving fitted model objects 56 | 57 | ```{r} 58 | #| child: template-bundle.Rmd 59 | ``` 60 | -------------------------------------------------------------------------------- /man/rmd/bag_tree_C5.0.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| child: aaa.Rmd 3 | #| include: false 4 | ``` 5 | 6 | `r descr_models("bag_tree", "C5.0")` 7 | 8 | ## Tuning Parameters 9 | 10 | ```{r} 11 | #| label: C5.0-param-info 12 | #| echo: false 13 | defaults <- 14 | tibble::tibble(parsnip = c("min_n"), 15 | default = c("2L")) 16 | 17 | param <- 18 | bag_tree() |> 19 | set_engine("C5.0") |> 20 | set_mode("classification") |> 21 | make_parameter_list(defaults) 22 | ``` 23 | 24 | This model has `r nrow(param)` tuning parameters: 25 | 26 | ```{r} 27 | #| label: C5.0-param-list 28 | #| echo: false 29 | #| results: asis 30 | param$item 31 | ``` 32 | 33 | ## Translation from parsnip to the original package (classification) 34 | 35 | `r uses_extension("bag_tree", "C5.0", "classification")` 36 | 37 | ```{r} 38 | #| label: C5.0-cls 39 | library(baguette) 40 | 41 | bag_tree(min_n = integer()) |> 42 | set_engine("C5.0") |> 43 | set_mode("classification") |> 44 | translate() 45 | ``` 46 | 47 | ## Preprocessing requirements 48 | 49 | ```{r} 50 | #| child: template-tree-split-factors.Rmd 51 | ``` 52 | 53 | ## Case weights 54 | 55 | ```{r} 56 | #| child: template-uses-case-weights.Rmd 57 | ``` 58 | 59 | 60 | ## References 61 | 62 | - Breiman, L. 1996. "Bagging predictors". Machine Learning. 24 (2): 123-140 63 | 64 | - Kuhn, M, and K Johnson. 2013. *Applied Predictive Modeling*. Springer. 65 | 66 | -------------------------------------------------------------------------------- /man/rmd/cubist_rules_Cubist.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| child: aaa.Rmd 3 | #| include: false 4 | ``` 5 | 6 | `r descr_models("cubist_rules", "Cubist")` 7 | 8 | ## Tuning Parameters 9 | 10 | ```{r} 11 | #| label: cubist-param-info 12 | #| echo: false 13 | defaults <- 14 | tibble::tibble(parsnip = c("committees", "neighbors", "max_rules"), 15 | default = c("1L", "0L", "NA_integer")) 16 | 17 | param <- 18 | cubist_rules() |> 19 | set_engine("Cubist") |> 20 | make_parameter_list(defaults) 21 | ``` 22 | 23 | This model has `r nrow(param)` tuning parameters: 24 | 25 | ```{r} 26 | #| label: cubist-param-list 27 | #| echo: false 28 | #| results: asis 29 | param$item 30 | ``` 31 | 32 | 33 | ## Translation from parsnip to the underlying model call (regression) 34 | 35 | `r uses_extension("cubist_rules", "Cubist", "regression")` 36 | 37 | ```{r} 38 | #| label: cubist-reg 39 | library(rules) 40 | 41 | cubist_rules( 42 | committees = integer(1), 43 | neighbors = integer(1), 44 | max_rules = integer(1) 45 | ) |> 46 | set_engine("Cubist") |> 47 | set_mode("regression") |> 48 | translate() 49 | ``` 50 | 51 | ## Preprocessing requirements 52 | 53 | ```{r} 54 | #| child: template-tree-split-factors.Rmd 55 | ``` 56 | 57 | ## References 58 | 59 | - Quinlan R (1992). "Learning with Continuous Classes." Proceedings of the 5th Australian Joint Conference On Artificial Intelligence, pp. 343-348. 60 | 61 | - Quinlan R (1993)."Combining Instance-Based and Model-Based Learning." Proceedings of the Tenth International Conference on Machine Learning, pp. 236-243. 62 | 63 | - Kuhn M and Johnson K (2013). _Applied Predictive Modeling_. Springer. 64 | -------------------------------------------------------------------------------- /man/rmd/decision_tree_C5.0.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| child: aaa.Rmd 3 | #| include: false 4 | ``` 5 | 6 | `r descr_models("decision_tree", "C5.0")` 7 | 8 | ## Tuning Parameters 9 | 10 | ```{r} 11 | #| label: C5.0-param-info 12 | #| echo: false 13 | defaults <- 14 | tibble::tibble(parsnip = c("min_n"), 15 | default = c("2L")) 16 | 17 | param <- 18 | decision_tree() |> 19 | set_engine("C5.0") |> 20 | set_mode("classification") |> 21 | make_parameter_list(defaults) 22 | ``` 23 | 24 | This model has `r nrow(param)` tuning parameters: 25 | 26 | ```{r} 27 | #| label: C5.0-param-list 28 | #| echo: false 29 | #| results: asis 30 | param$item 31 | ``` 32 | 33 | ## Translation from parsnip to the original package (classification) 34 | 35 | ```{r} 36 | #| label: C5.0-cls 37 | decision_tree(min_n = integer()) |> 38 | set_engine("C5.0") |> 39 | set_mode("classification") |> 40 | translate() 41 | ``` 42 | 43 | [C5.0_train()] is a wrapper around [C50::C5.0()] that makes it easier to run this model. 44 | 45 | ## Preprocessing requirements 46 | 47 | ```{r} 48 | #| child: template-tree-split-factors.Rmd 49 | ``` 50 | 51 | ## Case weights 52 | 53 | ```{r} 54 | #| child: template-uses-case-weights.Rmd 55 | ``` 56 | 57 | ## Saving fitted model objects 58 | 59 | ```{r} 60 | #| child: template-butcher.Rmd 61 | ``` 62 | 63 | 64 | ## Examples 65 | 66 | The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#decision-tree-C5.0) for `decision_tree()` with the `"C5.0"` engine. 67 | 68 | ## References 69 | 70 | - Kuhn, M, and K Johnson. 2013. *Applied Predictive Modeling*. Springer. 71 | 72 | -------------------------------------------------------------------------------- /man/rmd/discrim_linear_MASS.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| child: aaa.Rmd 3 | #| include: false 4 | ``` 5 | 6 | `r descr_models("discrim_linear", "MASS")` 7 | 8 | ## Tuning Parameters 9 | 10 | This engine has no tuning parameters. 11 | 12 | ## Translation from parsnip to the original package 13 | 14 | `r uses_extension("discrim_linear", "MASS", "classification")` 15 | 16 | ```{r} 17 | #| label: mass-cls 18 | library(discrim) 19 | 20 | discrim_linear() |> 21 | set_engine("MASS") |> 22 | translate() 23 | ``` 24 | 25 | ## Preprocessing requirements 26 | 27 | ```{r} 28 | #| child: template-makes-dummies.Rmd 29 | ``` 30 | 31 | ```{r} 32 | #| child: template-zv.Rmd 33 | ``` 34 | 35 | ## Case weights 36 | 37 | ```{r} 38 | #| child: template-no-case-weights.Rmd 39 | ``` 40 | 41 | ## References 42 | 43 | - Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer. 44 | -------------------------------------------------------------------------------- /man/rmd/discrim_linear_MASS.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | For this engine, there is a single mode: classification 5 | 6 | ## Tuning Parameters 7 | 8 | This engine has no tuning parameters. 9 | 10 | ## Translation from parsnip to the original package 11 | 12 | The **discrim** extension package is required to fit this model. 13 | 14 | 15 | ``` r 16 | library(discrim) 17 | 18 | discrim_linear() |> 19 | set_engine("MASS") |> 20 | translate() 21 | ``` 22 | 23 | ``` 24 | ## Linear Discriminant Model Specification (classification) 25 | ## 26 | ## Computational engine: MASS 27 | ## 28 | ## Model fit template: 29 | ## MASS::lda(formula = missing_arg(), data = missing_arg()) 30 | ``` 31 | 32 | ## Preprocessing requirements 33 | 34 | 35 | Factor/categorical predictors need to be converted to numeric values (e.g., dummy or indicator variables) for this engine. When using the formula method via \\code{\\link[=fit.model_spec]{fit()}}, parsnip will convert factor columns to indicators. 36 | 37 | 38 | Variance calculations are used in these computations so _zero-variance_ predictors (i.e., with a single unique value) should be eliminated before fitting the model. 39 | 40 | 41 | 42 | ## Case weights 43 | 44 | 45 | The underlying model implementation does not allow for case weights. 46 | 47 | ## References 48 | 49 | - Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer. 50 | -------------------------------------------------------------------------------- /man/rmd/discrim_linear_mda.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| child: aaa.Rmd 3 | #| include: false 4 | ``` 5 | 6 | `r descr_models("discrim_linear", "mda")` 7 | 8 | ## Tuning Parameters 9 | 10 | 11 | ```{r} 12 | #| label: mda-param-info 13 | #| echo: false 14 | defaults <- 15 | tibble::tibble(parsnip = c("penalty"), 16 | default = c("1.0")) 17 | 18 | param <- 19 | discrim_linear() |> 20 | set_engine("mda") |> 21 | make_parameter_list(defaults) 22 | ``` 23 | 24 | This model has `r nrow(param)` tuning parameter: 25 | 26 | ```{r} 27 | #| label: mda-param-list 28 | #| echo: false 29 | #| results: asis 30 | param$item 31 | ``` 32 | 33 | ## Translation from parsnip to the original package 34 | 35 | `r uses_extension("discrim_linear", "mda", "classification")` 36 | 37 | ```{r} 38 | #| label: mda-cls 39 | library(discrim) 40 | 41 | discrim_linear(penalty = numeric(0)) |> 42 | set_engine("mda") |> 43 | translate() 44 | ``` 45 | 46 | ## Preprocessing requirements 47 | 48 | ```{r} 49 | #| child: template-makes-dummies.Rmd 50 | ``` 51 | 52 | ```{r} 53 | #| child: template-zv.Rmd 54 | ``` 55 | 56 | ## Case weights 57 | 58 | ```{r} 59 | #| child: template-uses-case-weights.Rmd 60 | ``` 61 | 62 | ## References 63 | 64 | - Hastie, Tibshirani & Buja (1994) Flexible Discriminant Analysis by Optimal 65 | Scoring, _Journal of the American Statistical Association_, 89:428, 1255-1270 66 | -------------------------------------------------------------------------------- /man/rmd/discrim_linear_sda.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| child: aaa.Rmd 3 | #| include: false 4 | ``` 5 | 6 | `r descr_models("discrim_linear", "sda")` 7 | 8 | ## Tuning Parameters 9 | 10 | This engine has no tuning parameter arguments in [discrim_linear()]. 11 | 12 | However, there are a few engine-specific parameters that can be set or optimized when calling [set_engine()]: 13 | 14 | * `lambda`: the shrinkage parameters for the correlation matrix. This maps to the \pkg{dials} parameter [dials::shrinkage_correlation()]. 15 | 16 | * `lambda.var`: the shrinkage parameters for the predictor variances. This maps to [dials::shrinkage_variance()]. 17 | 18 | * `lambda.freqs`: the shrinkage parameters for the class frequencies. This maps to [dials::shrinkage_frequencies()]. 19 | 20 | * `diagonal`: a logical to make the model covariance diagonal or not. This maps to [dials::diagonal_covariance()]. 21 | 22 | ## Translation from parsnip to the original package 23 | 24 | `r uses_extension("discrim_linear", "sda", "classification")` 25 | 26 | ```{r} 27 | #| label: sda-cls 28 | library(discrim) 29 | 30 | discrim_linear() |> 31 | set_engine("sda") |> 32 | translate() 33 | ``` 34 | 35 | ## Preprocessing requirements 36 | 37 | ```{r} 38 | #| child: template-makes-dummies.Rmd 39 | ``` 40 | 41 | ```{r} 42 | #| child: template-zv.Rmd 43 | ``` 44 | 45 | ## Case weights 46 | 47 | ```{r} 48 | #| child: template-no-case-weights.Rmd 49 | ``` 50 | 51 | ## References 52 | 53 | - Ahdesmaki, A., and K. Strimmer. 2010. Feature selection in omics prediction problems using cat scores and false non-discovery rate control. Ann. Appl. Stat. 4: 503-519. [Preprint](https://arxiv.org/abs/0903.2003). 54 | -------------------------------------------------------------------------------- /man/rmd/discrim_quad_MASS.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| child: aaa.Rmd 3 | #| include: false 4 | ``` 5 | 6 | `r descr_models("discrim_quad", "MASS")` 7 | 8 | ## Tuning Parameters 9 | 10 | This engine has no tuning parameters. 11 | 12 | ## Translation from parsnip to the original package 13 | 14 | `r uses_extension("discrim_quad", "MASS", "classification")` 15 | 16 | ```{r} 17 | #| label: mass-cls 18 | library(discrim) 19 | 20 | discrim_quad() |> 21 | set_engine("MASS") |> 22 | translate() 23 | ``` 24 | 25 | ## Preprocessing requirements 26 | 27 | ```{r} 28 | #| child: template-makes-dummies.Rmd 29 | ``` 30 | 31 | ```{r} 32 | #| child: template-zv-conditional.Rmd 33 | ``` 34 | 35 | ## Case weights 36 | 37 | ```{r} 38 | #| child: template-no-case-weights.Rmd 39 | ``` 40 | 41 | ## References 42 | 43 | - Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer. 44 | -------------------------------------------------------------------------------- /man/rmd/discrim_quad_MASS.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | For this engine, there is a single mode: classification 5 | 6 | ## Tuning Parameters 7 | 8 | This engine has no tuning parameters. 9 | 10 | ## Translation from parsnip to the original package 11 | 12 | The **discrim** extension package is required to fit this model. 13 | 14 | 15 | ``` r 16 | library(discrim) 17 | 18 | discrim_quad() |> 19 | set_engine("MASS") |> 20 | translate() 21 | ``` 22 | 23 | ``` 24 | ## Quadratic Discriminant Model Specification (classification) 25 | ## 26 | ## Computational engine: MASS 27 | ## 28 | ## Model fit template: 29 | ## MASS::qda(formula = missing_arg(), data = missing_arg()) 30 | ``` 31 | 32 | ## Preprocessing requirements 33 | 34 | 35 | Factor/categorical predictors need to be converted to numeric values (e.g., dummy or indicator variables) for this engine. When using the formula method via \\code{\\link[=fit.model_spec]{fit()}}, parsnip will convert factor columns to indicators. 36 | 37 | 38 | Variance calculations are used in these computations within each outcome class. For this reason, _zero-variance_ predictors (i.e., with a single unique value) within each class should be eliminated before fitting the model. 39 | 40 | 41 | 42 | ## Case weights 43 | 44 | 45 | The underlying model implementation does not allow for case weights. 46 | 47 | ## References 48 | 49 | - Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer. 50 | -------------------------------------------------------------------------------- /man/rmd/linear_reg_h2o.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| child: aaa.Rmd 3 | #| include: false 4 | ``` 5 | 6 | `r descr_models("linear_reg", "h2o")` 7 | 8 | ## Tuning Parameters 9 | 10 | ```{r} 11 | #| label: h2o-param-info 12 | #| echo: false 13 | defaults <- 14 | tibble::tibble(parsnip = c("penalty", "mixture"), 15 | default = c("see below", "see below")) 16 | 17 | param <- 18 | linear_reg() |> 19 | set_engine("h2o") |> 20 | make_parameter_list(defaults) 21 | ``` 22 | 23 | This model has `r nrow(param)` tuning parameters: 24 | 25 | ```{r} 26 | #| label: h2o-param-list 27 | #| echo: false 28 | #| results: asis 29 | param$item 30 | ``` 31 | 32 | ```{r} 33 | #| child: template-h2o-glm-penalty.Rmd 34 | #| include: false 35 | ``` 36 | 37 | ## Translation from parsnip to the original package 38 | 39 | [agua::h2o_train_glm()] for `linear_reg()` is a wrapper around [h2o::h2o.glm()] with `family = "gaussian"`. 40 | 41 | 42 | ```{r} 43 | #| label: h2o-csl 44 | linear_reg(penalty = 1, mixture = 0.5) |> 45 | set_engine("h2o") |> 46 | translate() 47 | ``` 48 | 49 | ## Preprocessing requirements 50 | 51 | ```{r} 52 | #| child: template-makes-dummies.Rmd 53 | ``` 54 | 55 | ```{r} 56 | #| child: template-same-scale.Rmd 57 | ``` 58 | 59 | By default, [h2o::h2o.glm()] uses the argument `standardize = TRUE` to center and scale the data. 60 | 61 | ## Initializing h2o 62 | 63 | ```{r} 64 | #| child: template-h2o-init.Rmd 65 | ``` 66 | 67 | ## Saving fitted model objects 68 | 69 | ```{r} 70 | #| child: template-bundle.Rmd 71 | ``` 72 | -------------------------------------------------------------------------------- /man/rmd/multinom_reg_h2o.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| child: aaa.Rmd 3 | #| include: false 4 | ``` 5 | 6 | `r descr_models("multinom_reg", "h2o")` 7 | 8 | ## Tuning Parameters 9 | 10 | ```{r} 11 | #| label: h2o-param-info 12 | #| echo: false 13 | defaults <- 14 | tibble::tibble(parsnip = c("penalty", "mixture"), 15 | default = c("see below", "see below")) 16 | 17 | param <- 18 | multinom_reg() |> 19 | set_engine("h2o") |> 20 | make_parameter_list(defaults) 21 | ``` 22 | 23 | This model has `r nrow(param)` tuning parameters: 24 | 25 | ```{r} 26 | #| label: h2o-param-list 27 | #| echo: false 28 | #| results: asis 29 | param$item 30 | ``` 31 | 32 | ```{r} 33 | #| child: template-h2o-glm-penalty.Rmd 34 | #| include: false 35 | ``` 36 | 37 | ## Translation from parsnip to the original package 38 | 39 | [agua::h2o_train_glm()] for `multinom_reg()` is a wrapper around [h2o::h2o.glm()] with `family = 'multinomial'`. 40 | 41 | ```{r} 42 | #| label: h2o-cls 43 | multinom_reg(penalty = double(1), mixture = double(1)) |> 44 | set_engine("h2o") |> 45 | translate() 46 | ``` 47 | 48 | ## Preprocessing requirements 49 | 50 | ```{r} 51 | #| child: template-makes-dummies.Rmd 52 | ``` 53 | 54 | ```{r} 55 | #| child: template-same-scale.Rmd 56 | ``` 57 | 58 | By default, [h2o::h2o.glm()] uses the argument `standardize = TRUE` to center and scale the data. 59 | 60 | ## Initializing h2o 61 | 62 | ```{r} 63 | #| child: template-h2o-init.Rmd 64 | ``` 65 | -------------------------------------------------------------------------------- /man/rmd/naive_Bayes_klaR.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| child: aaa.Rmd 3 | #| include: false 4 | ``` 5 | 6 | `r descr_models("naive_Bayes", "klaR")` 7 | 8 | ## Tuning Parameters 9 | 10 | 11 | ```{r} 12 | #| label: klaR-param-info 13 | #| echo: false 14 | defaults <- 15 | tibble::tibble(parsnip = c("smoothness", "Laplace"), 16 | default = c("1.0", "0.0")) 17 | 18 | param <- 19 | naive_Bayes() |> 20 | set_engine("klaR") |> 21 | make_parameter_list(defaults) 22 | ``` 23 | 24 | This model has `r nrow(param)` tuning parameter: 25 | 26 | ```{r} 27 | #| label: klaR-param-list 28 | #| echo: false 29 | #| results: asis 30 | param$item 31 | ``` 32 | 33 | Note that the engine argument `usekernel` is set to `TRUE` by default when using the `klaR` engine. 34 | 35 | ## Translation from parsnip to the original package 36 | 37 | `r uses_extension("naive_Bayes", "klaR", "classification")` 38 | 39 | ```{r} 40 | #| label: klaR-cls 41 | library(discrim) 42 | 43 | naive_Bayes(smoothness = numeric(0), Laplace = numeric(0)) |> 44 | set_engine("klaR") |> 45 | translate() 46 | ``` 47 | 48 | ## Preprocessing requirements 49 | 50 | The columns for qualitative predictors should always be represented as factors (as opposed to dummy/indicator variables). When the predictors are factors, the underlying code treats them as multinomial data and appropriately computes their conditional distributions. 51 | 52 | ```{r} 53 | #| child: template-zv.Rmd 54 | ``` 55 | 56 | ## Case weights 57 | 58 | ```{r} 59 | #| child: template-no-case-weights.Rmd 60 | ``` 61 | 62 | ## References 63 | 64 | - Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer. 65 | -------------------------------------------------------------------------------- /man/rmd/no-pooling.md: -------------------------------------------------------------------------------- 1 | ## Predicting new samples 2 | 3 | This model can use subject-specific coefficient estimates to make predictions (i.e. partial pooling). For example, this equation shows the linear predictor ($\eta$) for a random intercept: 4 | 5 | $$ 6 | \eta_{i} = (\beta_0 + b_{0i}) + \beta_1x_{i1} 7 | $$ 8 | 9 | where $i$ denotes the `i`th independent experimental unit (e.g. subject). When the model has seen subject `i`, it can use that subject's data to adjust the _population_ intercept to be more specific to that subjects results. 10 | 11 | What happens when data are being predicted for a subject that was not used in the model fit? In that case, this package uses _only_ the population parameter estimates for prediction: 12 | 13 | $$ 14 | \hat{\eta}_{i'} = \hat{\beta}_0+ \hat{\beta}x_{i'1} 15 | $$ 16 | 17 | Depending on what covariates are in the model, this might have the effect of making the same prediction for all new samples. The population parameters are the "best estimate" for a subject that was not included in the model fit. 18 | 19 | The tidymodels framework deliberately constrains predictions for new data to not use the training set or other data (to prevent information leakage). 20 | 21 | -------------------------------------------------------------------------------- /man/rmd/null-model.Rmd: -------------------------------------------------------------------------------- 1 | # Engine Details 2 | 3 | Engines may have pre-set default arguments when executing the model fit call. 4 | For this type of model, the template of the fit calls are below: 5 | 6 | ## parsnip 7 | 8 | ```{r} 9 | #| label: parsnip-reg 10 | null_model() |> 11 | set_engine("parsnip") |> 12 | set_mode("regression") |> 13 | translate() 14 | ``` 15 | 16 | ```{r} 17 | #| label: parsnip-cls 18 | null_model() |> 19 | set_engine("parsnip") |> 20 | set_mode("classification") |> 21 | translate() 22 | ``` 23 | 24 | -------------------------------------------------------------------------------- /man/rmd/null-model.md: -------------------------------------------------------------------------------- 1 | # Engine Details 2 | 3 | Engines may have pre-set default arguments when executing the model fit call. 4 | For this type of model, the template of the fit calls are below: 5 | 6 | ## parsnip 7 | 8 | 9 | ``` r 10 | null_model() |> 11 | set_engine("parsnip") |> 12 | set_mode("regression") |> 13 | translate() 14 | ``` 15 | 16 | ``` 17 | ## Null Model Specification (regression) 18 | ## 19 | ## Computational engine: parsnip 20 | ## 21 | ## Model fit template: 22 | ## parsnip::nullmodel(x = missing_arg(), y = missing_arg()) 23 | ``` 24 | 25 | 26 | ``` r 27 | null_model() |> 28 | set_engine("parsnip") |> 29 | set_mode("classification") |> 30 | translate() 31 | ``` 32 | 33 | ``` 34 | ## Null Model Specification (classification) 35 | ## 36 | ## Computational engine: parsnip 37 | ## 38 | ## Model fit template: 39 | ## parsnip::nullmodel(x = missing_arg(), y = missing_arg()) 40 | ``` 41 | 42 | -------------------------------------------------------------------------------- /man/rmd/poisson_reg_glm.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| child: aaa.Rmd 3 | #| include: false 4 | ``` 5 | 6 | `r descr_models("poisson_reg", "glm")` 7 | 8 | ## Tuning Parameters 9 | 10 | This engine has no tuning parameters. 11 | 12 | ## Translation from parsnip to the underlying model call (regression) 13 | 14 | `r uses_extension("poisson_reg", "glm", "regression")` 15 | 16 | ```{r} 17 | #| label: glm-reg 18 | library(poissonreg) 19 | 20 | poisson_reg() |> 21 | set_engine("glm") |> 22 | translate() 23 | ``` 24 | 25 | ## Preprocessing requirements 26 | 27 | ```{r} 28 | #| child: template-makes-dummies.Rmd 29 | ``` 30 | 31 | ## Case weights 32 | 33 | ```{r} 34 | #| child: template-uses-case-weights.Rmd 35 | ``` 36 | 37 | 38 | ## Case weights 39 | 40 | ```{r} 41 | #| child: template-uses-case-weights.Rmd 42 | ``` 43 | 44 | _However_, the documentation in [stats::glm()] assumes that is specific type of case weights are being used:"Non-NULL weights can be used to indicate that different observations have different dispersions (with the values in weights being inversely proportional to the dispersions); or equivalently, when the elements of weights are positive integers `w_i`, that each response `y_i` is the mean of `w_i` unit-weight observations. For a binomial GLM prior weights are used to give the number of trials when the response is the proportion of successes: they would rarely be used for a Poisson GLM." 45 | 46 | If frequency weights are being used in your application, the [glm_grouped()] model (and corresponding engine) may be more appropriate. 47 | 48 | ## Saving fitted model objects 49 | 50 | ```{r} 51 | #| child: template-butcher.Rmd 52 | ``` 53 | -------------------------------------------------------------------------------- /man/rmd/poisson_reg_h2o.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| child: aaa.Rmd 3 | #| include: false 4 | ``` 5 | 6 | `r descr_models("poisson_reg", "h2o")` 7 | 8 | ## Tuning Parameters 9 | 10 | ```{r} 11 | #| label: h2o-param-info 12 | #| echo: false 13 | defaults <- 14 | tibble::tibble(parsnip = c("penalty", "mixture"), 15 | default = c("see below", "see below")) 16 | 17 | param <- 18 | poisson_reg() |> 19 | set_engine("h2o") |> 20 | make_parameter_list(defaults) 21 | ``` 22 | 23 | This model has `r nrow(param)` tuning parameters: 24 | 25 | ```{r} 26 | #| label: h2o-param-list 27 | #| echo: false 28 | #| results: asis 29 | param$item 30 | ``` 31 | 32 | ```{r} 33 | #| child: template-h2o-glm-penalty.Rmd 34 | #| include: false 35 | ``` 36 | 37 | ## Translation from parsnip to the original package 38 | 39 | [agua::h2o_train_glm()] for `poisson_reg()` is a wrapper around [h2o::h2o.glm()] with `family = 'poisson'`. 40 | 41 | `r uses_extension("poisson_reg", "h2o", "regression")` 42 | 43 | ```{r} 44 | #| label: h2o-csl 45 | library(poissonreg) 46 | 47 | poisson_reg(penalty = double(1), mixture = double(1)) |> 48 | set_engine("h2o") |> 49 | translate() 50 | ``` 51 | 52 | ## Preprocessing requirements 53 | 54 | ```{r} 55 | #| child: template-makes-dummies.Rmd 56 | ``` 57 | 58 | ```{r} 59 | #| child: template-same-scale.Rmd 60 | ``` 61 | 62 | By default, `h2o::h2o.glm()` uses the argument `standardize = TRUE` to center and scale all numerical columns. 63 | 64 | 65 | ## Initializing h2o 66 | 67 | ```{r} 68 | #| child: template-h2o-init.Rmd 69 | ``` 70 | 71 | ## Saving fitted model objects 72 | 73 | ```{r} 74 | #| child: template-bundle.Rmd 75 | ``` 76 | -------------------------------------------------------------------------------- /man/rmd/survival_reg_flexsurvspline.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| child: aaa.Rmd 3 | #| include: false 4 | ``` 5 | 6 | `r descr_models("survival_reg", "flexsurvspline")` 7 | 8 | ## Tuning Parameters 9 | 10 | This model has one engine-specific tuning parameter: 11 | 12 | * `k`: Number of knots in the spline. The default is `k = 0`. 13 | 14 | ## Translation from parsnip to the original package 15 | 16 | `r uses_extension("survival_reg", "flexsurvspline", "censored regression")` 17 | 18 | ```{r} 19 | #| label: flexsurvspline-creg 20 | library(censored) 21 | 22 | survival_reg() |> 23 | set_engine("flexsurvspline") |> 24 | set_mode("censored regression") |> 25 | translate() 26 | ``` 27 | 28 | ## Other details 29 | 30 | The main interface for this model uses the formula method since the model specification typically involved the use of [survival::Surv()]. 31 | 32 | For this engine, stratification cannot be specified via [`survival::strata()`], please see [flexsurv::flexsurvspline()] for alternative specifications. 33 | 34 | ```{r} 35 | #| child: template-survival-mean.Rmd 36 | ``` 37 | 38 | ## Case weights 39 | 40 | ```{r} 41 | #| child: template-uses-case-weights.Rmd 42 | ``` 43 | 44 | 45 | ## Saving fitted model objects 46 | 47 | ```{r} 48 | #| child: template-butcher.Rmd 49 | ``` 50 | 51 | 52 | ## References 53 | 54 | - Jackson, C. 2016. `flexsurv`: A Platform for Parametric Survival Modeling in R. _Journal of Statistical Software_, 70(8), 1 - 33. 55 | -------------------------------------------------------------------------------- /man/rmd/template-bundle.Rmd: -------------------------------------------------------------------------------- 1 | Models fitted with this engine may require native serialization methods to be properly saved and/or passed between R sessions. To learn more about preparing fitted models for serialization, see the bundle package. 2 | -------------------------------------------------------------------------------- /man/rmd/template-butcher.Rmd: -------------------------------------------------------------------------------- 1 | This model object contains data that are not required to make predictions. When saving the model for the purpose of prediction, the size of the saved object might be substantially reduced by using functions from the [butcher](https://butcher.tidymodels.org) package. 2 | -------------------------------------------------------------------------------- /man/rmd/template-censored-linear-predictor.Rmd: -------------------------------------------------------------------------------- 1 | Since risk regression and parametric survival models are modeling different characteristics (e.g. relative hazard versus event time), their linear predictors will be going in opposite directions. 2 | 3 | For example, for parametric models, the linear predictor _increases with time_. For proportional hazards models the linear predictor _decreases with time_ (since hazard is increasing). As such, the linear predictors for these two quantities will have opposite signs. 4 | 5 | tidymodels does not treat different models differently when computing performance metrics. To standardize across model types, the default for proportional hazards models is to have _increasing values with time_. As a result, the sign of the linear predictor will be the opposite of the value produced by the `predict()` method in the engine package. 6 | 7 | This behavior can be changed by using the `increasing` argument when calling `predict()` on a \pkg{parsnip} model object. 8 | -------------------------------------------------------------------------------- /man/rmd/template-early-stopping.Rmd: -------------------------------------------------------------------------------- 1 | The `stop_iter()` argument allows the model to prematurely stop training if the objective function does not improve within `early_stop` iterations. 2 | 3 | The best way to use this feature is in conjunction with an _internal validation set_. To do this, pass the `validation` parameter of \\code{\\link[=xgb_train]{xgb_train()}} via the parsnip \\code{\\link[=set_engine]{set_engine()}} function. This is the proportion of the training set that should be reserved for measuring performance (and stopping early). 4 | 5 | If the model specification has `early_stop >= trees`, `early_stop` is converted to `trees - 1` and a warning is issued. 6 | -------------------------------------------------------------------------------- /man/rmd/template-gee-silent.Rmd: -------------------------------------------------------------------------------- 1 | The `gee::gee()` function always prints out warnings and output even when `silent = TRUE`. The parsnip `"gee"` engine, by contrast, silences all console output coming from `gee::gee()`, even if `silent = FALSE`. 2 | -------------------------------------------------------------------------------- /man/rmd/template-h2o-glm-penalty.Rmd: -------------------------------------------------------------------------------- 1 | By default, when not given a fixed `penalty`, [h2o::h2o.glm()] uses a heuristic approach to select the optimal value of `penalty` based on training data. Setting the engine parameter `lambda_search` to `TRUE` enables an efficient version of the grid search, see more details at . 2 | 3 | The choice of `mixture` depends on the engine parameter `solver`, which is automatically chosen given training data and the specification of other model parameters. When `solver` is set to `'L-BFGS'`, `mixture` defaults to 0 (ridge regression) and 0.5 otherwise. 4 | -------------------------------------------------------------------------------- /man/rmd/template-h2o-init.Rmd: -------------------------------------------------------------------------------- 1 | To use the h2o engine with tidymodels, please run `h2o::h2o.init()` first. By default, This connects R to the local h2o server. This needs to be done in every new R session. You can also connect to a remote h2o server with an IP address, for more details see [h2o::h2o.init()]. 2 | 3 | You can control the number of threads in the thread pool used by h2o with the `nthreads` argument. By default, it uses all CPUs on the host. This is different from the usual parallel processing mechanism in tidymodels for tuning, while tidymodels parallelizes over resamples, h2o parallelizes over hyperparameter combinations for a given resample. 4 | 5 | h2o will automatically shut down the local h2o instance started by R when R is terminated. To manually stop the h2o server, run `h2o::h2o.shutdown()`. 6 | -------------------------------------------------------------------------------- /man/rmd/template-makes-dummies.Rmd: -------------------------------------------------------------------------------- 1 | Factor/categorical predictors need to be converted to numeric values (e.g., dummy or indicator variables) for this engine. When using the formula method via \\code{\\link[=fit.model_spec]{fit()}}, parsnip will convert factor columns to indicators. 2 | -------------------------------------------------------------------------------- /man/rmd/template-mtry-prop.Rmd: -------------------------------------------------------------------------------- 1 | The `mtry` argument denotes the number of predictors that will be randomly sampled at each split when creating tree models. 2 | 3 | Some engines, such as `"xgboost"`, `"xrf"`, and `"lightgbm"`, interpret their analogue to the `mtry` argument as the _proportion_ of predictors that will be randomly sampled at each split rather than the _count_. In some settings, such as when tuning over preprocessors that influence the number of predictors, this parameterization is quite helpful---interpreting `mtry` as a proportion means that `[0, 1]` is always a valid range for that parameter, regardless of input data. 4 | 5 | parsnip and its extensions accommodate this parameterization using the `counts` argument: a logical indicating whether `mtry` should be interpreted as the number of predictors that will be randomly sampled at each split. `TRUE` indicates that `mtry` will be interpreted in its sense as a count, `FALSE` indicates that the argument will be interpreted in its sense as a proportion. 6 | 7 | `mtry` is a main model argument for \\code{\\link[=boost_tree]{boost_tree()}} and \\code{\\link[=rand_forest]{rand_forest()}}, and thus should not have an engine-specific interface. So, regardless of engine, `counts` defaults to `TRUE`. For engines that support the proportion interpretation (currently `"xgboost"` and `"xrf"`, via the rules package, and `"lightgbm"` via the bonsai package) the user can pass the `counts = FALSE` argument to `set_engine()` to supply `mtry` values within `[0, 1]`. 8 | -------------------------------------------------------------------------------- /man/rmd/template-no-case-weights.Rmd: -------------------------------------------------------------------------------- 1 | The underlying model implementation does not allow for case weights. 2 | -------------------------------------------------------------------------------- /man/rmd/template-no-pooling.Rmd: -------------------------------------------------------------------------------- 1 | ## Predicting new samples 2 | 3 | This model can use subject-specific coefficient estimates to make predictions (i.e. partial pooling). For example, this equation shows the linear predictor (`\eta`) for a random intercept: 4 | 5 | ``` 6 | \eta_{i} = (\beta_0 + b_{0i}) + \beta_1x_{i1} 7 | ``` 8 | 9 | where `i` denotes the `i`th independent experimental unit (e.g. subject). When the model has seen subject `i`, it can use that subject's data to adjust the _population_ intercept to be more specific to that subjects results. 10 | 11 | What happens when data are being predicted for a subject that was not used in the model fit? In that case, this package uses _only_ the population parameter estimates for prediction: 12 | 13 | ``` 14 | \hat{\eta}_{i'} = \hat{\beta}_0+ \hat{\beta}x_{i'1} 15 | ``` 16 | 17 | Depending on what covariates are in the model, this might have the effect of making the same prediction for all new samples. The population parameters are the "best estimate" for a subject that was not included in the model fit. 18 | 19 | The tidymodels framework deliberately constrains predictions for new data to not use the training set or other data (to prevent information leakage). 20 | 21 | -------------------------------------------------------------------------------- /man/rmd/template-same-scale.Rmd: -------------------------------------------------------------------------------- 1 | Predictors should have the same scale. One way to achieve this is to center and 2 | scale each so that each predictor has mean zero and a variance of one. 3 | -------------------------------------------------------------------------------- /man/rmd/template-spark-notes.Rmd: -------------------------------------------------------------------------------- 1 | For models created using the `"spark"` engine, there are several things to consider. 2 | 3 | * Only the formula interface to via `fit()` is available; using `fit_xy()` will generate an error. 4 | * The predictions will always be in a Spark table format. The names will be the same as documented but without the dots. 5 | * There is no equivalent to factor columns in Spark tables so class predictions are returned as character columns. 6 | * To retain the model object for a new R session (via `save()`), the `model$fit` element of the parsnip object should be serialized via `ml_save(object$fit)` and separately saved to disk. In a new session, the object can be reloaded and reattached to the parsnip object. 7 | -------------------------------------------------------------------------------- /man/rmd/template-survival-mean.Rmd: -------------------------------------------------------------------------------- 1 | 2 | Predictions of type `"time"` are predictions of the mean survival time. 3 | -------------------------------------------------------------------------------- /man/rmd/template-survival-median.Rmd: -------------------------------------------------------------------------------- 1 | 2 | Predictions of type `"time"` are predictions of the median survival time. 3 | -------------------------------------------------------------------------------- /man/rmd/template-tree-split-factors.Rmd: -------------------------------------------------------------------------------- 1 | This engine does not require any special encoding of the predictors. Categorical predictors can be partitioned into groups of factor levels (e.g. `{a, c}` vs `{b, d}`) when splitting at a node. Dummy variables are not required for this model. 2 | -------------------------------------------------------------------------------- /man/rmd/template-uses-case-weights.Rmd: -------------------------------------------------------------------------------- 1 | This model can utilize case weights during model fitting. To use them, see the documentation in [case_weights] and the examples on `tidymodels.org`. 2 | 3 | The `fit()` and `fit_xy()` arguments have arguments called `case_weights` that expect vectors of case weights. 4 | -------------------------------------------------------------------------------- /man/rmd/template-uses-sparse-data.Rmd: -------------------------------------------------------------------------------- 1 | This model can utilize sparse data during model fitting and prediction. Both sparse matrices such as dgCMatrix from the `Matrix` package and sparse tibbles from the `sparsevctrs` package are supported. See [sparse_data] for more information. 2 | -------------------------------------------------------------------------------- /man/rmd/template-zv-conditional.Rmd: -------------------------------------------------------------------------------- 1 | Variance calculations are used in these computations within each outcome class. For this reason, _zero-variance_ predictors (i.e., with a single unique value) within each class should be eliminated before fitting the model. 2 | 3 | 4 | -------------------------------------------------------------------------------- /man/rmd/template-zv.Rmd: -------------------------------------------------------------------------------- 1 | Variance calculations are used in these computations so _zero-variance_ predictors (i.e., with a single unique value) should be eliminated before fitting the model. 2 | 3 | 4 | -------------------------------------------------------------------------------- /man/set_tf_seed.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mlp.R 3 | \name{set_tf_seed} 4 | \alias{set_tf_seed} 5 | \title{Set seed in R and TensorFlow at the same time} 6 | \usage{ 7 | set_tf_seed(seed) 8 | } 9 | \arguments{ 10 | \item{seed}{1 integer value.} 11 | } 12 | \description{ 13 | Some Keras models requires seeds to be set in both R and TensorFlow to 14 | achieve reproducible results. This function sets these seeds at the same 15 | time using version appropriate functions. 16 | } 17 | \keyword{internal} 18 | -------------------------------------------------------------------------------- /man/show_call.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/misc.R 3 | \name{show_call} 4 | \alias{show_call} 5 | \title{Print the model call} 6 | \usage{ 7 | show_call(object) 8 | } 9 | \arguments{ 10 | \item{object}{A "model_spec" object.} 11 | } 12 | \value{ 13 | A character string. 14 | } 15 | \description{ 16 | Print the model call 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/show_engines.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/engines.R 3 | \name{show_engines} 4 | \alias{show_engines} 5 | \title{Display currently available engines for a model} 6 | \usage{ 7 | show_engines(x) 8 | } 9 | \arguments{ 10 | \item{x}{The name of a parsnip model (e.g., "linear_reg", "mars", etc.)} 11 | } 12 | \value{ 13 | A tibble. 14 | } 15 | \description{ 16 | The possible engines for a model can depend on what packages are loaded. 17 | Some parsnip extension add engines to existing models. For example, 18 | the \pkg{poissonreg} package adds additional engines for the \code{\link[=poisson_reg]{poisson_reg()}} 19 | model and these are not available unless \pkg{poissonreg} is loaded. 20 | } 21 | \examples{ 22 | \dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 23 | show_engines("linear_reg") 24 | \dontshow{\}) # examplesIf} 25 | } 26 | -------------------------------------------------------------------------------- /man/sparse_data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sparsevctrs.R 3 | \name{sparse_data} 4 | \alias{sparse_data} 5 | \title{Using sparse data with parsnip} 6 | \description{ 7 | You can figure out whether a given model engine supports sparse data by 8 | calling \code{get_encoding("name of model")} and looking at the \code{allow_sparse_x} 9 | column. 10 | } 11 | \details{ 12 | Using sparse data for model fitting and prediction shouldn't require any 13 | additional configurations. Just pass in a sparse matrix such as dgCMatrix 14 | from the \code{Matrix} package or a sparse tibble from the sparsevctrs package 15 | to the data argument of \code{\link[=fit]{fit()}}, \code{\link[=fit_xy]{fit_xy()}}, and \code{\link[=predict]{predict()}}. 16 | 17 | Models that don't support sparse data will try to convert to non-sparse data 18 | with warnings. If conversion isn’t possible, an informative error will be 19 | thrown. 20 | } 21 | -------------------------------------------------------------------------------- /man/stan_conf_int.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/misc.R 3 | \name{stan_conf_int} 4 | \alias{stan_conf_int} 5 | \title{Wrapper for stan confidence intervals} 6 | \usage{ 7 | stan_conf_int(object, newdata) 8 | } 9 | \arguments{ 10 | \item{object}{A stan model fit} 11 | 12 | \item{newdata}{A data set.} 13 | } 14 | \description{ 15 | Wrapper for stan confidence intervals 16 | } 17 | \keyword{internal} 18 | -------------------------------------------------------------------------------- /man/tidy._LiblineaR.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tidy_liblinear.R 3 | \name{tidy._LiblineaR} 4 | \alias{tidy._LiblineaR} 5 | \title{tidy methods for LiblineaR models} 6 | \usage{ 7 | \method{tidy}{`_LiblineaR`}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A fitted parsnip model that used the \code{LiblineaR} engine.} 11 | 12 | \item{...}{Not used} 13 | } 14 | \value{ 15 | A tibble with columns \code{term} and \code{estimate}. 16 | } 17 | \description{ 18 | \code{tidy()} methods for the various \code{LiblineaR} models that return the 19 | coefficients from the parsnip model fit. 20 | } 21 | \keyword{internal} 22 | -------------------------------------------------------------------------------- /man/tidy._elnet.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tidy_glmnet.R 3 | \name{tidy._elnet} 4 | \alias{tidy._elnet} 5 | \alias{tidy._lognet} 6 | \alias{tidy._multnet} 7 | \alias{tidy._fishnet} 8 | \alias{tidy._coxnet} 9 | \title{tidy methods for glmnet models} 10 | \usage{ 11 | \method{tidy}{`_elnet`}(x, penalty = NULL, ...) 12 | 13 | \method{tidy}{`_lognet`}(x, penalty = NULL, ...) 14 | 15 | \method{tidy}{`_multnet`}(x, penalty = NULL, ...) 16 | 17 | \method{tidy}{`_fishnet`}(x, penalty = NULL, ...) 18 | 19 | \method{tidy}{`_coxnet`}(x, penalty = NULL, ...) 20 | } 21 | \arguments{ 22 | \item{x}{A fitted parsnip model that used the \code{glmnet} engine.} 23 | 24 | \item{penalty}{A \emph{single} numeric value. If none is given, the value specified 25 | in the model specification is used.} 26 | 27 | \item{...}{Not used} 28 | } 29 | \value{ 30 | A tibble with columns \code{term}, \code{estimate}, and \code{penalty}. When a 31 | multinomial mode is used, an additional \code{class} column is included. 32 | } 33 | \description{ 34 | \code{tidy()} methods for the various \code{glmnet} models that return the coefficients 35 | for the specific penalty value used by the parsnip model fit. 36 | } 37 | \keyword{internal} 38 | -------------------------------------------------------------------------------- /man/tidy.model_fit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tidy.R 3 | \name{tidy.model_fit} 4 | \alias{tidy.model_fit} 5 | \title{Turn a parsnip model object into a tidy tibble} 6 | \usage{ 7 | \method{tidy}{model_fit}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{An object to be converted into a tidy \code{\link[tibble:tibble]{tibble::tibble()}}.} 11 | 12 | \item{...}{Additional arguments to tidying method.} 13 | } 14 | \value{ 15 | a tibble 16 | } 17 | \description{ 18 | This method tidies the model in a parsnip model object, if it exists. 19 | } 20 | -------------------------------------------------------------------------------- /man/tidy.nullmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/nullmodel.R 3 | \name{tidy.nullmodel} 4 | \alias{tidy.nullmodel} 5 | \title{Tidy method for null models} 6 | \usage{ 7 | \method{tidy}{nullmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A \code{nullmodel} object.} 11 | 12 | \item{...}{Not used.} 13 | } 14 | \value{ 15 | A tibble with column \code{value}. 16 | } 17 | \description{ 18 | Return the results of \code{nullmodel} as a tibble 19 | } 20 | \examples{ 21 | \dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 22 | 23 | nullmodel(mtcars[,-1], mtcars$mpg) |> tidy() 24 | \dontshow{\}) # examplesIf} 25 | } 26 | \keyword{internal} 27 | -------------------------------------------------------------------------------- /man/type_sum.model_spec.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/type_sum.R 3 | \name{type_sum.model_spec} 4 | \alias{type_sum.model_spec} 5 | \alias{type_sum.model_fit} 6 | \title{Succinct summary of parsnip object} 7 | \usage{ 8 | \method{type_sum}{model_spec}(x) 9 | 10 | \method{type_sum}{model_fit}(x) 11 | } 12 | \arguments{ 13 | \item{x}{A \code{model_spec} or \code{model_fit} object to summarise.} 14 | } 15 | \value{ 16 | A character value. 17 | } 18 | \description{ 19 | \code{type_sum} controls how objects are shown when inside tibble 20 | columns. 21 | } 22 | \details{ 23 | For \code{model_spec} objects, the summary is "\verb{spec[?]}" 24 | or "\verb{spec[+]}". The former indicates that either the model 25 | mode has not been declared or that the specification has 26 | \code{tune()} parameters. Otherwise, the latter is shown. 27 | 28 | For fitted models, either "\code{fit[x]}" or "\verb{fit[+]}" are used 29 | where the "x" implies that the model fit failed in some way. 30 | } 31 | \keyword{internal} 32 | -------------------------------------------------------------------------------- /man/update_model_info_file.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/engine_docs.R 3 | \name{update_model_info_file} 4 | \alias{update_model_info_file} 5 | \title{Save information about models} 6 | \usage{ 7 | update_model_info_file(path = "inst/models.tsv") 8 | } 9 | \arguments{ 10 | \item{path}{A character string for the location of the tab delimited file.} 11 | } 12 | \description{ 13 | This function writes a tab delimited file to the package to capture 14 | information about the known models. This information includes packages in 15 | the tidymodels GitHub repository as well as packages that are known to work 16 | well with tidymodels packages (e.g. not only \pkg{parsnip} but also 17 | \pkg{tune}, etc.). There may be more model definitions in other extension 18 | packages that are not included here. 19 | 20 | These data are used to document engines for each model function man page. 21 | } 22 | \details{ 23 | See our 24 | \href{https://tidymodels.github.io/model-implementation-principles/}{model implementation guidelines} 25 | on best practices for modeling and modeling packages. 26 | 27 | It is highly recommended that the known parsnip extension packages are loaded. 28 | The unexported \pkg{parsnip} function \code{extensions()} will list these. 29 | } 30 | \keyword{internal} 31 | -------------------------------------------------------------------------------- /man/varying.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/varying.R 3 | \name{varying} 4 | \alias{varying} 5 | \title{A placeholder function for argument values} 6 | \usage{ 7 | varying() 8 | } 9 | \description{ 10 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} 11 | 12 | \code{\link[=varying]{varying()}} is used when a parameter will be specified at a later date. 13 | } 14 | \keyword{internal} 15 | -------------------------------------------------------------------------------- /parsnip.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | ProjectId: 7f6c9ff5-6b9a-4235-8666-12db5ef65d49 3 | 4 | RestoreWorkspace: No 5 | SaveWorkspace: No 6 | AlwaysSaveHistory: Default 7 | 8 | EnableCodeIndexing: Yes 9 | UseSpacesForTab: Yes 10 | NumSpacesForTab: 2 11 | Encoding: UTF-8 12 | 13 | RnwWeave: knitr 14 | LaTeX: pdfLaTeX 15 | 16 | AutoAppendNewline: Yes 17 | StripTrailingWhitespace: Yes 18 | 19 | BuildType: Package 20 | PackageUseDevtools: Yes 21 | PackageInstallArgs: --no-multiarch --with-keep.source 22 | PackageRoxygenize: rd,collate,namespace 23 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(parsnip) 3 | 4 | test_check("parsnip") 5 | 6 | -------------------------------------------------------------------------------- /tests/testthat/README.md: -------------------------------------------------------------------------------- 1 | Note that some functionality in parsnip is tested outside of the package. Due to a high degree of dependencies, many additional tests are in the [extratexts](https://github.com/tidymodels/extratests/tree/main/tests/testthat) repository. These are run nightly with CRAN and Github versions of parsnip as well as other tidymodels packages. 2 | 3 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/arguments.md: -------------------------------------------------------------------------------- 1 | # warns informatively about protected arguments 2 | 3 | Code 4 | .res <- check_eng_args(args = list(a = 1, b = 2, c = 3, e = 5), obj = obj, 5 | core_args = core_args) 6 | Condition 7 | Warning: 8 | The arguments `a`, `b`, and `c` cannot be manually modified and were removed. 9 | 10 | --- 11 | 12 | Code 13 | .res <- check_eng_args(args = list(b = 2, c = 3, e = 5), obj = obj, core_args = core_args) 14 | Condition 15 | Warning: 16 | The arguments `b` and `c` cannot be manually modified and were removed. 17 | 18 | --- 19 | 20 | Code 21 | .res <- check_eng_args(args = list(c = 3, e = 5), obj = obj, core_args = core_args) 22 | Condition 23 | Warning: 24 | The argument `c` cannot be manually modified and was removed. 25 | 26 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/augment.md: -------------------------------------------------------------------------------- 1 | # regression models 2 | 3 | Code 4 | augment(reg_form, head(mtcars[, -1])) 5 | Condition 6 | Error in `augment()`: 7 | ! Unknown mode "depeche". 8 | i Model mode should be one of "classification", "regression", "censored regression", or "quantile regression". 9 | 10 | # quantile regression models 11 | 12 | Code 13 | set_mode(linear_reg(), "quantile regression", quantile_levels = probs_1) 14 | Output 15 | Linear Regression Model Specification (quantile regression) 16 | 17 | Computational engine: lm 18 | 19 | Message 20 | Quantile levels: 0.2, 0.4, 0.6, 0.8, and 1. 21 | 22 | --- 23 | 24 | Code 25 | set_mode(linear_reg(), "regression", quantile_levels = probs_1) 26 | Condition 27 | Warning: 28 | `quantile_levels` is only used when the mode is "quantile regression". 29 | Output 30 | Linear Regression Model Specification (regression) 31 | 32 | Computational engine: lm 33 | 34 | 35 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/boost_tree.md: -------------------------------------------------------------------------------- 1 | # check_args() works 2 | 3 | Code 4 | spec <- set_mode(set_engine(boost_tree(trees = -1), "xgboost"), 5 | "classification") 6 | fit(spec, class ~ ., hpc) 7 | Condition 8 | Error in `fit()`: 9 | ! `trees` must be a whole number larger than or equal to 0 or `NULL`, not the number -1. 10 | 11 | --- 12 | 13 | Code 14 | spec <- set_mode(set_engine(boost_tree(sample_size = -10), "xgboost"), 15 | "classification") 16 | fit(spec, class ~ ., hpc) 17 | Condition 18 | Error in `fit()`: 19 | ! `sample_size` must be a number between 0 and 1 or `NULL`, not the number -10. 20 | 21 | --- 22 | 23 | Code 24 | spec <- set_mode(set_engine(boost_tree(tree_depth = -10), "xgboost"), 25 | "classification") 26 | fit(spec, class ~ ., hpc) 27 | Condition 28 | Error in `fit()`: 29 | ! `tree_depth` must be a whole number larger than or equal to 0 or `NULL`, not the number -10. 30 | 31 | --- 32 | 33 | Code 34 | spec <- set_mode(set_engine(boost_tree(min_n = -10), "xgboost"), 35 | "classification") 36 | fit(spec, class ~ ., hpc) 37 | Condition 38 | Error in `fit()`: 39 | ! `min_n` must be a whole number larger than or equal to 0 or `NULL`, not the number -10. 40 | 41 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/case-weights.md: -------------------------------------------------------------------------------- 1 | # case weights with formula method -- unregistered model spec 2 | 3 | Code 4 | fit(bag_mars("regression"), Sale_Price ~ Longitude + Latitude, data = ames, 5 | case_weights = wts) 6 | Condition 7 | Error in `case_weights_allowed()`: 8 | ! Error in getting model information for model bag_mars with engine earth and mode regression. 9 | 10 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/condense_control.md: -------------------------------------------------------------------------------- 1 | # condense_control works 2 | 3 | Code 4 | condense_control(control_parsnip(), ctrl) 5 | Condition 6 | Error: 7 | ! a object cannot be coerced to a object. 8 | i The arguments `allow_par` and `anotherone` are missing. 9 | 10 | --- 11 | 12 | Code 13 | control_test(ctrl) 14 | Condition 15 | Error in `control_test()`: 16 | ! a object cannot be coerced to a object. 17 | i The arguments `allow_par` and `anotherone` are missing. 18 | 19 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/engines.md: -------------------------------------------------------------------------------- 1 | # NULL engines 2 | 3 | Code 4 | set_engine(nearest_neighbor(), NULL) 5 | Condition 6 | Error in `set_engine()`: 7 | ! Missing engine. Possible mode/engine combinations are: classification {kknn} and regression {kknn}. 8 | 9 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/nearest_neighbor.md: -------------------------------------------------------------------------------- 1 | # updating 2 | 3 | Code 4 | update(set_engine(nearest_neighbor(neighbors = 5), "kknn", scale = FALSE), 5 | neighbors = tune(), scale = tune()) 6 | Output 7 | K-Nearest Neighbor Model Specification (unknown mode) 8 | 9 | Main Arguments: 10 | neighbors = tune() 11 | 12 | Engine-Specific Arguments: 13 | scale = tune() 14 | 15 | Computational engine: kknn 16 | 17 | 18 | # bad input 19 | 20 | Code 21 | nearest_neighbor(mode = "reallyunknown") 22 | Condition 23 | Error in `nearest_neighbor()`: 24 | ! "reallyunknown" is not a known mode for model `nearest_neighbor()`. 25 | 26 | # check_args() works 27 | 28 | Code 29 | spec <- set_mode(set_engine(nearest_neighbor(neighbors = -1), "kknn"), 30 | "classification") 31 | fit(spec, class ~ ., hpc) 32 | Condition 33 | Error in `fit()`: 34 | ! `neighbors` must be a whole number larger than or equal to 0 or `NULL`, not the number -1. 35 | 36 | --- 37 | 38 | Code 39 | spec <- set_mode(set_engine(nearest_neighbor(weight_func = 2), "kknn"), 40 | "classification") 41 | fit(spec, class ~ ., hpc) 42 | Condition 43 | Error in `fit()`: 44 | ! `weight_func` must be a single string or `NULL`, not the number 2. 45 | 46 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/packages.md: -------------------------------------------------------------------------------- 1 | # required packages 2 | 3 | Code 4 | expect_equal(req_pkgs(glmn), "glmnet") 5 | Condition 6 | Error: 7 | ! `req_pkgs()` was deprecated in parsnip 0.1.8 and is now defunct. 8 | i Please use `required_pkgs()` instead. 9 | 10 | --- 11 | 12 | Code 13 | expect_equal(req_pkgs(lm_fit), "stats") 14 | Condition 15 | Error: 16 | ! `req_pkgs()` was deprecated in parsnip 0.1.8 and is now defunct. 17 | i Please use `required_pkgs()` instead. 18 | 19 | # missing packages 20 | 21 | Code 22 | predict(mars_model, mtcars[1:3, -1]) 23 | Condition 24 | Error in `predict()`: 25 | ! Please install the rootveggie package to use this engine. 26 | 27 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/partykit.md: -------------------------------------------------------------------------------- 1 | # fit ctree models 2 | 3 | `weights` should be an integer vector with size the same as the number of rows of `data`. 4 | 5 | # fit cforest models 6 | 7 | `weights` should be a numeric vector with size the same as the number of rows of `data`. 8 | 9 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/rand_forest.md: -------------------------------------------------------------------------------- 1 | # updating 2 | 3 | Code 4 | update(set_engine(rand_forest(mode = "regression", mtry = 2), "randomForest", 5 | sampsize = 10), mtry = tune(), sampsize = tune()) 6 | Output 7 | Random Forest Model Specification (regression) 8 | 9 | Main Arguments: 10 | mtry = tune() 11 | 12 | Engine-Specific Arguments: 13 | sampsize = tune() 14 | 15 | Computational engine: randomForest 16 | 17 | 18 | # bad input 19 | 20 | Code 21 | res <- translate(set_engine(rand_forest(mode = "classification"), NULL)) 22 | Condition 23 | Error in `set_engine()`: 24 | ! Missing engine. Possible mode/engine combinations are: classification {ranger, randomForest, spark} and regression {ranger, randomForest, spark}. 25 | 26 | --- 27 | 28 | Code 29 | rand_forest(mode = "time series") 30 | Condition 31 | Error in `rand_forest()`: 32 | ! "time series" is not a known mode for model `rand_forest()`. 33 | 34 | --- 35 | 36 | Code 37 | translate(set_engine(rand_forest(mode = "classification"), "wat?")) 38 | Condition 39 | Error in `set_engine()`: 40 | x Engine "wat?" is not supported for `rand_forest()` 41 | i See `show_engines("rand_forest")`. 42 | 43 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/standalone-survival.md: -------------------------------------------------------------------------------- 1 | # .filter_eval_time() 2 | 3 | Code 4 | parsnip:::.filter_eval_time(times_duplicated) 5 | Condition 6 | Warning: 7 | There were 11 inappropriate evaluation time points that were removed. They were: 8 | * 11 duplicate values. 9 | Output 10 | [1] 0 1 2 3 4 5 6 7 8 9 10 11 | 12 | --- 13 | 14 | Code 15 | parsnip:::.filter_eval_time(-1) 16 | Condition 17 | Error: 18 | ! There were no usable evaluation times (finite, non-missing, and >= 0). 19 | 20 | --- 21 | 22 | Code 23 | parsnip:::.filter_eval_time(times_remove_plural) 24 | Condition 25 | Warning: 26 | There were 3 inappropriate evaluation time points that were removed. They were: 27 | * 1 missing value. 28 | * 1 infinite value. 29 | * 1 negative value. 30 | Output 31 | [1] 0 1 2 3 4 5 6 7 8 9 10 32 | 33 | --- 34 | 35 | Code 36 | parsnip:::.filter_eval_time(times_remove_singular) 37 | Condition 38 | Warning: 39 | There was 1 inappropriate evaluation time point that was removed. It was: 40 | * 1 negative value. 41 | Output 42 | [1] 0 1 2 3 4 5 6 7 8 9 10 43 | 44 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/surv_reg.md: -------------------------------------------------------------------------------- 1 | # updating 2 | 3 | Code 4 | update(set_engine(surv_reg(), "flexsurv", cl = 0.99), cl = tune()) 5 | Output 6 | Parametric Survival Regression Model Specification (regression) 7 | 8 | Engine-Specific Arguments: 9 | cl = tune() 10 | 11 | Computational engine: flexsurv 12 | 13 | 14 | # bad input 15 | 16 | Code 17 | surv_reg(mode = ", classification") 18 | Condition 19 | Error in `surv_reg()`: 20 | ! ", classification" is not a known mode for model `surv_reg()`. 21 | 22 | --- 23 | 24 | Code 25 | translate(set_engine(surv_reg(), "wat")) 26 | Condition 27 | Error in `set_engine()`: 28 | x Engine "wat" is not supported for `surv_reg()` 29 | i See `show_engines("surv_reg")`. 30 | 31 | --- 32 | 33 | Code 34 | res <- translate(set_engine(surv_reg(), NULL)) 35 | Condition 36 | Error in `set_engine()`: 37 | ! Missing engine. Possible mode/engine combinations are: regression {flexsurv, survival}. 38 | 39 | # deprecation warning 40 | 41 | Code 42 | surv_reg() 43 | Condition 44 | Warning: 45 | `surv_reg()` was deprecated in parsnip 0.1.6. 46 | i Please use `survival_reg()` instead. 47 | Output 48 | Parametric Survival Regression Model Specification (regression) 49 | 50 | Computational engine: survival 51 | 52 | 53 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/surv_reg_flexsurv.md: -------------------------------------------------------------------------------- 1 | # flexsurv execution 2 | 3 | Code 4 | res <- fit_xy(surv_basic, x = lung[, "age", drop = FALSE], y = lung$time, 5 | control = ctrl) 6 | Condition 7 | Error in `fit_xy()`: 8 | ! Survival models must use the formula interface. 9 | 10 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/surv_reg_survreg.md: -------------------------------------------------------------------------------- 1 | # survival execution 2 | 3 | Code 4 | res <- fit_xy(surv_basic, x = lung[, c("age", "sex")], y = lung$time, control = ctrl) 5 | Condition 6 | Error in `fit_xy()`: 7 | ! Survival models must use the formula interface. 8 | 9 | -------------------------------------------------------------------------------- /tests/testthat/helper-extract_parameter_set.R: -------------------------------------------------------------------------------- 1 | check_parameter_set_tibble <- function(x) { 2 | expect_equal(names(x), c("name", "id", "source", "component", "component_id", "object")) 3 | expect_equal(class(x$name), "character") 4 | expect_equal(class(x$id), "character") 5 | expect_equal(class(x$source), "character") 6 | expect_equal(class(x$component), "character") 7 | expect_equal(class(x$component_id), "character") 8 | expect_true(!any(duplicated(x$id))) 9 | 10 | expect_equal(class(x$object), "list") 11 | obj_check <- purrr::map_lgl(x$object, \(x) inherits(x, "param") | all(is.na(x))) 12 | expect_true(all(obj_check)) 13 | 14 | invisible(TRUE) 15 | } 16 | -------------------------------------------------------------------------------- /tests/testthat/mars_model.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidymodels/parsnip/6d4c68477ef81a9a7fe044cd628b3d80e451fe3b/tests/testthat/mars_model.RData -------------------------------------------------------------------------------- /tests/testthat/test-aaaa.R: -------------------------------------------------------------------------------- 1 | # keras is pretty tenacious about writing output to the R session. By default 2 | # this gets inserted into the test results. To make this less hideous, we 3 | # try to trigger the output here so that it shows up at the top of the testing. 4 | 5 | library(testthat) 6 | 7 | # setting keras environment 8 | Sys.setenv(TF_CPP_MIN_LOG_LEVEL = '3') 9 | k_bk <- try(keras:::backend(), silent = TRUE) 10 | -------------------------------------------------------------------------------- /tests/testthat/test-adds.R: -------------------------------------------------------------------------------- 1 | skip_if_not_installed("modeldata") 2 | 3 | hpc <- hpc_data[1:150, c(2:5, 8)] 4 | 5 | # ------------------------------------------------------------------------------ 6 | 7 | test_that('adding row indicies', { 8 | hpc_2 <- hpc |> add_rowindex() 9 | expect_true(nrow(hpc_2) == 150) 10 | expect_true(sum(names(hpc_2) == ".row") == 1) 11 | expect_true(is.integer(hpc_2$.row)) 12 | 13 | mtcar_2 <- dplyr::as_tibble(mtcars) |> dplyr::slice(0) |> add_rowindex() 14 | expect_true(nrow(mtcar_2) == 0) 15 | expect_true(sum(names(mtcar_2) == ".row") == 1) 16 | expect_true(is.integer(mtcar_2$.row)) 17 | 18 | expect_snapshot(error = TRUE, as.matrix(mtcars) |> add_rowindex()) 19 | }) 20 | -------------------------------------------------------------------------------- /tests/testthat/test-arguments.R: -------------------------------------------------------------------------------- 1 | test_that("warns informatively about protected arguments", { 2 | obj <- list(protect = c("a", "b")) 3 | core_args <- c("c", "d") 4 | 5 | expect_snapshot( 6 | .res <- check_eng_args( 7 | args = list(a = 1, b = 2, c = 3, e = 5), 8 | obj = obj, 9 | core_args = core_args 10 | ) 11 | ) 12 | 13 | expect_named(.res, "e") 14 | 15 | expect_snapshot( 16 | .res <- check_eng_args( 17 | args = list(b = 2, c = 3, e = 5), 18 | obj = obj, 19 | core_args = core_args 20 | ) 21 | ) 22 | 23 | expect_named(.res, "e") 24 | 25 | expect_snapshot( 26 | .res <- check_eng_args( 27 | args = list(c = 3, e = 5), 28 | obj = obj, 29 | core_args = core_args 30 | ) 31 | ) 32 | 33 | expect_named(.res, "e") 34 | 35 | expect_warning( 36 | check_eng_args( 37 | args = list(a = 1, b = 2, c = 3, e = 5), 38 | obj = obj, 39 | core_args = core_args 40 | ), 41 | class = "parsnip_protected_arg_warning" 42 | ) 43 | }) 44 | -------------------------------------------------------------------------------- /tests/testthat/test-bag_mars.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {baguette} 3 | # https://github.com/tidymodels/baguette 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-bag_mlp.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {baguette} 3 | # https://github.com/tidymodels/baguette 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-bag_tree.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {baguette} 3 | # https://github.com/tidymodels/baguette 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-bart.R: -------------------------------------------------------------------------------- 1 | test_that("check_args() works", { 2 | # Here for completeness, no checking is done 3 | expect_true(TRUE) 4 | }) 5 | -------------------------------------------------------------------------------- /tests/testthat/test-c5_rules.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {rules} 3 | # https://github.com/tidymodels/rules 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-condense_control.R: -------------------------------------------------------------------------------- 1 | test_that("condense_control works", { 2 | ctrl <- control_parsnip() 3 | 4 | expect_equal( 5 | condense_control(ctrl, ctrl), 6 | ctrl 7 | ) 8 | 9 | ctrl$allow_par <- TRUE 10 | ctrl$catch <- TRUE 11 | 12 | expect_equal( 13 | condense_control(ctrl, control_parsnip()), 14 | control_parsnip(catch = TRUE) 15 | ) 16 | 17 | ctrl$anotherone <- 2 18 | expect_snapshot(error = TRUE, 19 | condense_control(control_parsnip(), ctrl) 20 | ) 21 | 22 | # Emulate being called from one of the upstream control_* functions 23 | control_test <- function(control = control_parsnip()) { 24 | control <- parsnip::condense_control(control_parsnip(), control) 25 | invisible(control) 26 | } 27 | expect_snapshot(error = TRUE, control_test(ctrl)) 28 | }) 29 | -------------------------------------------------------------------------------- /tests/testthat/test-cubist_rules.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {rules} 3 | # https://github.com/tidymodels/rules 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-default_engines.R: -------------------------------------------------------------------------------- 1 | test_that('check default engines', { 2 | expect_equal(boost_tree()$engine, "xgboost") 3 | expect_equal(decision_tree()$engine, "rpart") 4 | expect_equal(linear_reg()$engine, "lm") 5 | expect_equal(logistic_reg()$engine, "glm") 6 | expect_equal(mars()$engine, "earth") 7 | expect_equal(mlp()$engine, "nnet") 8 | expect_equal(multinom_reg()$engine, "nnet") 9 | expect_equal(nearest_neighbor()$engine, "kknn") 10 | expect_equal(proportional_hazards()$engine, "survival") 11 | expect_equal(rand_forest()$engine, "ranger") 12 | expect_equal(survival_reg()$engine, "survival") 13 | expect_equal(svm_linear()$engine, "LiblineaR") 14 | expect_equal(svm_poly()$engine, "kernlab") 15 | expect_equal(svm_rbf()$engine, "kernlab") 16 | }) 17 | -------------------------------------------------------------------------------- /tests/testthat/test-discrim_flexible.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {discrim} 3 | # https://github.com/tidymodels/discrim 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-discrim_linear.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {discrim} 3 | # https://github.com/tidymodels/discrim 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-discrim_quad.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {discrim} 3 | # https://github.com/tidymodels/discrim 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-discrim_regularized.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {discrim} 3 | # https://github.com/tidymodels/discrim 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-engines.R: -------------------------------------------------------------------------------- 1 | test_that("NULL engines", { 2 | # See issue https://github.com/tidymodels/parsnip/issues/1242 3 | 4 | expect_snapshot( 5 | set_engine(nearest_neighbor(), NULL), 6 | error = TRUE 7 | ) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test-glm_grouped.R: -------------------------------------------------------------------------------- 1 | test_that('correct results for glm_grouped()', { 2 | ucb_weighted <- as.data.frame(UCBAdmissions) 3 | ucb_weighted$Freq <- as.integer(ucb_weighted$Freq) 4 | 5 | ucb_long <- tidyr::uncount(ucb_weighted, Freq) 6 | 7 | ungrouped <- glm(Admit ~ Gender + Dept, data = ucb_long, family = binomial) 8 | 9 | expect_no_condition( 10 | grouped <- glm_grouped(Admit ~ Gender + Dept, data = ucb_weighted, weights = ucb_weighted$Freq) 11 | ) 12 | 13 | expect_equal(grouped$df.null, 11) 14 | }) 15 | -------------------------------------------------------------------------------- /tests/testthat/test-naive_Bayes.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {discrim} 3 | # https://github.com/tidymodels/discrim 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-nearest_neighbor.R: -------------------------------------------------------------------------------- 1 | test_that('updating', { 2 | expect_snapshot( 3 | nearest_neighbor(neighbors = 5) |> 4 | set_engine("kknn", scale = FALSE) |> 5 | update(neighbors = tune(), scale = tune()) 6 | ) 7 | }) 8 | 9 | test_that('bad input', { 10 | expect_snapshot(error = TRUE, nearest_neighbor(mode = "reallyunknown")) 11 | }) 12 | 13 | test_that('check_args() works', { 14 | skip_if_not_installed("kknn") 15 | skip_if_not_installed("modeldata") 16 | 17 | hpc <- hpc_data[1:150, c(2:5, 8)] 18 | 19 | expect_snapshot( 20 | error = TRUE, 21 | { 22 | spec <- nearest_neighbor(neighbors = -1) |> 23 | set_engine("kknn") |> 24 | set_mode("classification") 25 | fit(spec, class ~ ., hpc) 26 | } 27 | ) 28 | expect_snapshot( 29 | error = TRUE, 30 | { 31 | spec <- nearest_neighbor(weight_func = 2) |> 32 | set_engine("kknn") |> 33 | set_mode("classification") 34 | fit(spec, class ~ ., hpc) 35 | } 36 | ) 37 | }) 38 | -------------------------------------------------------------------------------- /tests/testthat/test-packages.R: -------------------------------------------------------------------------------- 1 | 2 | load(test_path("mars_model.RData")) 3 | 4 | # ------------------------------------------------------------------------------ 5 | 6 | test_that('required packages', { 7 | rlang::local_options(lifecycle_verbosity = "quiet") 8 | 9 | glmn <- 10 | linear_reg() |> 11 | set_engine("glmnet") 12 | expect_equal(required_pkgs(glmn), c("parsnip", "glmnet")) 13 | expect_equal(required_pkgs(glmn, infra = FALSE), c("glmnet")) 14 | 15 | expect_snapshot(error = TRUE, { 16 | expect_equal(req_pkgs(glmn), "glmnet") 17 | }) 18 | 19 | lm_fit <- 20 | linear_reg() |> 21 | set_engine("lm") |> 22 | fit(mpg ~ ., data = mtcars) 23 | 24 | expect_equal(required_pkgs(lm_fit), c("parsnip", "stats")) 25 | expect_equal(required_pkgs(lm_fit, infra = FALSE), c("stats")) 26 | 27 | expect_snapshot(error = TRUE, { 28 | expect_equal(req_pkgs(lm_fit), "stats") 29 | }) 30 | }) 31 | 32 | # ------------------------------------------------------------------------------ 33 | 34 | test_that('missing packages', { 35 | skip_if_not_installed("earth") 36 | 37 | has_earth <- parsnip:::is_installed("earth") 38 | 39 | if (has_earth) { 40 | expect_no_condition(predict(mars_model, mtcars[1:3, -1])) 41 | 42 | } else { 43 | expect_snapshot(error = TRUE, predict(mars_model, mtcars[1:3, -1])) 44 | expect_true(any(names(sessionInfo()$loadedOnly) == "earth")) 45 | } 46 | mars_model$spec$method$libs <- "rootveggie" 47 | expect_snapshot(error = TRUE, predict(mars_model, mtcars[1:3, -1])) 48 | 49 | }) 50 | 51 | -------------------------------------------------------------------------------- /tests/testthat/test-pls.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {plsmod} 3 | # https://github.com/tidymodels/plsmod 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-poisson_reg.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {poissonreg} 3 | # https://github.com/tidymodels/poissonreg 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-print.R: -------------------------------------------------------------------------------- 1 | test_that("model spec print methods work (whole game)", { 2 | expect_snapshot(svm_poly()) 3 | expect_snapshot(boost_tree(mtry = 5)) 4 | expect_snapshot(rand_forest() |> set_mode("regression")) 5 | expect_snapshot(logistic_reg() |> set_engine("glmnet", penalty = .5)) 6 | expect_snapshot(mlp() |> set_mode("classification") |> translate()) 7 | }) 8 | 9 | test_that("`print_model_spec()` handles args correctly", { 10 | lr <- linear_reg() 11 | class(lr)[1] <- "beep" 12 | 13 | expect_snapshot(print_model_spec(linear_reg())) 14 | expect_snapshot(print_model_spec(lr)) 15 | expect_snapshot(print_model_spec(lr, cls = "boop")) 16 | expect_snapshot(print_model_spec(lr, cls = "boop", desc = "Boop")) 17 | }) 18 | 19 | test_that("`get_model_desc()` retrieves/creates model description well", { 20 | expect_equal(get_model_desc("linear_reg"), "Linear Regression") 21 | expect_equal(get_model_desc("boost_tree"), "Boosted Tree") 22 | expect_equal(get_model_desc("boost_tree"), 23 | model_descs$desc[model_descs$cls == "boost_tree"]) 24 | 25 | expect_equal(get_model_desc("goofy new class"), "goofy new class") 26 | expect_equal(get_model_desc("goofy_new_class"), "goofy new class") 27 | expect_equal(get_model_desc("goofy.new_class"), "goofy new class") 28 | expect_equal(get_model_desc("goofy.new.class"), "goofy new class") 29 | }) 30 | -------------------------------------------------------------------------------- /tests/testthat/test-proportional_hazards.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {censored} 3 | # https://github.com/tidymodels/censored 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-rand_forest.R: -------------------------------------------------------------------------------- 1 | 2 | test_that('updating', { 3 | expect_snapshot( 4 | rand_forest(mode = "regression", mtry = 2) |> 5 | set_engine("randomForest", sampsize = 10) |> 6 | update(mtry = tune(), sampsize = tune()) 7 | ) 8 | }) 9 | 10 | test_that('bad input', { 11 | expect_snapshot(res <- 12 | translate(rand_forest(mode = "classification") |> 13 | set_engine(NULL)), 14 | error = TRUE) 15 | expect_snapshot(error = TRUE, rand_forest(mode = "time series")) 16 | expect_snapshot(error = TRUE, translate(rand_forest(mode = "classification") |> set_engine("wat?"))) 17 | }) 18 | 19 | test_that("check_args() works", { 20 | # Here for completeness, no checking is done 21 | expect_true(TRUE) 22 | }) 23 | -------------------------------------------------------------------------------- /tests/testthat/test-rule_fit.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {rules} 3 | # https://github.com/tidymodels/rules 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-standalone-survival.R: -------------------------------------------------------------------------------- 1 | test_that(".filter_eval_time()", { 2 | times_basic <- 0:10 3 | expect_equal( 4 | parsnip:::.filter_eval_time(times_basic), 5 | times_basic 6 | ) 7 | 8 | times_dont_reorder <- c(10, 1:9) 9 | expect_equal( 10 | parsnip:::.filter_eval_time(times_dont_reorder), 11 | times_dont_reorder 12 | ) 13 | 14 | expect_null(parsnip:::.filter_eval_time(NULL)) 15 | 16 | times_duplicated <- c(times_basic, times_basic) 17 | expect_snapshot( 18 | parsnip:::.filter_eval_time(times_duplicated) 19 | ) 20 | 21 | expect_snapshot(error = TRUE, parsnip:::.filter_eval_time(-1)) 22 | 23 | times_remove_plural <- c(Inf, NA, -3, times_basic) 24 | expect_snapshot(parsnip:::.filter_eval_time(times_remove_plural)) 25 | 26 | times_remove_singular <- c(-3, times_basic) 27 | expect_snapshot(parsnip:::.filter_eval_time(times_remove_singular)) 28 | }) 29 | -------------------------------------------------------------------------------- /tests/testthat/test-surv_reg.R: -------------------------------------------------------------------------------- 1 | test_that('updating', { 2 | rlang::local_options(lifecycle_verbosity = "quiet") 3 | 4 | expect_snapshot( 5 | surv_reg() |> 6 | set_engine("flexsurv", cl = 0.99) |> 7 | update(cl = tune()) 8 | ) 9 | }) 10 | 11 | test_that('bad input', { 12 | rlang::local_options(lifecycle_verbosity = "quiet") 13 | 14 | expect_snapshot(error = TRUE, surv_reg(mode = ", classification")) 15 | expect_snapshot(error = TRUE, translate(surv_reg() |> set_engine("wat"))) 16 | expect_snapshot(res <- translate(surv_reg() |> set_engine(NULL)), error = TRUE) 17 | }) 18 | 19 | test_that("deprecation warning", { 20 | rlang::local_options(lifecycle_verbosity = "warning") 21 | expect_snapshot(surv_reg()) 22 | }) 23 | -------------------------------------------------------------------------------- /tests/testthat/test-surv_reg_survreg.R: -------------------------------------------------------------------------------- 1 | 2 | 3 | # ------------------------------------------------------------------------------ 4 | 5 | test_that('survival execution', { 6 | skip_if_not_installed("survival") 7 | rlang::local_options(lifecycle_verbosity = "quiet") 8 | surv_basic <- surv_reg() |> set_engine("survival") 9 | surv_lnorm <- surv_reg(dist = "lognormal") |> set_engine("survival") 10 | 11 | expect_no_condition( 12 | res <- fit( 13 | surv_basic, 14 | survival::Surv(time, status) ~ age + sex, 15 | data = lung, 16 | control = ctrl 17 | ) 18 | ) 19 | 20 | expect_no_condition( 21 | res <- fit( 22 | surv_lnorm, 23 | survival::Surv(time) ~ age + sex, 24 | data = lung, 25 | control = ctrl 26 | ) 27 | ) 28 | expect_snapshot( 29 | error = TRUE, 30 | res <- fit_xy( 31 | surv_basic, 32 | x = lung[, c("age", "sex")], 33 | y = lung$time, 34 | control = ctrl 35 | ) 36 | ) 37 | }) 38 | 39 | test_that('survival prediction', { 40 | skip_if_not_installed("survival") 41 | 42 | rlang::local_options(lifecycle_verbosity = "quiet") 43 | surv_basic <- surv_reg() |> set_engine("survival") 44 | surv_lnorm <- surv_reg(dist = "lognormal") |> set_engine("survival") 45 | 46 | res <- fit( 47 | surv_basic, 48 | survival::Surv(time, status) ~ age + sex, 49 | data = lung, 50 | control = ctrl 51 | ) 52 | exp_pred <- predict(extract_fit_engine(res), head(lung)) 53 | exp_pred <- tibble(.pred = unname(exp_pred)) 54 | expect_equal(exp_pred, predict(res, head(lung))) 55 | }) 56 | 57 | 58 | -------------------------------------------------------------------------------- /tests/testthat/test-survival-censoring-weights.R: -------------------------------------------------------------------------------- 1 | test_that("probability truncation via trunc_probs()", { 2 | probs <- seq(0, 1, length.out = 5) 3 | 4 | probs_trunc_001 <- parsnip:::trunc_probs(probs, trunc = 0.01) 5 | expect_equal(probs_trunc_001[1], 0.01) 6 | expect_equal(probs_trunc_001[2:5], probs[2:5]) 7 | 8 | probs_trunc_04 <- parsnip:::trunc_probs(probs, trunc = 0.4) 9 | data_derived_trunc <- min(probs[probs > 0]) / 2 10 | expect_equal(probs_trunc_04[1], data_derived_trunc) 11 | expect_equal(probs_trunc_04[2:5], probs[2:5]) 12 | 13 | probs_trunc_04_na <- parsnip:::trunc_probs(c(NA, probs), 0.4) 14 | expect_identical(probs_trunc_04_na[1], NA_real_) 15 | expect_equal(probs_trunc_04_na[2], data_derived_trunc) 16 | expect_equal(probs_trunc_04_na[3:6], probs[2:5]) 17 | 18 | probs <- (1:200)/200 19 | expect_identical( 20 | parsnip:::trunc_probs(probs, trunc = 0.01), 21 | probs 22 | ) 23 | }) 24 | -------------------------------------------------------------------------------- /tests/testthat/test-survival_reg.R: -------------------------------------------------------------------------------- 1 | test_that("testing", { 2 | # Testing is done in {censored} 3 | # https://github.com/tidymodels/censored 4 | 5 | expect_true(TRUE) 6 | }) -------------------------------------------------------------------------------- /tests/testthat/test-tunable.R: -------------------------------------------------------------------------------- 1 | test_that('brulee has mixture object', { 2 | skip_if_not_installed("brulee") 3 | # for issue 1236 4 | mlp_spec <- 5 | mlp( 6 | hidden_units = tune(), 7 | activation = tune(), 8 | penalty = tune(), 9 | learn_rate = tune(), 10 | epoch = 2000 11 | ) |> 12 | set_mode("regression") |> 13 | set_engine("brulee", 14 | stop_iter = tune(), 15 | mixture = tune(), 16 | rate_schedule = tune()) 17 | 18 | brulee_res <- tunable(mlp_spec) 19 | 20 | expect_true( 21 | length(brulee_res$call_info[brulee_res$name == "mixture"]) > 0 22 | ) 23 | }) 24 | -------------------------------------------------------------------------------- /vignettes/articles/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | 4 | /.quarto/ 5 | -------------------------------------------------------------------------------- /vignettes/articles/template-cls-multi-class.R: -------------------------------------------------------------------------------- 1 | #' We'll predict the island where the penguins were observed with two variables in the same unit (mm): bill length and bill depth. 2 | 3 | #+ results = "hide", messages = FALSE 4 | library(tidymodels) 5 | tidymodels_prefer() 6 | data(penguins) 7 | 8 | penguins <- penguins |> select(island, starts_with("bill_")) 9 | penguins_train <- penguins[-c(21, 153, 31, 277, 1), ] 10 | penguins_test <- penguins[ c(21, 153, 31, 277, 1), ] 11 | -------------------------------------------------------------------------------- /vignettes/articles/template-cls-two-class.R: -------------------------------------------------------------------------------- 1 | #' The example data has two predictors and an outcome with two classes. Both predictors are in the same units. 2 | 3 | #+ results = "hide", messages = FALSE 4 | library(tidymodels) 5 | tidymodels_prefer() 6 | data(two_class_dat) 7 | 8 | data_train <- two_class_dat[-(1:10), ] 9 | data_test <- two_class_dat[ 1:10 , ] 10 | -------------------------------------------------------------------------------- /vignettes/articles/template-reg-chicago.R: -------------------------------------------------------------------------------- 1 | #' We'll model the ridership on the Chicago elevated trains as a function of the 14 day lagged ridership at two stations. The two predictors are in the same units (rides per day/1000) and do not need to be normalized. 2 | 3 | #' All but the last week of data are used for training. The last week will be predicted after the model is fit. 4 | 5 | #+ results = "hide", messages = FALSE 6 | library(tidymodels) 7 | tidymodels_prefer() 8 | data(Chicago) 9 | 10 | n <- nrow(Chicago) 11 | Chicago <- Chicago |> select(ridership, Clark_Lake, Quincy_Wells) 12 | 13 | Chicago_train <- Chicago[1:(n - 7), ] 14 | Chicago_test <- Chicago[(n - 6):n, ] 15 | 16 | 17 | -------------------------------------------------------------------------------- /vignettes/articles/template-reg-sacramento.R: -------------------------------------------------------------------------------- 1 | #' We'll model the relationship between the cost of a house in Sacramento CA and the square footage of a property. 2 | 3 | #' A few rows were randomly held out for illustrating prediction. 4 | 5 | #+ results = "hide", messages = FALSE 6 | library(tidymodels) 7 | tidymodels_prefer() 8 | 9 | sac_holdout <- c(90L, 203L, 264L, 733L, 771L) 10 | sac_train <- Sacramento[-sac_holdout, ] 11 | sac_test <- Sacramento[ sac_holdout, ] 12 | --------------------------------------------------------------------------------