plot_pca: Principal Component Analysis of models

View source: R/plot_pca.R

plot_pcaR Documentation

Principal Component Analysis of models

Description

Principal Component Analysis of models residuals. PCA can be used to assess the similarity of the models.

Usage

plot_pca(object, ..., scale = TRUE, arrow_size = 2)

plotModelPCA(object, ..., scale = TRUE)

Arguments

object

An object of class auditor_model_residual created with model_residual function.

...

Other auditor_model_residual objects to be plotted together.

scale

A logical value indicating whether the models residuals should be scaled before the analysis.

arrow_size

Width of the arrows.

Value

A ggplot object.

Examples

dragons <- DALEX::dragons[1:100, ]

# fit a model
model_lm <- lm(life_length ~ ., data = dragons)

lm_audit <- audit(model_lm, data = dragons, y = dragons$life_length)

# validate a model with auditor
mr_lm <- model_residual(lm_audit)

library(randomForest)
model_rf <- randomForest(life_length~., data = dragons)
rf_audit <- audit(model_rf, data = dragons, y = dragons$life_length)
mr_rf <- model_residual(rf_audit)

# plot results
plot_pca(mr_lm, mr_rf)


auditor documentation built on Nov. 2, 2023, 6:13 p.m.