Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resampling using Ensemble ML (classification) #1

Open
oliviafraserusda opened this issue Jan 25, 2022 · 7 comments
Open

Resampling using Ensemble ML (classification) #1

oliviafraserusda opened this issue Jan 25, 2022 · 7 comments

Comments

@oliviafraserusda
Copy link

oliviafraserusda commented Jan 25, 2022

Do you have an example of resampling using ensemble ml (section 2.4) with classification (instead of regression)?

@thengl
Copy link
Member

thengl commented Jan 27, 2022

Yes, example is at: https://opengeohub.github.io/spatial-prediction-eml/spatial-interpolation-using-ensemble-ml.html#spatial-prediction-of-soil-types-factor-variable
It works the same way - you just have to prepare the spatial grid for spatial blocking or use the landmap::train.spLearner function.

@oliviafraserusda
Copy link
Author

Is it possible to predict landmap::train.spLearner across an independent geographic area SpatialPixelsDataFrame for model validation?

@thengl
Copy link
Member

thengl commented Feb 5, 2022

Yes just use argument predictionLocations. See: https://rdrr.io/cran/landmap/man/predict.spLearner.html

@jpgannon
Copy link

I’m having trouble using the predict() function for the purpose above (applying the model to a new geographic area). I’m hoping you can provide some guidance.

The line to create the model I’m using:
mC <- train.spLearner(plots["hpu"],
covariates = spdf_all_layers[,c('tpi20', 'tpi100', 'tpi200m',
'mrvbf', 'hbuaab', 'EDb',
'twid')],
SL.library = SL.library,
super.learner = "classif.glmnet",
parallel = FALSE,
oblique.coords = TRUE)

Then I am trying to use predict() to apply the model to a new geographic location. Both of the following syntax options return the same error (spdf_all_layers2 is an spdf of the new area):

BPhpu <- predict(mC, predictionLocations = spdf_all_layers2[,c('tpi20', 'tpi100', 'tpi200m', 'mrvbf', 'hbuaab', 'EDb', 'twid')])

Or

BPhpu <- predict(mC, predictionLocations = spdf_all_layers2)

Error in [.data.frame(predictionLocations@data, , object@spModel$features) :
undefined columns selected

I’m using the same code to create spfd_all_layers2 as to create the initial one. All columns are named the same, the spdf has the same dimensions, projection, etc.

Are there any known frequent issues with this that I could use to help me troubleshoot?
Thank you!

@jpgannon
Copy link

One more thing: I tried to run predict() with the exact spatial points dataframe used to build the model "spdf_all_layers" above, and it threw the same error.

@oliviafraserusda
Copy link
Author

oliviafraserusda commented Mar 22, 2024 via email

@jpgannon
Copy link

Yeah they are all derived from the same DEM. They are built in the exact same way as the input for the model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants