Model.deploySQL

In [ ]:
Model.deploySQL(X: list = [], 
                test_relation: str = "", 
                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.
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 [11]:
from verticapy.learn.neighbors import KNeighborsRegressor
model = KNeighborsRegressor(name = "public.KNN_iris")
model.fit("public.iris", ["PetalLengthCm", "SepalLengthCm"], "SepalWidthCm")
display(model.deploySQL())
(SELECT "PetalLengthCm", "SepalLengthCm", "SepalWidthCm", AVG(predict_neighbors) AS predict_neighbors FROM (SELECT x."PetalLengthCm", x."SepalLengthCm", x."SepalWidthCm", 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."SepalWidthCm" 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", "SepalWidthCm", row_id) knr_table