Model.predict_proba¶
In [ ]:
Model.predict_proba(vdf: Union[str, vDataFrame],
X: list = [],
name: str = "",
pos_label: Union[int, str, float] = None,
inplace: bool = True)
Returns the model's probabilities 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. |
pos_label | int / str / float | ✓ | Class label, the class for which the probability is calculated. If name is specified and pos_label is unspecified, the probability column names use the following format: name_class1, name_class2, etc. |
inplace | bool | ✓ | If set to True, the prediction will be added to the vDataFrame. |
In [1]:
from verticapy.datasets import load_iris
iris = load_iris()
display(iris)
In [2]:
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(iris, ["PetalLengthCm", "PetalWidthCm"], "Species")
model.predict_proba(iris,
X = ["PetalLengthCm", "PetalWidthCm"],
name = "iris_prediction")
Out[2]:
In [3]:
# You can also specify a pos_label
model.predict_proba(iris,
X = ["PetalLengthCm", "PetalWidthCm"],
name = "iris_prob_setosa",
pos_label = "Iris-setosa")
Out[3]: