model_support: Methods for extending anchors model support

Description Usage Arguments Value Supported Models

Description

In order to have 'anchors' support for your model of choice 'anchors' needs to be able to get predictions from the model in a standardised way, and it needs to be able to know whether it is a classification or regression model. For the former it calls the 'predict_model()' generic which the user is free to supply methods for without overriding the standard 'predict()' method. For the latter the model must respond to the 'model_type()' generic.

Usage

1
2
3
predict_model(x, newdata, type, ...)

model_type(x, ...)

Arguments

x

A model object

newdata

The new observations to predict

type

Either ''raw'‘ to indicate predicted values, or '’prob'' to indicate class probabilities

...

passed on to 'predict' method

Value

A data.frame in the case of ‘predict_model()'. If 'type = ’raw'' it will contain one column named ''Response'' holding the predicted values. If ‘type = ’prob'' it will contain a column for each of the possible classes named after the class, each column holding the probability score for class membership. For ‘model_type()' a character string. Either '’regression'' or ''classification'' is currently supported.

Supported Models

Out of the box, 'anchors' supports the following model objects:

- 'WrappedModel' from mlr - 'H2OModel' from h2o - 'lda' from MASS (used for low-dependency examples)

If your model is not one of the above you'll need to implement support yourself. For that you'll need to implement a 'predict_model()' method and potentially a 'model_type()' method (if the latter is omitted the model should be wrapped in [as_classifier()]/[as_regressor()], everytime it is used in [anchors()]).


viadee/anchorsOnR documentation built on Nov. 22, 2019, 5:24 p.m.