5) Recalling a Logistic Regression Model

This Blog entry is from the Logistic Regression section in Learn R.

It is fairly self-explanatory to deploy a logistic model, recall is performed in the same manner as a linear regression model and as described beforehand.  As with the lm() product, the glm() model has a predict.gml() function to create a prediction for all values in a data frame.  The signature bears stark resemblance to that of the predict.lm() function:

AutomaticLogisticRegression <- predict.glm(LogisticRegressionModel,FraudRisk)
1.png

Run the line of script to console:

2.png

It can be seen that a new vector has been created in the environment pane which will contain the predictions for each entry in the FraudRisk Data Frame:

3.png

For completeness, merge the newly created vector into the FraudRisk data frame:

FraudRisk <- mutate(FraudRisk, AutomaticLogisticRegression)
4.png

Run the line of script to console:

5.png