optimizeModelWeight: Optimize weight on ensemble of 2 supervised models

Description Usage Arguments Value Examples

Description

This function creates a weighted average of predictions from two models and evaluates F1, precision, recall, auc or c for each combination of the models to determine the best weights for each.

Usage

1
optimizeModelWeight(pred1, pred2, actual, steps = 50, cutoff = 0.5)

Arguments

pred1

numeric vector of probabilities, prediction from model 1

pred2

numeric vector of probabilities, prediction from model 2

actual

vector of 1s and 0s. The target variable test data

steps

number, high numbers compute a more exhaustive combination of model weights

cutoff

Cutoff used to demarcate predictions into positive or negative class.

ytest,

vector of the target variable from test data. (0s and 1s)

jitterPlot

TRUE or FALSE. Jitters points on plot when TRUE

Value

data.frame of results

Examples

1
2
3
4
5
require('Hmisc')
fit_glm1 <- glm(am~cyl, data=mtcars, family=binomial(logit))
fit_glm2 <- glm(am~disp, data=mtcars, family=binomial(logit))
ow <- optimizeModelWeight(fit_glm1$fitted.values, fit_glm2$fitted.values, actual=fit_glm1$model$am)
plot(ow$weights, ow$precision, type='l', xlab='weight on model 1')

brooksandrew/Rsenal documentation built on May 13, 2019, 7:50 a.m.