How to guides
-
 min read

Run AI Predictions in Google Sheets using XOKind AI

It is now possible to run a lead scoring AI model on your data stored in Google Sheets using App Scripts. Follow the step by step guide to create your own!

This article outlines a way to run the XOKind AI application for lead scoring on data stored in Google Sheets using App Scripts. It will make use of the UCI dataset available here as an example to predict if a client will subscribe to a term deposit. The dataset contains around 20 attributes of customers extracted from direct marketing campaigns and will be used to train an instance of the lead scoring app.

There are 3 ways to train an instance of the app and prepare the app for live inference:

1. Using the XOKind Web UI, uploading the document and following the steps to choose the columns, training and deploying it.

2. Using the XOKind API and following the necessary steps to create a data source using the data, creating an app using the required columns, training and deploying the app

3. Using the spreadsheet functions outlined in this document and training, deploying the app right from within Google Sheets.

Apps created using any of the above methods are also accessible using the other methods. For example, apps created using the Web UI can be accessed using the API or spreadsheets and vice versa.

Setup

1. Script

To start, go to Extensions → App scripts and click on App Script.

Once the app script opens, paste the following code in the script:

The app script exposes 2 functions: XOKindTrain and XOKindInference to perform the training and inference on the data. These functions abstract the relevant calls from the XOKind API to setup the data and the app, to perform training on the data, to deploy the app and to perform inference on the trained/deployed app.

The API token used in the function is for testing only. Please get in touch with us for a production ready API token.

2. Data

To setup the data, download the “bank-additional” dataset from the data folder and copy the first 3k rows of “bank-additional.csv” containing ~4k rows (10% of the full dataset) into the google sheet.

Training

Before an app can be used for inference, it needs to be trained on the dataset. To train an app, call the XOKindTrain function on the UCI dataset “=XOKindTrain(A1:3000, U1:3000)”

On any non data cell, change the number of rows to match the data that is copied in the sheet:

This function encapsulates creation of a data source using the data present in the sheet, creation of an app using the columns of the data source, calling the fine tuning on that app and deploying that trained app.

Once the training is done, the cell should be populated with the accuracy obtained from training a lead scoring app.

Inference

After training is done, the app can be used to predict if a new customer is going to subscribe to a term deposit. This inference can be performed in the playground in the web UI, via the API as well as from within the sheet.

To perform inference for a new customer in the sheet, use the function "=XOKindInference(A$1:T$1, A3003:T3003)"

The function call can be dragged across rows just like any other sheet function to predict subsequent or multiple rows. 

Summary

This article showcases the extensibility and the flexibility XOKind API provides to perform lead prediction. The abstraction we provide can also be extended to use any of the XOKind AI apps in many developer friendly environments. We are also actively working on extending the abstractions in other environments like Snowflake and traditional SQL platforms like MySQL/Postgres.

Get started with the XOKind AI low code platform, or schedule a 15 minute consultation to discuss your project with one of our experts.

XOKind Team
Verified writer
OUT-OF-THE-BOX AI

Turn your data into predictive insights in record time

Need help defining your AI project?

Book a 15-min consultation with an AI expert to identify the best use cases for your business.

BOOK CONSULTATION