isotree.import.model: Load an Isolation Forest model exported from Python

View source: R/isoforest.R

isotree.import.modelR Documentation

Load an Isolation Forest model exported from Python

Description

Loads a serialized Isolation Forest model as produced and exported by the Python version of this package. Note that the metadata must be something importable in R - e.g. column names must be valid for R (numbers are valid for Python's pandas, but not for R, for example).

It's recommended to generate a '.metadata' file (passing 'add_metada_file=TRUE') and to visually inspect said file in any case.

This function is not meant to be used for passing models to and from R - in such case, one can use 'saveRDS' and 'readRDS' instead as they will likely result in smaller file sizes (although this function will still work correctly for serialization within R).

Usage

isotree.import.model(file, lazy_serialization = TRUE)

Arguments

file

Path to the saved isolation forest model. Must be a file path, not a file connection, and the character encoding should correspond to the system's native encoding.

lazy_serialization

Whether to use lazy serialization through the ALTREP system for the resulting objects. See the documentation for this same parameter in isolation.forest for details.

Details

If the model was fit to a ‘DataFrame' using Pandas’ own Boolean types, take a look at the metadata to check if these columns will be taken as booleans (R logicals) or as categoricals with string values '"True"' and '"False"'.

See the documentation for isotree.export.model for details about compatibility of the generated files across different machines and versions.

Value

An isolation forest model, as if it had been constructed through isolation.forest.

See Also

isotree.export.model isotree.restore.handle


isotree documentation built on May 29, 2024, 11:24 a.m.