User-Defined Function#

User-defined functions (UDFs) allow us to combine SQL with deep learning models. These functions wrap around deep learning models.

Here is an illustrative UDF for classifying MNIST images.

!wget -nc
cursor.execute("""DROP UDF IF EXISTS MnistImageClassifier;""")
response = cursor.df()

cursor.create_udf("MnistImageClassifier", True, '')
response = cursor.df()

Run a query using the newly registered UDF!#

query = cursor.table("MNISTVid")
query = query.filter("id = 30 OR id = 50 OR id = 70")
query ="data, MnistImageClassifier(data).label")
response = query.df()