Model.deploySQL

In [ ]:
Model.deploySQL(X: list = [], 
                test_relation: str = "", 
                predict: bool = False, 
                key_columns: list = [])

Returns the SQL code needed to deploy the model.

Parameters

Name Type Optional Description
X
list
✓
List of the columns used to deploy the model. If empty, the model predictors will be used.
test_relation
str
✓
Relation to use to do the predictions.
predict
bool
✓
If set to True, returns the prediction instead of the probability.
key_columns
list
✓
Columns which are not used but to keep during the computations.

Returns

str : the SQL code needed to deploy the model.

Example

In [14]:
from verticapy.learn.neighbors import KNeighborsClassifier
model = KNeighborsClassifier(name = "public.KNN_iris")
model.fit("public.iris", ["PetalLengthCm", "SepalLengthCm"], "Species")
display(model.deploySQL())
(SELECT row_id, "PetalLengthCm", "SepalLengthCm", "Species", predict_neighbors, COUNT(*) / 5 AS proba_predict FROM (SELECT x."PetalLengthCm", x."SepalLengthCm", x."Species", ROW_NUMBER() OVER(PARTITION BY x."PetalLengthCm", x."SepalLengthCm", row_id ORDER BY POWER(POWER(ABS(x."PetalLengthCm" - y."PetalLengthCm"), 2) + POWER(ABS(x."SepalLengthCm" - y."SepalLengthCm"), 2), 1 / 2)) AS ordered_distance, y."Species" AS predict_neighbors, row_id FROM (SELECT *, ROW_NUMBER() OVER() AS row_id FROM public.iris WHERE "PetalLengthCm" IS NOT NULL AND "SepalLengthCm" IS NOT NULL) x CROSS JOIN (SELECT * FROM public.iris WHERE "PetalLengthCm" IS NOT NULL AND "SepalLengthCm" IS NOT NULL) y) z WHERE ordered_distance <= 5 GROUP BY "PetalLengthCm", "SepalLengthCm", "Species", row_id, predict_neighbors) kneighbors_table