-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtmp2.Rmd
81 lines (73 loc) · 1.55 KB
/
tmp2.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
71
72
73
74
75
76
77
78
79
80
## add benfold
```{r}
library(benford.analysis)
for (i
in
train_data_1 %>%
select(-short_name,-t,-tsi_real,-p) %>%
names
) {
plot(benford(train_data_1[,i], number.of.digits=1))
}
```
1. weedspeed 1
1. tsi 2
1. temperature 2
```{r}
var_is_numeric <-
train_data_1 %>%
select(-t,-p,-tsi_real) %>%
select_if(is.numeric) %>%
names
benfoldstart_time <- now()
benfoldmodel <-
prcomp_irlba(
x = train_data_1 %>%
drop_data_underc %>%
select(var_is_numeric)
,n = 2
,center = T
,scale. = T
)
benfoldend_time <- now()
benfoldend_time-benfoldstart_time
train_pca <-
predict(benfoldmodel
,newdata =
train_data_1 %>%
drop_data_underc %>%
select(var_is_numeric)
)[[1]]
test_pca <-
predict(benfoldmodel
,newdata =
test_data_1 %>%
select(var_is_numeric)
)[[1]]
```
```{r}
train_pca2 <-
predict(benfoldmodel
,newdata =
train_data_1 %>%
drop_data_underc %>%
select(var_is_numeric)
)
test_pca2 <-
predict(benfoldmodel
,newdata =
test_data_1 %>%
select(var_is_numeric)
)
```
```{r}
predict(benfoldmodel
,newdata =
train_data_1 %>%
drop_data_underc %>%
select(var_is_numeric)
) %>%
as.data.frame() %>%
ggplot(aes(PC1,PC2)) +
geom_point(alpha=0.05)
```