Comments (7)
Hi François,
I cannot pinpoint the cause of this error, could please provide more information? Can you create a minimal example when this is happening, or at least the code of your analysis?
from s-jsdm.
Here we go:
model = sjSDM(train_X.samp, train_Y.samp, learning_rate = 0.01, iter = 50L,
biotic = bioticStruct(df = 10),
step_size = 20, #as.integer(nrow(train_X)*0.1),
device = "gpu") #cpu
from s-jsdm.
Thanks, I found two issues:
- data formats: train_Y.samp was a table ->
as.matrix
, train_X.samp had also a weird format, class says it is a data.frame but only withdata.frame(train_X.samp)
it worked - There are NA's in train_X.samp, model.frame removes them but the corresponding rows in Y are not removed
This works (I also switched X and Y because I assume that Y is your occurrence matrix:
library(sjSDM)
model = sjSDM(as.matrix(train_Y.samp), train_X.samp, learning_rate = 0.01, iter = 50L,
biotic = bioticStruct(df = 10),
step_size = 20, #as.integer(nrow(train_X)*0.1),
device = "cpu") #cpu
#This works:
no_na = complete.cases(data.frame(train_X.samp))
model = sjSDM(as.matrix(train_Y.samp)[no_na, ], data.frame(train_X.samp)[no_na, ], learning_rate = 0.01, iter = 50L,
biotic = bioticStruct(df = 10),
step_size = 2, #as.integer(nrow(train_X)*0.1),
device = "cpu") #cpu
reminder for me:
- record NAs in linear and remove the rows in Y
- check data types
from s-jsdm.
Thank you !
Does it mean that the function cannot manage predictors with different types (e.g., numeric and categorical)?
from s-jsdm.
No, it can handle all types. The difference to lm/glm is that they manage the data in one dataset (formula = y~temp + treatment, data = forest_data) and therefore rows with nas are removed in the predictors (tmp, treatment) and the response (y).
However, the model.frame does not support multiple responses (Y1+Y2), that is why sjSDM users have to provide an env object (env = matrix or linear(data=env, formula = ~temp + treatment) and the response (occ=matrix with Y1, Y2) separately. If there are now nas in temp or treatment, those rows are removed only in the predictors but not in the response (occ/Y).
By the way if you want to see how the model.frame parses your formula/predictors:
no_na = complete.cases(data.frame(train_X.samp))
env = linear(data = data.frame(train_X.samp)[no_na, ], formula = ~.) # which is equivalent to env = data.frame(train_X.samp)[no_na, ]
print(env$x)
model = sjSDM(as.matrix(train_Y.samp)[no_na, ], env = env, learning_rate = 0.01, iter = 50L,
biotic = bioticStruct(df = 10),
step_size = 2, #as.integer(nrow(train_X)*0.1),
device = "cpu") #cpu
from s-jsdm.
Ok, noted, thank you for your help Max. :-)
from s-jsdm.
No problem, quite the opposite. I have to thank you, you reveal a lot of weaknesses/bugs in the pkg ^^
Close for now, but the na and data format checker have to be implemented #35
from s-jsdm.
Related Issues (20)
- Easy Model Residuals HOT 1
- Bug: plot.sjSDM doesnt work for species with whitespace HOT 1
- Error: object 'torch' not found in the example Pichler and Hartig- 2020 HOT 2
- Scale of predicted results and questions about tuning HOT 3
- plotInternalStructure: there is no package called ‘ggplodt2’ HOT 1
- Error : torch._C._LinAlgError HOT 3
- Shared contributions in ANOVA HOT 4
- Error when predicting to new data - error: Error : torch._C._LinAlgError: linalg.inv: The diagonal element 3 is zero HOT 4
- offset
- plotInternalStructure error HOT 4
- Species-level predictors? HOT 4
- Installation on hpc HOT 6
- Negative Binomial Throws an error in tuning HOT 1
- Question about bioticStruct() and generating Single Species SDMs from sjSDM HOT 4
- CRAN Issue
- VENN diagram Anova HOT 1
- Problem with installation HOT 1
- Error in sjSDM_cv HOT 8
- PyTorch not installed HOT 13
- Is there a way to assess the significance (p-value?) of pairwise relationships in species associations? HOT 2
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 s-jsdm.