Comments (4)
This should not be the case. Can you provide a reproducible example?
For me the code below with 100 observations and 2 covariates takes about 1.7 seconds to run.
t1 <- Sys.time()
df <- data.frame(x1 = 1:100, x2 = 1:2)
y <- df$x1 + 3*df$x2 + rnorm(nrow(df))
fit = mlegp(df, y)
predict(fit)
predict(fit, data.frame(x1 = 3, x2 = 2))
t2 <- Sys.time()
print(t2-t1)
Here is my sessionInfo():
sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
other attached packages:
[1] mlegp_3.1.8
loaded via a namespace (and not attached):
[1] compiler_4.0.4 tools_4.0.4 shinyjs_2.0.0
from mlegp.
Hi, sorry I think my initial statement was not correct.
I meant, for predicting on a 1000 x 2 matrix it takes around 2 minutes.
t1 <- Sys.time()
df <- data.frame(x1 = 1:100, x2 = 1:2)
y <- df$x1 + 3*df$x2 + rnorm(nrow(df))
fit = mlegp(df, y)
predict(fit)
predict(fit, data.frame(x1 = seq(1:1000), x2 = runif(1000, min = 1, max = 2)))
t2 <- Sys.time()
print(t2-t1)
> print(t2-t1)
Time difference of 2.209696 mins
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=de_DE.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=de_DE.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=de_DE.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] mlegp_3.1.8
from mlegp.
This was the original code I used:
x <- matrix(runif(60), ncol = 2)
y <- sin(x %*% rep(10, 2))
library(microbenchmark)
gp <- mlegp::mlegp(x, y)
microbenchmark(fitgp <- mlegp::predict.gp(gp, newData = data.frame(X1 = runif(1000), X2 = runif(1000))),
times = 10,
unit = "s")
from mlegp.
This, unfortunately, is expected behavior for a large number of inputs.
For each predicted value, we need to calculate the correlation between it and each of the original inputs (100 calculations in the above example). This is then repeated for each input in the prediction matrix (repeated 1000 times in the above example).
The original code for this was written over 10 years ago and can possibly be optimized (or written in C). I will take a closer look when time allows, but if you want to make any changes, pull requests are welcome. The relevant code is predict.gp() which calls predictNewZ() which calls calcCorOneObs().
from mlegp.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mlegp.