hs_RF_pred: Train random forest model on hyperspec object

Description Usage Arguments Examples

View source: R/hs_RF_pred.R

Description

Train random forest model on hyperspec object

Usage

1
hs_RF_pred(hs.x, model, ...)

Arguments

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

Examples

 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]])

CMET-UGent/MicroRaman documentation built on July 25, 2020, 6:20 p.m.