saveRF {CORElearn}R Documentation

Saves/loads random forests model to/from file

Description

saveRF: the internal structure of given random forests model is saved to file. loadRF: the internal structure of random forests model is loaded from given file and a model is created and returned.

Usage

saveRF(model, fileName) 
loadRF(formula, data, fileName) 
 

Arguments

model The model structure as returned by CoreModel.
fileName Name of the file to save/load the model to/from.
formula Formula shell match the model loaded from file.
data Data shell match the formula and the model loaded from file.

Details

The function saveRF saves the internal structure of given random forests model to specified file. The model must be a valid structure returned by CoreModel. The function loadRF loads the internal structure of random forests saved in a specified file and returns access to it in the model. The parameters formula and data have to match the loaded model, and are needed for subsequent predictions with the loaded model.

Value

saveRF does not return any value, while loadRF returns a loaded model as a list, similarly to CoreModel.

Author(s)

Marko Robnik-Sikonja, Petr Savicky

See Also

CORElearn, CoreModel.

Examples

# use iris data set

# build random forests model with certain parameters
modelRF <- CoreModel(Species ~ ., iris, model="rf", 
              selectionEstimator="MDL",minNodeWeight=5,rfNoTrees=100)
print(modelRF)

# prediction with node distribution
pred <- predict.CoreModel(modelRF, iris, rfPredictClass=FALSE, type="both")
print(pred)

# saves the random forests model to file
saveRF(modelRF, "tempRF.txt")

# restore the model to another model
loadedRF = loadRF(Species ~ ., iris, "tempRF.txt")

# prediction should be the same
predLoaded <- predict.CoreModel(loadedRF, iris, rfPredictClass=FALSE, type="both")
print(predLoaded)



[Package CORElearn version 0.9.22 Index]