forked from gtzjh/MyModels
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.R
49 lines (38 loc) · 1.94 KB
/
plot.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
rm(list = ls())
setwd("C:/Users/jh/workspace/MyModels/") # Change the path to your work space.
results_dir <- "results/CAT/" # Change the results dir path as you need.
library(tidyverse)
library(yaml)
library(patchwork)
library(showtext)
showtext_opts(dpi = 500)
showtext_auto()
theme_set(theme_bw())
source("plot/Scatter.R")
source("plot/Optimization.R")
source("plot/GlobalExplanation.R")
source("plot/LocalExplanation.R")
# Accuracy: training and test accuracy, scatter plots
scatter_plot <- plot_scatter(paste(results_dir, "scatter_test.csv", sep = ""),
paste(results_dir, "scatter_train.csv", sep = ""),
paste(results_dir, "accuracy.yml", sep = ""))
print(scatter_plot)
ggsave(paste(results_dir, "scatter_plot.png", sep = ""), plot = scatter_plot,
width = 140, height = 140, units = "mm")
# Parameters tuning using Optuna.
optimization_plot <- plot_optimization(paste(results_dir, "optimization.csv", sep = ""))
print(optimization_plot)
ggsave(paste(results_dir, "optimization_plot.png", sep = ""), plot = optimization_plot,
width = 140, height = 140, units = "mm")
# Global explanation
global_explanation_plot <- plot_global(paste(results_dir, "shap_values.csv", sep = ""))
print(global_explanation_plot)
ggsave(paste(results_dir, "global_explanation_plot.png", sep = ""), plot = global_explanation_plot,
width = 190, height = 190, units = "mm")
# Local explanation
# The local explanation may be very large, adjut the output width and height as you need. Here is in a A4 size.
local_explanation_plot <- plot_local(paste(results_dir, "shap_data.csv", sep = ""),
paste(results_dir, "shap_values.csv", sep = ""))
print(local_explanation_plot)
ggsave(paste(results_dir, "local_explanation_plot.png", sep = ""), plot = local_explanation_plot,
width = 210, height = 297, units = "mm")