Get metric from a prediction model
get_metric.Rd
Extracts a specified metric from a prediction model.
Arguments
- prediction_model
A dataframe with predicted values appended to target_test_df.
- metric
The name of the metric to assess performance of the prediction model. Supported metrics include "rmse", "rsq", and "mae".
- target_variable
The name of the target variable of the prediction model.
Examples
train_df <- target_df(mtcars[1:16, ], 'gear', c("am", "vs"))
test_df <- target_df(mtcars[17:32, ], 'gear', c("am", "vs"))
x_recipe <- create_recipe(train_df, target_variable="gear")
x_spec_list <- create_spec_kmin(train_df, model_recipe=x_recipe, method="lm", target_variable="gear")
x_spec <- get_list_item(x_spec_list, n=1)
x_fit <- create_fit(x_recipe, x_spec, train_df)
prediction_model <- create_model_prediction(test_df, x_fit )
get_metric(prediction_model, "rmse", "gear")
#> [1] 0.6646039