knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.ext = "png", fig.align = "center" )
library(ggplot2) library(corrplot) library(ppscore)
pps_heatmap <- function(pps_mat) { melted_pps_mat <- melt(pps_mat) pps_heatmap <- ggplot(melted_cormat, aes(Var2, Var1, fill = value)) + geom_tile(color = "white") + scale_fill_gradient2(low = "blue", high = "red", mid = "white", midpoint = 0, limit = c(-1,1), space = "Lab", name="PPS Score") + geom_text(aes(Var2, Var1, label = value), color = "black", size = 4) + theme_minimal() + theme(axis.text.x = element_text(angle = 45, vjust = 1, size = 12, hjust = 1)) + theme(axis.title.x = "feature", axis.text.x = axis.ticks.x = element_blank(), axis.title.y = "target", axis.text.y = axis.ticks.y = element_blank(), panel.grid.major = panel.border = panel.background = axis.ticks = element_blank()) + coord_fixed() + return(pps_heatmap) }
x <- runif(1000000, -2, 2) error <- runif(1000000, -0.5, 0.5) y <- x * x + error df <- data.frame(x, error, y)
ggplot(df, aes(x = x, y = y)) + geom_point()
matrix = ppscore::matrix(df) matrix
pps_heatmap(matrix)
ppscore::score(df, "x", "y")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.