-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptimal.Rmd
71 lines (54 loc) · 1.67 KB
/
optimal.Rmd
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
```{r setup, include=FALSE}
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
```
```{r}
library(readr)
library(dplyr)
library(ggplot2)
library(rjson)
library(gridExtra)
library(reticulate)
```
```{r}
history <- read_csv("model/optimal/history.csv")
```
```{r}
np <- import("numpy")
confusion_matrix <- np$load("model/optimal/confusion_matrix.npy")
confusion_df <- data.frame(Predicted=c("True", "False", "True", "False"), Actual=c("True", "True", "False", "False"), Value=c(confusion_matrix[1], confusion_matrix[2], confusion_matrix[3], confusion_matrix[4]))
confusion_plot <- ggplot(data=confusion_df, aes(x=Actual, y=Predicted, fill=Value)) +
geom_tile() +
geom_text(aes(label=Value), color="white", size=10) +
scale_x_discrete(limits = rev)
confusion_plot
```
```{r}
loss <- ggplot(data=history, aes(x=as.numeric(row.names(history)), y=loss)) +
geom_point() +
geom_line() +
ggtitle("Accuracy vs. Epoch") +
xlab("Epoch") +
ylab("Accuracy")
loss
```
```{r}
accuracy <- ggplot(data=history, aes(x=as.numeric(row.names(history)), y=accuracy)) +
geom_point() +
geom_line() +
ggtitle("Accuracy vs. Epoch") +
xlab("Epoch") +
ylab("Accuracy")
accuracy
```
```{r}
grid.arrange(loss, accuracy, confusion_plot, nrow=2, ncol=2)
```
```{r}
results <- fromJSON(file="model/optimal/results.json")
print(paste("Uncleaned Model Accuracy:", results["accuracy"]))
print(paste("Uncleaned Model Loss:", results["loss"]))
```
```{r}
ggsave(filename="model/optimal/plots/loss.png", plot=loss)
ggsave(filename="model/optimal/plots/accuracy.png", plot=accuracy)
```