IsolationForest¶
In [ ]:
IsolationForest(name: str,
n_estimators: int = 100,
max_depth: int = 10,
nbins: int = 32,
sample: float = 0.632,
col_sample_by_tree: float = 1.0)
Creates an IsolationForest object using the Vertica IFOREST algorithm.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
name | str | ❌ | Name of the model to be stored in the database. |
n_estimators | int | ✓ | The number of trees in the forest, an integer in the range [1, 1000]. |
max_depth | int | ✓ | Maximum depth of each tree, an integer in the range [1, 100]. |
nbins | int | ✓ | Number of bins used for finding splits in each column, an integer in the range [2, 1000]. A greater value for nbins results in more precise splits, but a longer runtime. |
sample | float | ✓ | The random sample of the input dataset for training each tree, a float in the range [0.0, 1.0]. |
col_sample_by_tree | float | ✓ | The fraction of randomly chosen columns (features) used to build each tree, a float in the range (0,1]. |
Attributes¶
After the object creation, all the parameters become attributes. The model also creates extra attributes when fitting:
| Name | Type | Description |
|---|---|---|
input_relation | str | Training relation. |
X | list | List of the predictors. |
y | str | Response column. |
Methods¶
| Name | Description |
|---|---|
| contour | Draws the model's contour plot. |
| decision_function | Returns the anomaly score using the input relation. |
| deploySQL | Returns the SQL code to deploy the model. |
| drop | Drops the model from the Vertica database. |
| fit | Trains the model. |
| get_attr | Returns model attributes. |
| get_params | Returns model parameters. |
| get_tree | Returns a tablesample with information about the input tree. |
| plot_tree | Draws the input tree (requires the graphviz module). |
| predict | Predicts using the input relation. |
| set_params | Sets the parameters of the model. |
| to_graphviz | Converts the input tree to a Graphviz tree. |
| to_memmodel | Converts a specified Vertica model to a memModel model. |
| to_python | Returns the Python code to deploy the model without using built-in Vertica functions. |
| to_sql | Returns the SQL code to deploy the model without using Vertica built-in functions. |
Example¶
In [29]:
from verticapy.learn.ensemble import IsolationForest
model = IsolationForest(name = "public.iforest_model",
n_estimators = 20,
max_depth = 3,
nbins = 32)
display(model)
