Model.predict¶
In [ ]:
Model.predict(vdf: (str, vDataFrame),
X: list = [],
name: str = "",
inplace: bool = True)
Predicts using the input relation.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
vdf | str / vDataFrame | ❌ | Object to use to run the prediction. It can also be a customized relation but you need to englobe it using an alias. For example "(SELECT 1) x" is correct whereas "(SELECT 1)" or "SELECT 1" are incorrect. |
X | list | ✓ | List of the columns used to deploy the models. If empty, the model predictors will be used. |
name | str | ✓ | Name of the added vcolumn. If empty, a name will be generated. |
inplace | bool | ✓ | If set to True, the prediction will be added to the vDataFrame. |
In [1]:
from verticapy import vDataFrame
iris = vDataFrame("public.iris")
display(iris)
In [3]:
from verticapy.learn.ensemble import RandomForestClassifier
model = RandomForestClassifier(name = "public.RF_iris",
n_estimators = 20,
max_features = "auto",
max_leaf_nodes = 32,
sample = 0.7,
max_depth = 3,
min_samples_leaf = 5,
min_info_gain = 0.0,
nbins = 32)
model.fit("public.iris", ["PetalLengthCm", "PetalWidthCm"], "Species")
model.predict(iris,
X = ["PetalLengthCm", "PetalWidthCm"],
name = "iris_prediction")
Out[3]:
