Generate a Schema

This page is archived. Please refer to
Generate a Schema
for the updated version.
A Schema is a JSON dictionary that describes data points you have for your users and for the objects the users interact with on the platform.
In order to start the learning process, you’ll need to map the data types in your software that the Begin AI algorithm will understand. This article will walk you through the guidelines for building your own schema.

Schema Breakdown

Each schema is broken into different parts:

1. Schema Flag

The initial key, schema, flags this document as a schema file for our training algorithm. This is mandatory and must be the only top-level item in the schema.
{ "schema": {} }
After the schema flag, define the following objects at the root level:

2. Users

Defines the aspects of a user relevant to the learning model. (For example, user names, date of birth, location, etc.)

3. Other Objects (eg. Song, Book, Album, Shelf, Product, etc.)

You can optionally define other objects in your schema that the user interacts with (books, magazines, libraries, events, etc). Defining these objects enables you to use them as sources to run your machine learning algorithms.
For example, a bookseller using our recommendation algorithm would define a book object, with titles, genres, author, theme, reader level, and year of publication.

4. Interactions

A mandatory structure within the schema. Interactions describe the actions and sentiments that happen between the user and different objects of your schema.
You can have as many keys and objects as you need, but each must be unique in order to avoid collisions.

Rules for User and other objects

To build a user object:
  1. If your objective is to classify data (ie: Fake Account Detection or Classifier) into various labels, mention all of them in an array
  1. Set a type, which can be any of the following
      • number
      • text
      • category
      • lat_lng_location
      • date
      • boolean
{ "schema": { "user": { "labels" : ["fake", "not_fake"], "date_of_birth": { "type": "date", "min_date": "1960-01-01", "map_to": "user_date_of_birth" }, "joining_date": { "type": "date", "min_date": "1960-01-01" } }
Example of a user object

Interaction objects

There are important rules to follow when building interactions:
  1. They must be on the same level as the user object.
  1. They must contain at least one element inside of it that contains the structure _with_* (For example _with_user, _with_recipe, _with_article, etc.).
    1. ⚠️
      HEADS UP: You can include as many _with_* objects as you need, provided they’re defined in the schema as a high-level object (for example, _with_user).
  1. sentiment: Specific to interaction keys, they weigh the interactions on a scale from negative to positive. The following sentiment options are available
      • Dead (dead)
      • Super Negative (super_negative)
      • Negative (negative)
      • Neutral (neutral)
      • Positive (positive)
      • Super Positive (super_positive)
Below is an example of an interaction object:
{ "schema": { "user": { "labels" : ["fake", "not_fake"], "date_of_birth": { ... }, "joining_date": { ... }, "instructions": [{ ... ] }] }, "content": { ... } }, "interactions": { "_with_content": { "like": { "sentiment": "positive" } }, "_with_user": { "followed": { "sentiment": "positive" }, "report": { "sentiment": "super_negative" } } } } }
Example of an interaction field