Skip to content

Commit 50c5843

Browse files
committed
Fixed typo in commit message
1 parent 2235cdc commit 50c5843

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

.Rhistory

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#######################################
2+
#### Main function for BIR ####
3+
#######################################
4+
rm(list = ls())
5+
library(glmnet) # Lasso
6+
library(pbapply)
7+
library(GenSA) # simulated annealing
8+
#### File paths ####
9+
data.path <- "Datasets/"
10+
out.path <- "Results/"
11+
function.path <- "Functions/"
12+
source.files <- list.files(path = function.path, recursive = TRUE)
13+
invisible(sapply(source.files, function(x) source(file = paste0(function.path, x))))
14+
Fe <- read.csv(paste0(data.path, "dataset.csv"))
15+
X <- read.csv(paste0(data.path, "embedding.csv"), header=F)
16+
lambda.vals <- seq(0.0001, 3.5, length = 10)
17+
# lambda.vals <- exp(seq(log(0.0001), log(3.5), length.out = 20))
18+
#### Run BIR ####
19+
# Prepare fold ids
20+
seed <- 155000
21+
set.seed(seed)
22+
eval.res.lambda <- c()
23+
lambda.vals.index = 0
24+
best_lambda.norm = 0.06
25+
# Compute BIR on the full dataset with the best lambda
26+
res <- RunBIR(X = scale(X, center=T, scale=F),
27+
Fe = scale(Fe, center=T, scale=T),
28+
lambda = best_lambda.norm)
29+
# Compute BIR on the full dataset with the best lambda
30+
res <- RunBIR(X = scale(X, center=T, scale=F),
31+
Fe = Fe,
32+
lambda = best_lambda.norm)
33+
View(Fe)
34+
# Compute BIR on the full dataset with the best lambda
35+
res <- RunBIR(X = scale(X, center=T, scale=F),
36+
Fe = scale(Fe, center=T, scale=F),
37+
lambda = best_lambda.norm)
38+
# Compute BIR on the full dataset with the best lambda
39+
res <- RunBIR(X = scale(X, center=T, scale=F),
40+
Fe = scale(Fe, center=T, scale=T),
41+
lambda = best_lambda.norm)
42+
Fe
43+
# Some elements of Fe can have a standard deviation (sd) equal to 0, which is an issue when scaling.
44+
# In ordre to solve the problem, the sd for these columns is set to 1.
45+
Fe.sd <- apply(Fe, 2, sd) # Check which columns have sd = 0
46+
zero.sd <- which(Fe.sd == 0)
47+
if (length(wh.zero.sd) > 0){
48+
Fe.sd[wh.zero.sd] <- 1
49+
}
50+
if (length(zero.sd) > 0){
51+
Fe.sd[zero.sd] <- 1
52+
}
53+
# Compute BIR on the full dataset with the best lambda
54+
res <- RunBIR(X = scale(X, center=T, scale=F),
55+
Fe = scale(Fe, center=T, scale=Fe.sd),
56+
lambda = best_lambda.norm)
57+
res
58+
save(res, file = paste0(out.path, "result.RData"))
59+
save(res, file = paste0(out.path, "result_v2.RData"), version = 2)

BIR.R

+9-1
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,17 @@ eval.res.lambda <- do.call(rbind.data.frame, eval.res.lambda)
7575
best_lambda.index <- which.min(eval.res.lambda$avg_MSE)
7676
best_lambda.norm <- eval.res.lambda$lambda.norm[best_lambda.index]
7777

78+
# Some elements of Fe can have a standard deviation (sd) equal to 0, which is an issue when scaling.
79+
# In ordre to solve the problem, the sd for these columns is set to 1.
80+
Fe.sd <- apply(Fe, 2, sd) # Check which columns have sd = 0
81+
zero.sd <- which(Fe.sd == 0)
82+
if (length(zero.sd) > 0){
83+
Fe.sd[zero.sd] <- 1
84+
}
85+
7886
# Compute BIR on the full dataset with the best lambda
7987
res <- RunBIR(X = scale(X, center=T, scale=F),
80-
Fe = scale(Fe, center=T, scale=T),
88+
Fe = scale(Fe, center=T, scale=Fe.sd),
8189
lambda = best_lambda.norm)
8290

8391
save(res, file = paste0(out.path, "result.RData"))

0 commit comments

Comments
 (0)