Model.to_python¶
In [ ]:
Model.to_python(name: str = "predict",
return_proba: bool = False,
return_distance_clusters: bool = False,
return_str: bool = False,)
Returns the Python code needed to deploy the model without using built-in Vertica functions.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
name | bool | ✓ | Function Name. |
return_proba | list | ✓ | If set to True and the model is a classifier, the function will return the model probabilities. |
return_distance_clusters | bool | ✓ | If set to True and the model type is KMeans or NearestCentroids, the function will return the model clusters distances. |
return_str | bool | ✓ | If set to True, the function str will be returned. |
Returns¶
str / func : Python function
Example¶
In [12]:
from verticapy.learn.ensemble import XGBoostClassifier
model = XGBoostClassifier("xgb_iris", max_ntree = 2, max_depth = 2)
model.drop()
model.fit("public.iris",
["PetalLengthCm", "PetalWidthCm",],
"Species")
# Returns the string needed to deploy the model's prediction in Python
print(model.to_python(return_str = True))
In [13]:
# Only for classification
# Returns the string needed to deploy the model's probability in Python
print(model.to_python(return_str = True, return_proba = True))
In [14]:
from verticapy.learn.cluster import KMeans
model = KMeans("kmeans_iris",)
model.drop()
model.fit("public.iris",)
# Only for clustering
# Returns the string needed to deploy the distance to the model's clusters in Python
print(model.to_python(return_str = True, return_distance_clusters = True))
In [15]:
# Getting in-memory predictions
model.to_python()([[7.15, 2.9, 5.9, 1.8], [3.15, 12.9, 15.9, 0.8]])
Out[15]:
