Description Usage Arguments Examples
Train random forest model on hyperspec object
1 | hs_RF_pred(hs.x, model, ...)
|
hs.x |
Hyperspec object on which to perform predictions |
model |
Model to use for predictions. Output from hs_RF. |
... |
additional parameters passed on to stats::predict |
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 | # Short example
data("hs_example")
# Preprocess
hs_example <- hs_preprocess(hs_example)
# Mock-up metadata
mock_meta <- data.frame(Spectrum_ID = rownames(hs_example@data$spc),
group = factor(c(rep(1,30),rep(2,34))))
# Calculate metrics
hs.RF <- hs_RF(hs.x = hs_example, metadata = mock_meta, spectrumID_col= "Spectrum_ID",
target_var = "group")
# Trained model
print(hs.RF[[1]])
# Confusion matrix
print(hs.RF[[2]])
# Variable importance metric
caret::varImp(hs.RF[[1]])
# Perform predictions
hs_RF_pred(hs.x = hs_example, model = hs.RF[[1]])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.