KernelDensity (Beta)¶
In [ ]:
KernelDensity(name: str,
bandwidth: float = 1,
kernel: str = "gaussian",
p: int = 2,
max_leaf_nodes: int = 1e9,
max_depth: int = 5,
min_samples_leaf: int = 1,
nbins: int = 5,
xlim: list = [])
Creates a KernelDensity object. This object uses pure SQL to compute the final score.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
name | str | ❌ | Name of the model to be stored in the database. |
bandwidth | float | ✓ | The bandwidth of the kernel. |
kernel | str | ✓ | The method used for the plot.
|
p | int | ✓ | The p corresponding to the one of the p-distance (distance metric used during the model computation). |
max_leaf_nodes | int | ✓ | The maximum number of leaf nodes, an integer between 1 and 1e9, inclusive. |
max_depth | int | ✓ | The maximum tree depth, an integer between 1 and 100, inclusive. |
min_samples_leaf | int | ✓ | The minimum number of samples each branch must have after splitting a node, an integer between 1 and 1e6, inclusive. A split that causes fewer remaining samples is discarded. |
nbins | int | ✓ | The number of bins to use to discretize the input features. |
xlim | list | ✓ | List of tuples to use to compute the kernel window. |
Attributes¶
After the object creation, all the parameters become attributes. The model will also create extra attributes when fitting the model:
| Name | Type | Description |
|---|---|---|
input_relation | str | Training relation. |
X | list | List of the predictors. |
map | str | Name of the Mapping Relation. |
tree_name | str | Name of the Tree. |
Methods¶
| Name | Description |
|---|---|
| deploySQL | Returns the SQL code needed to deploy the model. |
| drop | Drops the model from the Vertica DB. |
| features_importance | Computes the model features importance using the Gini Index. |
| fit | Trains the model. |
| get_attr | Returns the model attribute. |
| get_params | Returns the model Parameters. |
| get_tree | Returns a tablesample with all the KernelDensity tree information. |
| plot | Draws the Model. |
| plot_tree | Draws the KernelDensity tree (requires the graphviz module). |
| predict | Computes the KernelDensity score. |
| regression_report / report | Computes a regression report using multiple metrics to evaluate the density estimation (r2, mse, max error...). |
| score | Computes the density estimation score. |
| set_params | Sets the parameters of the model. |
| to_graphviz | Converts the KernelDensity tree to a Graphviz tree. |
Example¶
In [16]:
from verticapy.learn.neighbors import KernelDensity
model = KernelDensity(name = "KDE_test",
bandwidth = 1,
kernel = "gaussian",
p = 2,
max_leaf_nodes = 1e9,
max_depth = 5,
min_samples_leaf = 1,
nbins = 5,
xlim = [])
display(model)
